-
Notifications
You must be signed in to change notification settings - Fork 549
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
feat: add AWS Xray Propagator #163
Conversation
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
==========================================
+ Coverage 94.10% 94.33% +0.22%
==========================================
Files 74 78 +4
Lines 3582 3762 +180
Branches 387 409 +22
==========================================
+ Hits 3371 3549 +178
- Misses 211 213 +2
|
propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts
Outdated
Show resolved
Hide resolved
propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts
Outdated
Show resolved
Hide resolved
let parsedTraceId = INVALID_TRACE_ID; | ||
let parsedSpanId = INVALID_SPAN_ID; | ||
let parsedTraceFlags = null; | ||
while(pos < traceHeader.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Java, this is quite a bit faster than using split
, but I don't know about JS, it may be better to stick to using split
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also confused here, I initially tried to use split method but the Java implementation is in this way so I just followed it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a benchmark utility you can use to test things like this. You can see an example at open-telemetry/opentelemetry-js#1334
You can also use jsperf.com for browser benchmarking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subjectively, I think split
based implementations are typically easier to read, which is an important distinction. I would expect your implementation here to be slightly faster than a split implementation, but not appreciably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the ids are fixed length, it might be easier and faster to use substring also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now think Daniel's consideration makes more sense. Since we have a fixed size tracing header, it can be a little bit faster to use substring, and maybe that is why Java also implements in this way
propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,76 @@ | |||
{ | |||
"name": "opentelemetry-propagator-aws-xray", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"name": "opentelemetry-propagator-aws-xray", | |
"name": "@opentelemetry/propagator-aws-xray", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@open-telemetry/javascript-maintainers do we want to have another namespace or even just a naming convention for vendor-specific and contrib things? Maybe @otel-contrib/propagator-aws-xray
or @opentelemetry/contrib-propagator-aws-xray
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name still needs to be changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, which one should it be changed to? @opentelemetry/contrib-propagator-aws-xray
or @otel-contrib/propagator-aws-xray
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, lets do @opentelemetry/propagator-aws-xray
. I will bring up the naming discussion at tomorrow's SIG meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Thank you so much!
let parsedTraceId = INVALID_TRACE_ID; | ||
let parsedSpanId = INVALID_SPAN_ID; | ||
let parsedTraceFlags = null; | ||
while(pos < traceHeader.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a benchmark utility you can use to test things like this. You can see an example at open-telemetry/opentelemetry-js#1334
You can also use jsperf.com for browser benchmarking.
let parsedTraceId = INVALID_TRACE_ID; | ||
let parsedSpanId = INVALID_SPAN_ID; | ||
let parsedTraceFlags = null; | ||
while(pos < traceHeader.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subjectively, I think split
based implementations are typically easier to read, which is an important distinction. I would expect your implementation here to be slightly faster than a split implementation, but not appreciably.
let parsedTraceId = INVALID_TRACE_ID; | ||
let parsedSpanId = INVALID_SPAN_ID; | ||
let parsedTraceFlags = null; | ||
while(pos < traceHeader.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the ids are fixed length, it might be easier and faster to use substring also.
private _parseTraceFlag(xraySampledFlag: string): TraceFlags | null { | ||
if (xraySampledFlag.length === SAMPLED_FLAG_LENGTH && xraySampledFlag === NOT_SAMPLED) { | ||
return TraceFlags.NONE; | ||
} else if (xraySampledFlag === IS_SAMPLED) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for else
after a return
propagators/opentelemetry-propagator-aws-xray/src/AWSXRayPropagator.ts
Outdated
Show resolved
Hide resolved
Hello, Daniel @dyladan |
I have discussed this with the other maintainers @obecny and @mayurkale22 and we would like to keep vendor-specific code out of our hosted repositories if at all possible. We are happy to code-review vendor propagators and exporters, but we would prefer that these code modules be hosted and deployed from vendor-owned repositories. As an example, you can look at what GCP has done for their cloud trace and cloud monitoring exporters and propagator here https://github.com/GoogleCloudPlatform/opentelemetry-operations-js. At the time this repository was created, we had similar discussions with the GCP folks. |
@dyladan Do you mind adding your perspective to the linked spec PR? https://github.com/open-telemetry/opentelemetry-specification/pull/735/files It'd be better to do that before it gets merged - while yes it only says SHOULD, I think that's usually considered a recommendation since otherwise there's no reason to mention it at all. Not going with the recommendation is something that needs to have some real motivation I think. AWS can host the module - if that's the final decision we're happy to. But I see discrepancy between JS, Java, and the spec in this area where there doesn't seem to be a huge reason to have that discrepancy. Propagators being an interop concern, therefore part of the SDKs does make sense to me, but they do feel vendorish and wanting to split makes sense to me too. My personal opinion is wanting consistency there between Java and JS one way or another though (those are the two languages I've looked at in depth so far). |
This comment has been minimized.
This comment has been minimized.
@EdZou Anyways, I believe |
Yes, I did not explicitly add dependency in package.json, but it still works for instrumenting IdGenerator. Not so sure if that is the key probelm here @anuraaga |
@EdZou @dyladan I debugged the example app and while I didn't confirm for sure, I guess we're waiting on this fix to be released open-telemetry/opentelemetry-js#1387 @dyladan do you think it's possible to make a release so propagators in external packages can work ok? |
Which problem is this PR solving?
As discussed on Node SIG meeting, adding AWS Xray propagator components under opentelemetry-js-contrib/propagators repository
Short description of the changes