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] Cannot access flags from span context #34739

Open
niko-renko opened this issue Aug 19, 2024 · 11 comments
Open

[pkg/ottl] Cannot access flags from span context #34739

niko-renko opened this issue Aug 19, 2024 · 11 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers pkg/ottl priority:p1 High

Comments

@niko-renko
Copy link

Component(s)

pkg/ottl

What happened?

Description

Cannot access flags from span context. Making a statement that uses flags will fail.

Steps to Reproduce

Make & Use a transformer:

  transform:
    error_mode: ignore
    trace_statements:
    - context: span
      statements:
      - set(attributes["flags"], flags)

Expected Result

Spans will have a flags attribute that contain the flags values from the span context.

Actual Result

2024/08/19 17:23:35 collector server run finished with error: invalid configuration: processors::transform: unable to parse OTTL statement "set(attributes[\"collector_test_2\"], flags)": error while parsing arguments for call to "set": invalid argument at position 1: segment "flags" from path "flags" is not a valid path nor a valid OTTL keyword for the Span context - review https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottlspan to see all valid paths

Collector version

v0.107.0

Environment information

Environment

OS: Ubuntu 20

OpenTelemetry Collector configuration

receivers:
...

processors:
  transform:
    error_mode: ignore
    trace_statements:
    - context: span
      statements:
      - set(attributes["flags"], flags)

exporters:
...

service:
  pipelines:
    receivers: [...]
    processors: [transform]
    exporters: [...]

Log output

2024/08/19 17:23:35 collector server run finished with error: invalid configuration: processors::transform: unable to parse OTTL statement "set(attributes[\"collector_test_2\"], flags)": error while parsing arguments for call to "set": invalid argument at position 1: segment "flags" from path "flags" is not a valid path nor a valid OTTL keyword for the Span context - review https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/contexts/ottlspan to see all valid paths

Additional context

No response

@niko-renko niko-renko added bug Something isn't working needs triage New item requiring triage labels Aug 19, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@TylerHelmuth TylerHelmuth added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers priority:p1 High and removed bug Something isn't working needs triage New item requiring triage labels Aug 19, 2024
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Oct 21, 2024
@Annosha
Copy link

Annosha commented Oct 26, 2024

@TylerHelmuth If this is a beginner friendly issue can I work on it?

@TylerHelmuth
Copy link
Member

@Annosha Sure it is yours

@TylerHelmuth TylerHelmuth removed help wanted Extra attention is needed Stale labels Oct 26, 2024
@TylerHelmuth TylerHelmuth changed the title Cannot access flags from span context [pkg/ottl] Cannot access flags from span context Nov 15, 2024
@TylerHelmuth TylerHelmuth added the help wanted Extra attention is needed label Nov 15, 2024
@avanish-vaghela
Copy link
Contributor

Hey @TylerHelmuth, Could you assign this to me please?

@evan-bradley
Copy link
Contributor

@niko-renko Can you talk more about your use case? The W3C specification for the flags only contains two flags, and it's my understanding that the sampled flag isn't particularly meaningful at the point where we're processing data in the Collector (it must necessarily be 1 since we have the trace).

From what I can tell, we should offer a read-only flags.random_trace_id field or similar that provides a boolean representation of the random-trace-id flag.

@evan-bradley
Copy link
Contributor

Reading more of the field definition, it looks like there are a few more flags that can be stored in the field, but I still think we should consider offering paths for each flag. We could potentially offer something like flags.raw_value or similar for direct access to the bit sequence.

@TylerHelmuth
Copy link
Member

@evan-bradley to start can we implement it like we implemented flags for logs

@evan-bradley
Copy link
Contributor

Didn't realize logs had a flags field as well, thanks for pointing that out. Are you ware of any usages of that field? I think the UX is likely not very good:

  1. Reading out the flags as an integer doesn't seem immediately useful to me, I'm not clear what a user would be able to do with the raw value. Also since there are only a limited set of flags, it would probably make sense to have OTTL pull them out individually since we don't have the bitwise operations necessary to allow users to read them in a statement.
  2. Right now the logs proto field says it only contains W3C trace context flags, which I've been told should be considered read-only in Collector processors until someone comes to us with a compelling use case for writing to them. At a minimum, without bitwise operators they're going to be hard to work with.

Unless users are looking for only access to the raw bit sequence, I think we should consider implementing something different for traces and look to update the logs context to match once we're happy with it.

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Dec 16, 2024

Are you ware of any usages of that field

I am not.

If the current logs implementation is not useful I am ok with implementing flags for spans with specific flags in mind, but I do think we should make a generic path like logs in case there is some custom function someone wants to build that does something with the raw flags.

Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers pkg/ottl priority:p1 High
Projects
None yet
5 participants