Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] Fix missing Connection_string tag in database Span #1407

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion plugins/input/skywalkingv2/trace_segment_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ func (t *TraceSegmentHandle) parseSpan(span *agent.SpanObject, applicationInstan
} else {
otSpan.StatusCode = skywalkingv3.StatusCodeOk
}

switch {
case span.SpanLayer == agent.SpanLayer_MQ:
t.mappingMessageSystemTag(span, otSpan)
case span.SpanType == agent.SpanType_Exit:
mappingDatabaseTag(span, otSpan)
}

return otSpan
}

Expand All @@ -217,7 +225,7 @@ func mappingDatabaseTag(span *agent.SpanObject, otSpan *skywalkingv3.OtSpan) {
return
}

otSpan.Attribute[skywalkingv3.AttributeDBConnectionString] = dbType + "://" + span.GetPeer()
otSpan.Attribute[skywalkingv3.AttributeDBConnectionString] = strings.ToLower(dbType) + "://" + span.GetPeer()
}

func convertUniIDToString(u *agent.UniqueId) string {
Expand Down
11 changes: 9 additions & 2 deletions plugins/input/skywalkingv3/segment_analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func ParseSegment(span *v3.SpanObject, segment *v3.SegmentObject, cache *Resourc
otSpan.Kind = OpenTracingSpanKindServer
case span.SpanType == v3.SpanType_Exit:
otSpan.Kind = OpenTracingSpanKindClient
mappingDatabaseTag(span, otSpan)
case span.SpanType == v3.SpanType_Local:
otSpan.Kind = OpenTracingSpanKindInternal
default:
Expand Down Expand Up @@ -155,6 +154,14 @@ func ParseSegment(span *v3.SpanObject, segment *v3.SegmentObject, cache *Resourc
} else {
otSpan.StatusCode = StatusCodeOk
}

switch {
case span.SpanLayer == v3.SpanLayer_MQ:
mappingMessageSystemTag(span, otSpan, mapping)
case span.SpanType == v3.SpanType_Exit:
mappingDatabaseTag(span, otSpan)
}

return otSpan
}

Expand All @@ -179,7 +186,7 @@ func mappingDatabaseTag(span *v3.SpanObject, otSpan *OtSpan) {
return
}

otSpan.Attribute[AttributeDBConnectionString] = dbType + "://" + span.GetPeer()
otSpan.Attribute[AttributeDBConnectionString] = strings.ToLower(dbType) + "://" + span.GetPeer()
}

func mappingMessageSystemTag(span *v3.SpanObject, otSpan *OtSpan, mapping map[int32]string) {
Expand Down
Loading