Skip to content

Commit a189b3d

Browse files
committed
otel add status_code
1 parent 84e0ab2 commit a189b3d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

backend/modules/observability/lib/otel/consts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
otelAttributeInput = "cozeloop.input"
2222
otelAttributeOutput = "cozeloop.output"
2323
otelAttributeLogID = "cozeloop.logid"
24+
otelAttributeStatusCode = "cozeloop.status_code"
2425

2526
apmInput = "gen_ai.input"
2627
apmOutput = "gen_ai.output"

backend/modules/observability/lib/otel/otel_convert.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ var (
6868
IsTag: true,
6969
DataType: dataTypeString,
7070
},
71+
"status_code": {
72+
AttributeKey: []string{otelAttributeStatusCode},
73+
IsTag: false,
74+
DataType: dataTypeInt64,
75+
},
7176
"psm": {
7277
AttributeKey: []string{"service.name"},
7378
IsTag: false,
@@ -343,6 +348,11 @@ func OtelSpanConvertToSendSpan(ctx context.Context, spaceID string, resourceScop
343348
}
344349
if conf.IsTag {
345350
tagsLong[fieldKey] = value
351+
} else {
352+
switch fieldKey {
353+
case "status_code":
354+
statusCode = int32(value)
355+
}
346356
}
347357
case dataTypeBool:
348358
value, ok := srcValue.(bool)

0 commit comments

Comments
 (0)