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

[ottl] Improve how to check for nil parent_span_id #32918

Open
TylerHelmuth opened this issue May 7, 2024 · 3 comments
Open

[ottl] Improve how to check for nil parent_span_id #32918

TylerHelmuth opened this issue May 7, 2024 · 3 comments
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium processor/transform Transform processor

Comments

@TylerHelmuth
Copy link
Member

Component(s)

No response

Is your feature request related to a problem? Please describe.

Right now if you want to perform a transform only on a root span you have to write a condition that is either

parent_span_id == SpanID(0x0000000000000000)

or

parent_span_id.string == "0000000000000000"

This is because pdata represents empty parent span id as [0, 0, 0, 0, 0, 0, 0, 0, 0]

Describe the solution you'd like

I want to make it more intuitive to identify a root span. While we have a solution, I wouldn't expect a regular user to understand that == nil or == "" will not work and that they need to represent an all-zero span id instead.

I think we could accomplish this with a new IsRootSpan converter that takes no parameters and returns returns true if the current context's parent span id is [0, 0, 0, 0, 0, 0, 0, 0, 0]. But this solution wouldn't help users who are looking for empty span id or trace id.

Another option is to update the way that the contexts handle empty span/trace ids. Instead of returning default values, they could return nil. This would be a breaking change and will remove the ability to actually interact with a trace/span id that actually is all zeros.

Describe alternatives you've considered

We could do nothing.

Additional context

This issue spawned from a user needing to modify only root spans, at which point I realized identifying a root span is difficult to stumble upon.

@TylerHelmuth TylerHelmuth added enhancement New feature or request priority:p2 Medium processor/transform Transform processor pkg/ottl labels May 7, 2024
Copy link
Contributor

github-actions bot commented May 7, 2024

Pinging code owners for processor/transform: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley. See Adding Labels via Comments if you do not have permissions to add labels yourself.

Copy link
Contributor

github-actions bot commented May 7, 2024

Pinging code owners for pkg/ottl: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@evan-bradley
Copy link
Contributor

I don't have the full context necessary to make an informed decision here, but I like the IsRootSpan Converter since it's clearly named and doesn't require the user to think about how that's specified in the underlying data. In particular, this statement would read well:

do_something() where IsRootSpan()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/ottl priority:p2 Medium processor/transform Transform processor
Projects
None yet
Development

No branches or pull requests

2 participants