Hi I'm trying to display an attribute across all s...
# support
a
Hi I'm trying to display an attribute across all spans, I tried some thing like
Copy code
Baggage.current().toBuilder().put("enduser.id", userId).build().makeCurrent();
But it does not get reflected in the trace.
p
@Aravind Chintalapalli Please also share your language/framework and what other methods you have tried so that community members have more context
a
The stack is Java/Tomcat
p
@Aravind Chintalapalli Can you check this thread - https://signoz-community.slack.com/archives/C01HWQ1R0BC/p1651517582593439 Might be relevant
s
The baggage entries are only propagated across the process boundaries. They don't get added to span unless you get the baggage entries from current context and enrich the span in your code.
👍 1
a
Oh ok. Then how do I set an attribute across all spans ?
s
a
Thank you very. Can you point point to some resource on how to use
Resource API
s
Here is a SDK configuration guide which also includes the Resource https://github.com/open-telemetry/opentelemetry-java/blob/main/docs/sdk-configuration.md#configuring-an-instance-of-the-sdk. The Resource conceptually represents entities and is the closest thing to which can add attributes to all spans but not doesn't make sense to include user or dynamically changing values.
a
That's a bummer 😞
s
What are you trying to achieve?
a
I want to tag a api request with user id so that I can search the api request by user id.
I'm using struts framework.
s
Why do you have to tag it with every single span? Just tag the top most server span and you should still be able to search with it.
The span is part of trace and you will see the full trace with it
a
oh ? even if I tag one of the span in a trace, will I get the entire trace while searching ?
s
Correct
a
Thats awesome, I'll try it now
Thank you ! it work !
p
nice @Aravind Chintalapalli Can you share what finally worked for you? Would be helpful for people who visit this thread in future
a
I was not able to set dynamic value across spans, but I was able to set the dynamic value as a tag on one of the spans and I was able find the whole trace by searching for the tag.
p
👍