Skip to content

Commit 4ac6983

Browse files
committed
nit
1 parent d71413a commit 4ac6983

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

source/plugins/go/src/telemetry.go

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -665,18 +665,20 @@ func UpdateTracesErrorMetrics(key string) {
665665

666666
func UpdateTracesInfoMetrics(key string, logEntry string) {
667667
TracesInfoMetricsMutex.Lock()
668-
// 2025-09-18T17:23:19.0195013+00:00, amacoreagent, Information, Pid: 243334, Tid: 15] GigOtlpDataOutput: Identifier:dcr-**.gigl-dce-**, Event:Log, Total Received:10762, Total Published:10762, Total Failed:0, Received EPS:81.18, Published EPS:81.18.
669-
// 2025-09-18T17:23:19.0246002+00:00, amacoreagent, Information, Pid: 243334, Tid: 15] GigOtlpDataOutput: Identifier:dcr-**.gigl-dce-**, Event:Span, Total Received:39080, Total Published:39080, Total Failed:0, Received EPS:264.30, Published EPS:264.30.
670-
if received, published, ok := extractOtlpEPS(logEntry); ok {
671-
if existingReceived, ok := TracesInfoMetrics[key+"Received"]; ok {
672-
TracesInfoMetrics[key+"Received"] = math.Max(existingReceived, received)
673-
} else {
674-
TracesInfoMetrics[key+"Received"] = received
675-
}
676-
if existingPublished, ok := TracesInfoMetrics[key+"Published"]; ok {
677-
TracesInfoMetrics[key+"Published"] = math.Max(existingPublished, published)
678-
} else {
679-
TracesInfoMetrics[key+"Published"] = published
668+
if strings.Contains(key, "Otlp") && strings.Contains(key, "EPS") {
669+
// 2025-09-18T17:23:19.0195013+00:00, amacoreagent, Information, Pid: 243334, Tid: 15] GigOtlpDataOutput: Identifier:dcr-**.gigl-dce-**, Event:Log, Total Received:10762, Total Published:10762, Total Failed:0, Received EPS:81.18, Published EPS:81.18.
670+
// 2025-09-18T17:23:19.0246002+00:00, amacoreagent, Information, Pid: 243334, Tid: 15] GigOtlpDataOutput: Identifier:dcr-**.gigl-dce-**, Event:Span, Total Received:39080, Total Published:39080, Total Failed:0, Received EPS:264.30, Published EPS:264.30.
671+
if received, published, ok := extractOtlpEPS(logEntry); ok {
672+
if existingReceived, ok := TracesInfoMetrics[key+"Received"]; ok {
673+
TracesInfoMetrics[key+"Received"] = math.Max(existingReceived, received)
674+
} else {
675+
TracesInfoMetrics[key+"Received"] = received
676+
}
677+
if existingPublished, ok := TracesInfoMetrics[key+"Published"]; ok {
678+
TracesInfoMetrics[key+"Published"] = math.Max(existingPublished, published)
679+
} else {
680+
TracesInfoMetrics[key+"Published"] = published
681+
}
680682
}
681683
}
682684
TracesInfoMetricsMutex.Unlock()
@@ -745,7 +747,7 @@ func PushToAppInsightsTraces(records []map[interface{}]interface{}, severityLeve
745747
} else if matched, _ := regexp.MatchString(`ContentType .* not supported`, logEntry); matched {
746748
UpdateTracesErrorMetrics("OtlpInvalidContentType")
747749
} else if strings.Contains(logEntry, "GigLA Token not available") {
748-
UpdateTracesInfoMetrics("OtlpInvalidToken", logEntry)
750+
UpdateTracesErrorMetrics("OtlpInvalidToken")
749751
} else if strings.Contains(logEntry, "GigOtlpDataOutput") && strings.Contains(logEntry, "Event:Log") {
750752
UpdateTracesInfoMetrics("OtlpLogsEPS", logEntry)
751753
} else if strings.Contains(logEntry, "GigOtlpDataOutput") && strings.Contains(logEntry, "Event:Span") {
@@ -758,9 +760,11 @@ func PushToAppInsightsTraces(records []map[interface{}]interface{}, severityLeve
758760
}
759761
}
760762

761-
traceEntry := strings.Join(logLines, "\n")
762-
traceTelemetryItem := appinsights.NewTraceTelemetry(traceEntry, severityLevel)
763-
traceTelemetryItem.Properties["tag"] = tag
764-
TelemetryClient.Track(traceTelemetryItem)
763+
if len(logLines) > 0 {
764+
traceEntry := strings.Join(logLines, "\n")
765+
traceTelemetryItem := appinsights.NewTraceTelemetry(traceEntry, severityLevel)
766+
traceTelemetryItem.Properties["tag"] = tag
767+
TelemetryClient.Track(traceTelemetryItem)
768+
}
765769
return output.FLB_OK
766770
}

0 commit comments

Comments
 (0)