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

put baggage as Span attribute #5320

Closed
flodetan opened this issue Mar 24, 2023 · 8 comments
Closed

put baggage as Span attribute #5320

flodetan opened this issue Mar 24, 2023 · 8 comments
Labels
Feature Request Suggest an idea for this project Stale

Comments

@flodetan
Copy link

flodetan commented Mar 24, 2023

Is your feature request related to a problem? Please describe.
Yes, I didn't find anywhere to put baggage as Span attribute

Describe the solution you'd like
My opentelemetry-java have tracecparent and baggage propagation, span data was export by otlp exporter.

I have some information propagated through baggage, I want to put baggage to Span attribute to make information be visible in jaeger UI. How can i implement this feature ?

Describe alternatives you've considered
PS : I already tried in SimpleSpanProcessor.onStart() but baggage is empty(not generated yet), and SimpleSpanProcessor.onEnd() but no context provided.
Also tried in w3cTraceContextPropagator and w3cBaggagePropagator, i can get baggage from context , but it doesn't provide dataobject to set baggage.

// SimpleSpanProcessor
  public void onStart(Context parentContext, ReadWriteSpan span) {
   // here no baggage exist in parentContext
  }

public void onEnd(ReadableSpan span) {
   // here no baggage should exist, but no context provided
 }

// W3CTraceContextPropagator
public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C> getter) {
    if (context == null) {
      return Context.root();
    }
    if (getter == null) {
      return context;
    }
    SpanContext spanContext = extractImpl(carrier, getter);
    if (!spanContext.isValid()) {
      return context;
    }
    return context.with(Span.wrap(spanContext));
    // here I can extrace baggage from carrier, but spanContext didn't have any fields to set baggage.
}

Additional context

@flodetan flodetan added the Feature Request Suggest an idea for this project label Mar 24, 2023
@jkwatson
Copy link
Contributor

Take a look at the W3CBaggagePropagator. It will put baggage into the Context, and that can be seen in a SpanProcessor implementation.

@trask
Copy link
Member

trask commented Mar 29, 2023

@whughchen also check out open-telemetry/opentelemetry-java-instrumentation#8023

@jack-berg jack-berg added the needs author feedback Waiting for additional feedback from the author label Apr 5, 2023
@flodetan
Copy link
Author

flodetan commented Apr 6, 2023

Take a look at the W3CBaggagePropagator. It will put baggage into the Context, and that can be seen in a SpanProcessor implementation.

the problem is that in SpanProcessor.onStart() method baggage is empty(haven't generated/propagated yet), and SimpleSpanProcessor.onEnd() method no context provided.

@jkwatson
Copy link
Contributor

jkwatson commented Apr 6, 2023

Well, there are several things here, so let's keep them separate:

  1. Putting some baggage into the context, and making that context the current context.
  2. Getting the baggage out of the current context and adding some baggage item as a span attribute.
  3. Propagating baggage in & out of your process using the provided W3CBaggagePropagator

Have you been able to do any of these three things successfully? Do you have some working code you can share with what you're trying?

@github-actions
Copy link
Contributor

This issue was marked stale due to lack of author feedback. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Apr 13, 2023
@github-actions
Copy link
Contributor

Closed as inactive. Feel free to reopen if this issue is still being worked on.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2023
@mukutbhattacharjee
Copy link

@flodetan were you able to find a solution for this?

@flodetan
Copy link
Author

@flodetan were you able to find a solution for this?
@mukutbhattacharjee yes, see above : #5320

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Suggest an idea for this project Stale
Projects
None yet
Development

No branches or pull requests

5 participants