diff --git a/pkg/ottl/contexts/internal/span.go b/pkg/ottl/contexts/internal/span.go index 607cb2e110f9..cb8831842656 100644 --- a/pkg/ottl/contexts/internal/span.go +++ b/pkg/ottl/contexts/internal/span.go @@ -127,6 +127,8 @@ func SpanPathGetSetter[K SpanContext](path ottl.Path[K]) (ottl.GetSetter[K], err } } return accessStatus[K](), nil + case "flags": + return accessFlags[K](), nil default: return nil, FormatDefaultErrorMessage(path.Name(), path.String(), SpanContextName, SpanRef) } @@ -585,3 +587,17 @@ func accessStatusMessage[K SpanContext]() ottl.StandardGetSetter[K] { }, } } + +func accessFlags[K SpanContext]() ottl.StandardGetSetter[K] { + return ottl.StandardGetSetter[K]{ + Getter: func(_ context.Context, tCtx K) (any, error) { + return int64(tCtx.GetSpan().Flags()), nil + }, + Setter: func(_ context.Context, tCtx K, val any) error { + if i, ok := val.(uint32); ok { + tCtx.GetSpan().SetFlags(i) + } + return nil + }, + } +} diff --git a/pkg/ottl/contexts/internal/span_test.go b/pkg/ottl/contexts/internal/span_test.go index 899d12493424..993b033310c8 100644 --- a/pkg/ottl/contexts/internal/span_test.go +++ b/pkg/ottl/contexts/internal/span_test.go @@ -600,6 +600,17 @@ func TestSpanPathGetSetter(t *testing.T) { span.SetEndTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(200))) }, }, + { + name: "flags", + path: &TestPath[*spanContext]{ + N: "flags", + }, + orig: 0x01, + newVal: 0x00, + modified: func(span ptrace.Span) { + span.SetFlags(0x00) + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -674,6 +685,7 @@ func createSpan() ptrace.Span { span.Status().SetCode(ptrace.StatusCodeOk) span.Status().SetMessage("good span") + span.SetFlags(0x01) return span } diff --git a/pkg/ottl/contexts/ottlspan/README.md b/pkg/ottl/contexts/ottlspan/README.md index 6caf0a94862c..8270f5a3a4f7 100644 --- a/pkg/ottl/contexts/ottlspan/README.md +++ b/pkg/ottl/contexts/ottlspan/README.md @@ -42,14 +42,14 @@ The following paths are supported. | kind.deprecated_string | the kind of the span in deprecated string format. Valid values are `SPAN_KIND_UNSPECIFIED`, `SPAN_KIND_INTERNAL`, `SPAN_KIND_SERVER`, `SPAN_KIND_CLIENT`, `SPAN_KIND_PRODUCER`, and `SPAN_KIND_CONSUMER`. When setting, if an invalid value is used `SPAN_KIND_UNSPECIFIED` will be set. This accessor will eventually be removed, use `kind` or `kind.string` instead. | string | | start_time_unix_nano | the start time in unix nano of the span | int64 | | end_time_unix_nano | the end time in unix nano of the span | int64 | -| start_time | the start time in `time.Time` of the span | `time.Time` | -| end_time | the end time in `time.Time` of the span | `time.Time` | +| start_time | the start time in `time.Time` of the span | `time.Time` | +| end_time | the end time in `time.Time` of the span | `time.Time` | | dropped_attributes_count | the dropped attributes count of the span | int64 | | events | the events of the span | ptrace.SpanEventSlice | | dropped_events_count | the dropped events count of the span | int64 | | links | the links of the span | ptrace.SpanLinkSlice | | dropped_links_count | the dropped links count of the span | int64 | - +| flags | the trace flags of the span | int64 | ## Enums @@ -61,8 +61,8 @@ The Span Context supports the enum names from the [traces proto](https://github. | SPAN_KIND_INTERNAL | 1 | | SPAN_KIND_SERVER | 2 | | SPAN_KIND_CLIENT | 3 | -| SPAN_KIND_PRODUCER | 4 | -| SPAN_KIND_CONSUMER | 5 | -| STATUS_CODE_UNSET | 0 | -| STATUS_CODE_OK | 1 | -| STATUS_CODE_ERROR | 2 | +| SPAN_KIND_PRODUCER | 4 | +| SPAN_KIND_CONSUMER | 5 | +| STATUS_CODE_UNSET | 0 | +| STATUS_CODE_OK | 1 | +| STATUS_CODE_ERROR | 2 |