TraceView: Add scope attributes to span details (#103173)
* Add scope attributes to span details * Tests
This commit is contained in:
@@ -143,7 +143,12 @@ func spanToSpanRow(span *tracev11.Span, libraryTags *commonv11.InstrumentationSc
|
||||
return nil, fmt.Errorf("failed to marshal service tags: %w", err)
|
||||
}
|
||||
|
||||
spanTags, err := json.Marshal(getSpanTags(span))
|
||||
// Get both span tags and scope tags and combine them
|
||||
spanTagsList := getSpanTags(span)
|
||||
scopeTagsList := getScopeTags(libraryTags)
|
||||
spanTagsList = append(spanTagsList, scopeTagsList...)
|
||||
|
||||
spanTags, err := json.Marshal(spanTagsList)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal span tags: %w", err)
|
||||
}
|
||||
@@ -270,6 +275,22 @@ func getSpanTags(span *tracev11.Span) []*KeyValue {
|
||||
return tags
|
||||
}
|
||||
|
||||
func getScopeTags(scope *commonv11.InstrumentationScope) []*KeyValue {
|
||||
if scope == nil || len(scope.Attributes) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
tags := make([]*KeyValue, len(scope.Attributes))
|
||||
for i, attr := range scope.Attributes {
|
||||
val, err := getAttributeVal(attr.Value)
|
||||
if err != nil {
|
||||
logger.Debug("error transforming scope attributes", "err", err)
|
||||
}
|
||||
tags[i] = &KeyValue{Key: attr.Key, Value: val}
|
||||
}
|
||||
return tags
|
||||
}
|
||||
|
||||
func getSpanKind(spanKind tracev11.Span_SpanKind) string {
|
||||
var tagStr string
|
||||
switch spanKind {
|
||||
|
||||
Reference in New Issue
Block a user