-
Notifications
You must be signed in to change notification settings - Fork 153
Feature request: Add isTraceSampled method to Tracer #1378
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
Comments
I'd be willing to implement this if it's accepted. |
Hi @icholy, thank you for taking the time to open this feature request. I think the idea is valuable and I'm open to consider it. Before going to the implementation I'd like us to spend some time here in this issue discussing a potential implementation. Those are some points we should discuss and agree on before moving to a PR:
If you're still interested in contributing this function, I'd be happy to collaborate on a proposal. |
|
I agree, let's stick to
I agree with the second point. Regarding the first one, we are in a good direction but I would try to make an effort to not have duplicate logic between the existing The current implementation for the former is: public getXrayTraceId(): string | undefined {
const xRayTraceId = this.get(this.xRayTraceIdVariable);
if (xRayTraceId === '') return undefined;
return xRayTraceId.split(';')[0].replace('Root=', '');
} Given that both methods now need to access the tracing header, I would consider extracting part of the logic and reuse it for both, kind of like: private getXrayTraceData: string[] {
const xRayTraceData = this.get(this.xRayTraceIdVariable);
if (xRayTraceData === '') return undefined;
return xRayTraceData.split(';');
}
public getXrayTraceId(): string | undefined {
const xRayTraceData = this.getXrayTraceData();
if (xRayTraceData.length === 0) return undefined;
return xRayTraceData[0].replace('Root=', '');
}
public isXrayTraceSampled(): boolean {
const xRayTraceData = this.getXrayTraceData();
// TODO: implement
}
Okay. I agree that With that said, I think it would be more consistent to have it called
I'm available to help with the editing during the review phase, but the PR for this feature will have to include changes to the corresponding docs as well. Generally speaking, I think the existing section currently titled "Access AWS X-Ray Root Trace ID" should be changed to something like "Access AWS X-Ray Trace Data", and its content should reflect that:
If you agree with the points/direction, let me know and I'll assign the issue to you and you can start working on a PR. |
Sounds good to me. |
Hi @icholy, I just wanted to check if you were still working on this feature. If not, please let me know so I can put it back on the backlog. |
@dreamorosi I'm on holiday. I'll be back next week. |
Working on this now. |
|
@dreamorosi will there be a release soon? |
Yes, I'm planning a release this week. It'll include the feature |
This is now released under v1.9.0 version! |
Use case
I'd like a attribute in my logs to indicate whether or not a request has been sampled. Something like this:
I can populate the
trace_id
usingTracer#getRootXrayTraceId
, but there's no way to find out if the trace is sampled.Solution/User Experience
A new
isTraceSampled
method on theTracer
class.Alternative solutions
Implement my own
isTraceSampled
function which parses the_X_AMZN_TRACE_ID
header value.Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
The text was updated successfully, but these errors were encountered: