Is there a way to set the user for traces? #1224
-
I am trying to figure out how to set the userId for the traces based on https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-segment.html. But it seems like |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @kujtimiihoxha, thanks for opening the discussion & for using Powertools. The Tracer utility uses the The As mentioned above, in Lambda, the main segment (of type
If we look at the code of the To evidence this, we can call I would recommend against doing that because the segment in Lambda should be immutable as discussed above. This is also compatible with what stated in the doc section that you linked in your OP:
So unless this is supported by the SDK, Powertools won't be able to support it. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
@dreamorosi thanks it seems like I did not fully understand how x-ray and lambda work together thanks for the response. I will just use annotations instead. |
Beta Was this translation helpful? Give feedback.
Hi @kujtimiihoxha, thanks for opening the discussion & for using Powertools.
The Tracer utility uses the
Segment
andSubsegment
objects fromaws-xray-sdk-core
and doesn't apply any changes to their prototype, so the functionalities are the same as the ones offered by the SDK.The
getSegment()
method from Tracer can return either aSegment
or aSubsegment
. In AWS Lambda this means either thefacade
segment (the one created by AWS Lambda, the service, which is immutable), or any subsegment (which can be the one created by Powertools - i.e.# index.handler
- or any other subsegment created by you).As mentioned above, in Lambda, the main segment (of type
Segment
) is immutable, meaning that y…