@@ -77,23 +77,23 @@ func (l *logInfo) withDestinationService(service *workloadapi.Service) *logInfo
7777 return l
7878}
7979
80- func OutputAccesslog (data requestMetric , conn_metrics connMetric , accesslog logInfo ) {
80+ func outputAccesslog (data requestMetric , connMetrics connMetric , accesslog logInfo ) {
8181 // Skip output access log on connection establishment
82- if data .state == TCP_ESTABLISHED && conn_metrics .totalReports == 1 {
82+ if data .state == TCP_ESTABLISHED && connMetrics .totalReports == 1 {
8383 return
8484 }
85- logStr := buildAccesslog (data , conn_metrics , accesslog )
85+ logStr := buildAccesslog (data , connMetrics , accesslog )
8686 fmt .Println ("accesslog:" , logStr )
8787}
8888
89- func buildAccesslog (data requestMetric , conn_metrics connMetric , accesslog logInfo ) string {
90- uptime := calculateUptime (osStartTime , data .lastReportTime )
91- startTime := calculateUptime (osStartTime , data .startTime )
89+ func buildAccesslog (reqMetric requestMetric , connMetrics connMetric , accesslog logInfo ) string {
90+ uptime := calculateUptime (osStartTime , reqMetric .lastReportTime )
91+ startTime := calculateUptime (osStartTime , reqMetric .startTime )
9292 startTimeInfo := fmt .Sprintf ("%v" , startTime )
9393 timeInfo := fmt .Sprintf ("%v" , uptime )
9494 sourceInfo := fmt .Sprintf ("src.addr=%s, src.workload=%s, src.namespace=%s" , accesslog .sourceAddress , accesslog .sourceWorkload , accesslog .sourceNamespace )
9595 destinationInfo := fmt .Sprintf ("dst.addr=%s, dst.service=%s, dst.workload=%s, dst.namespace=%s" , accesslog .destinationAddress , accesslog .destinationService , accesslog .destinationWorkload , accesslog .destinationNamespace )
96- connectionInfo := fmt .Sprintf ("start_time=%s, direction=%s, state=%s, sent_bytes=%d, received_bytes=%d, packet_loss=%d, retransmissions=%d, srtt=%dus, min_rtt=%dus, duration=%vms" , startTimeInfo , accesslog .direction , accesslog .state , conn_metrics .sentBytes , conn_metrics .receivedBytes , conn_metrics .packetLost , conn_metrics .totalRetrans , data .srtt , data .minRtt , (float64 (data .duration ) / 1000000.0 ))
96+ connectionInfo := fmt .Sprintf ("start_time=%s, direction=%s, state=%s, sent_bytes=%d, received_bytes=%d, packet_loss=%d, retransmissions=%d, srtt=%dus, min_rtt=%dus, duration=%vms" , startTimeInfo , accesslog .direction , accesslog .state , connMetrics .sentBytes , connMetrics .receivedBytes , connMetrics .packetLost , connMetrics .totalRetrans , reqMetric .srtt , reqMetric .minRtt , (float64 (reqMetric .duration ) / 1000000.0 ))
9797
9898 logResult := fmt .Sprintf ("%s %s, %s, %s" , timeInfo , sourceInfo , destinationInfo , connectionInfo )
9999 return logResult
0 commit comments