https://signoz.io logo
#support
Title
# support
a

Aravind Chintalapalli

05/22/2022, 3:06 PM
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

Pranay

05/22/2022, 3:10 PM
@Aravind Chintalapalli Please also share your language/framework and what other methods you have tried so that community members have more context
a

Aravind Chintalapalli

05/22/2022, 3:10 PM
The stack is Java/Tomcat
p

Pranay

05/22/2022, 3:12 PM
@Aravind Chintalapalli Can you check this thread - https://signoz-community.slack.com/archives/C01HWQ1R0BC/p1651517582593439 Might be relevant
s

Srikanth Chekuri

05/22/2022, 3:25 PM
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

Aravind Chintalapalli

05/22/2022, 3:26 PM
Oh ok. Then how do I set an attribute across all spans ?
s

Srikanth Chekuri

05/22/2022, 3:30 PM
a

Aravind Chintalapalli

05/22/2022, 3:38 PM
Thank you very. Can you point point to some resource on how to use
Resource API
s

Srikanth Chekuri

05/22/2022, 3:46 PM
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

Aravind Chintalapalli

05/22/2022, 3:47 PM
That's a bummer 😞
s

Srikanth Chekuri

05/22/2022, 3:48 PM
What are you trying to achieve?
a

Aravind Chintalapalli

05/22/2022, 3:49 PM
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

Srikanth Chekuri

05/22/2022, 3:51 PM
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

Aravind Chintalapalli

05/22/2022, 3:52 PM
oh ? even if I tag one of the span in a trace, will I get the entire trace while searching ?
s

Srikanth Chekuri

05/22/2022, 3:54 PM
Correct
a

Aravind Chintalapalli

05/22/2022, 3:54 PM
Thats awesome, I'll try it now
Thank you ! it work !
p

Pranay

05/22/2022, 4:42 PM
nice @Aravind Chintalapalli Can you share what finally worked for you? Would be helpful for people who visit this thread in future
a

Aravind Chintalapalli

05/23/2022, 4:41 PM
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

Pranay

05/23/2022, 5:54 PM
👍
3 Views