Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/ottl] added flag path #34736

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/ottl/contexts/internal/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func SpanPathGetSetter[K SpanContext](path ottl.Path[K]) (ottl.GetSetter[K], err
}
}
return accessStatus[K](), nil
case "flags":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this is a new accessible property added to the span context, can you please also add an entry in the readme?

return accessFlags[K](), nil
default:
return nil, FormatDefaultErrorMessage(path.Name(), path.String(), SpanContextName, SpanRef)
}
Expand Down Expand Up @@ -585,3 +587,17 @@ func accessStatusMessage[K SpanContext]() ottl.StandardGetSetter[K] {
},
}
}

func accessFlags[K SpanContext]() ottl.StandardGetSetter[K] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add a test case for accessing flags to the unit test of the SpanPathGetSetter

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
},
}
}
13 changes: 13 additions & 0 deletions pkg/ottl/contexts/internal/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -675,6 +686,8 @@ func createSpan() ptrace.Span {
span.Status().SetCode(ptrace.StatusCodeOk)
span.Status().SetMessage("good span")

span.SetFlags(0x01)

return span
}

Expand Down
1 change: 1 addition & 0 deletions pkg/ottl/contexts/ottlspan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following paths are supported.
| 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 | trace flags of the span | int64 |


## Enums
Expand Down