Skip to content

The only tool you need to know what is happening and how to fix it.

span attachment fix

ddux2c4932fd8d8f
diff --git a/backend/app/controllers/otelcontrollers/helpers.go b/backend/app/controllers/otelcontrollers/helpers.go
index 9636ec79..f40c0b88 100644
--- a/backend/app/controllers/otelcontrollers/helpers.go
+++ b/backend/app/controllers/otelcontrollers/helpers.go
@@ -3,6 +3,7 @@ package otelcontrollers
import (
"encoding/hex"
"strconv"
+ "strings"
"time"
"github.com/google/uuid"
@@ -20,6 +21,9 @@ func otelTraceIDToUUID(traceID []byte) uuid.UUID {
}
func rayIDToUUID(rayID string) uuid.UUID {
+ if idx := strings.IndexByte(rayID, '-'); idx != -1 {
+ rayID = rayID[:idx]
+ }
b, err := hex.DecodeString(rayID)
if err != nil || len(b) == 0 {
return uuid.New()
diff --git a/backend/app/controllers/otelcontrollers/trace_converter.go b/backend/app/controllers/otelcontrollers/trace_converter.go
index 00e11a4f..7ce0886e 100644
--- a/backend/app/controllers/otelcontrollers/trace_converter.go
+++ b/backend/app/controllers/otelcontrollers/trace_converter.go
@@ -36,15 +36,17 @@ func convertTraces(projectId uuid.UUID, req *coltracepb.ExportTraceServiceReques
spanAttrs := span.Attributes
allAttrs := extractAttributes(spanAttrs)
- traceId := otelTraceIDToUUID(span.TraceId)
- if traceId == uuid.Nil {
- rayId := getStringAttribute(spanAttrs, "cloudflare.ray_id")
- if rayId == "" {
- rayId = getStringAttribute(resourceAttrs, "cloudflare.ray_id")
- }
- if rayId != "" {
- traceId = rayIDToUUID(rayId)
- } else {
+ rayId := getStringAttribute(spanAttrs, "cloudflare.ray_id")
+ if rayId == "" {
+ rayId = getStringAttribute(resourceAttrs, "cloudflare.ray_id")
+ }
+
+ var traceId uuid.UUID
+ if rayId != "" {
+ traceId = rayIDToUUID(rayId)
+ } else {
+ traceId = otelTraceIDToUUID(span.TraceId)
+ if traceId == uuid.Nil {
traceId = uuid.New()
}
}