Skip to content

Commit

Permalink
Support span flags
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Oct 15, 2024
1 parent bd82957 commit dc9d1b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions sdk/telemetry/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ func (sl *SpanLink) UnmarshalJSON(data []byte) error {
err = decoder.Decode(&sl.Attrs)
case "droppedAttributesCount", "dropped_attributes_count":
err = decoder.Decode(&sl.DroppedAttrs)
case "flags":
err = decoder.Decode(&sl.Flags)
default:
// Skip unknown.
}
Expand Down
14 changes: 8 additions & 6 deletions sdk/telemetry/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ func TestSpanEncoding(t *testing.T) {
SpanID: [8]byte{0x2},
TraceState: "test=a",
ParentSpanID: [8]byte{0x1},
// https://github.com/open-telemetry/opentelemetry-collector/issues/11267
// Flags: 1,
Flags: 1,
Name: "span.a",
Kind: SpanKindClient,
StartTime: y2k,
Expand All @@ -41,6 +40,7 @@ func TestSpanEncoding(t *testing.T) {
"traceId": "01000000000000000000000000000000",
"spanId": "0200000000000000",
"traceState": "test=a",
"flags": 1,
"name": "span.a",
"kind": 3,
"attributes": [
Expand Down Expand Up @@ -78,6 +78,7 @@ func TestSpanEncoding(t *testing.T) {
"trace_id": "01000000000000000000000000000000",
"span_id": "0200000000000000",
"trace_state": "test=a",
"flags": 1,
"name": "span.a",
"kind": 3,
"attributes": [
Expand Down Expand Up @@ -162,8 +163,7 @@ func TestSpanLinkEncoding(t *testing.T) {
TraceState: "test=green",
Attrs: []Attr{Int("queue", 17)},
DroppedAttrs: 8,
// https://github.com/open-telemetry/opentelemetry-collector/issues/11267
// Flags: 1,
Flags: 1,
}

t.Run("CamelCase", runJSONEncodingTests(link, []byte(`{
Expand All @@ -178,7 +178,8 @@ func TestSpanLinkEncoding(t *testing.T) {
}
}
],
"droppedAttributesCount": 8
"droppedAttributesCount": 8,
"flags": 1
}`)))

t.Run("SnakeCase", runJSONUnmarshalTest(link, []byte(`{
Expand All @@ -193,6 +194,7 @@ func TestSpanLinkEncoding(t *testing.T) {
}
}
],
"dropped_attributes_count": 8
"dropped_attributes_count": 8,
"flags": 1
}`)))
}

0 comments on commit dc9d1b7

Please sign in to comment.