Skip to content

Commit

Permalink
Address style comments
Browse files Browse the repository at this point in the history
  • Loading branch information
IbraheemA committed Nov 5, 2024
1 parent 96d1d1d commit ed506b8
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pkg/trace/traceutil/otel_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func GetOTelResourceV1(span ptrace.Span, res pcommon.Resource) (resName string)
}

// GetOTelResourceV2 returns the DD resource name based on OTel span and resource attributes.
func GetOTelResourceV2(span ptrace.Span, res pcommon.Resource) (resName string) {
resName = GetOTelAttrValInResAndSpanAttrs(span, res, false, "resource.name")
func GetOTelResourceV2(span ptrace.Span, res pcommon.Resource) string {
resName := GetOTelAttrValInResAndSpanAttrs(span, res, false, "resource.name")
if resName == "" {
if m := GetOTelAttrValInResAndSpanAttrs(span, res, false, "http.request.method", semconv.AttributeHTTPMethod); m != "" {
if m == "_OTHER" {
Expand All @@ -220,27 +220,37 @@ func GetOTelResourceV2(span ptrace.Span, res pcommon.Resource) (resName string)
resName = resName + " " + route
}
}
} else if m := GetOTelAttrValInResAndSpanAttrs(span, res, false, semconv.AttributeMessagingOperation); m != "" {
}
}

if resName == "" {
if m := GetOTelAttrValInResAndSpanAttrs(span, res, false, semconv.AttributeMessagingOperation); m != "" {
resName = m
// use the messaging operation
if dest := GetOTelAttrValInResAndSpanAttrs(span, res, false, semconv.AttributeMessagingDestination, semconv117.AttributeMessagingDestinationName); dest != "" {
resName = resName + " " + dest
}
} else if m := GetOTelAttrValInResAndSpanAttrs(span, res, false, semconv.AttributeRPCMethod); m != "" {
}
}

if resName == "" {
if m := GetOTelAttrValInResAndSpanAttrs(span, res, false, semconv.AttributeRPCMethod); m != "" {
resName = m
// use the RPC method
if svc := GetOTelAttrValInResAndSpanAttrs(span, res, false, semconv.AttributeRPCService); m != "" {
// ...and service if available
resName = resName + " " + svc
}
} else {
resName = span.Name()
}
}

if resName == "" {
resName = span.Name()
}
if len(resName) > MaxResourceLen {
resName = resName[:MaxResourceLen]
}
return
return resName
}

// GetOTelOperationNameV2 returns the DD operation name based on OTel span and resource attributes and given configs.
Expand Down

0 comments on commit ed506b8

Please sign in to comment.