Skip to content
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

Closed
wants to merge 4 commits into from
Closed

feat: add AWS Xray Propagator #163

wants to merge 4 commits into from

Conversation

EdZou
Copy link

@EdZou EdZou commented Jul 26, 2020

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

  1. Add AWS Xray propagator components
  2. Add corresponding unit test for AWS Xray propagator
  3. Add corresponding README.md file for AWS Xray propagator

@codecov
Copy link

codecov bot commented Jul 26, 2020

Codecov Report

Merging #163 into master will increase coverage by 0.22%.
The diff coverage is n/a.

@@            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     
Impacted Files Coverage Δ
...ors/opentelemetry-propagator-aws-xray/.eslintrc.js 0.00% <0.00%> (ø)
...s/opentelemetry-propagator-aws-xray/src/version.ts 0.00% <0.00%> (ø)
...metry-propagator-aws-xray/src/AWSXRayPropagator.ts 100.00% <0.00%> (ø)
...propagator-aws-xray/test/AWSXRayPropagator.test.ts 100.00% <0.00%> (ø)

let parsedTraceId = INVALID_TRACE_ID;
let parsedSpanId = INVALID_SPAN_ID;
let parsedTraceFlags = null;
while(pos < traceHeader.length) {
Copy link
Contributor

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.

Copy link
Author

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

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

@@ -0,0 +1,76 @@
{
"name": "opentelemetry-propagator-aws-xray",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "opentelemetry-propagator-aws-xray",
"name": "@opentelemetry/propagator-aws-xray",

Copy link
Member

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?

Copy link
Member

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

Copy link
Author

@EdZou EdZou Jul 28, 2020

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?

Copy link
Member

@dyladan dyladan Jul 28, 2020

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.

Copy link
Author

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) {
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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

@EdZou EdZou marked this pull request as ready for review July 28, 2020 01:12
@EdZou EdZou requested a review from a team July 28, 2020 01:12
@EdZou
Copy link
Author

EdZou commented Jul 30, 2020

Hello, Daniel @dyladan
After discussion with my mentor Anuraag @anuraaga , we believe according to the specification here: https://github.com/open-telemetry/opentelemetry-specification/pull/735/files. We should add our AWS Xray propagator code under js-contrib repo anyway

@dyladan
Copy link
Member

dyladan commented Jul 30, 2020

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.

@anuraaga
Copy link
Contributor

@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).

@EdZou

This comment has been minimized.

@anuraaga
Copy link
Contributor

@EdZou npm link is an alternative to publishing, it should generally work. When we publish that package it will be a different name and we'll have an aws namespace for it like @aws-observability/opentelemetry-propagator-xray.

Anyways, I believe lerna link should work well enough for your example project, but I notice now that at least in your PR the example doesn't have dependencies on the xray packages?

https://github.com/open-o11y/aws-opentelemetry-js/pull/3/files#diff-640d1aab881301a5fabb1482b0fa1d21R24

@EdZou
Copy link
Author

EdZou commented Aug 24, 2020

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

@anuraaga
Copy link
Contributor

@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?

@EdZou EdZou closed this Aug 26, 2020
@obecny obecny added the enhancement New feature or request label Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants