-
Notifications
You must be signed in to change notification settings - Fork 65
feat: Add Envoy Propagator #264
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| const CARRIER_ENVOY_HEADER_KEY = 'x-ot-span-context'; | ||
|
|
||
| const BINARY_PROTO = { |
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.
Not sure if this should be in here like this. I tried using a local file but it doesn't get generated with webpack. Any tips or recommendations for proto?
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.
Not sure if this should be in here like this. I tried using a local file but it doesn't get generated with webpack. Any tips or recommendations for proto?
I think we should generate the lightstep.proto in the same way that we generate the collector.proto. The resulting file would end up in the src/imp/generated_proto directory. See the Makefile.
If we do that, we can probably avoid the dependency on protobufjs since we already use google-protobuf.
| this._propagators[this._opentracing.FORMAT_HTTP_HEADERS] = new LightStepPropagator(this); | ||
| this._propagators[this._opentracing.FORMAT_TEXT_MAP] = new LightStepPropagator(this); | ||
| this._propagators[this._opentracing.FORMAT_BINARY] = new UnsupportedPropagator(this, | ||
| this._propagators[this._opentracing.FORMAT_BINARY] = new LightStepPropagator(this, |
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.
Does it make sense to have the LightstepPropagator now have a default for FORMAT_BINARY?
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.
It looks like go uses the BinaryPropagator by default: https://github.com/lightstep/lightstep-tracer-go/blob/master/tracer.go#L180. I think that corresponds to the EnvoyPropagator from this PR.
I think this makes sense, but have we thought about how this will work with or impact the no-protobuf version of this library?
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.
FORMAT_BINARY should correspond to the binary propagator. BinaryPropagator/EnvoyPropagator/whatever are all the same.
Theoretically this shouldn't impact the no-pb version (as FORMAT_BINARY should map to UnsupportedPropagator correctly over there)
| }); | ||
|
|
||
| it("should propagate binary carriers"); | ||
| it('should propagate binary carriers', () => { |
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.
This is the modified test in here, the rest of the changes were just formatting based on es-lint.
mwear
left a comment
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 not super familiar with the lightstep binary format, so perhaps @austinlparker can weigh in to confirm or correct some of my feedback in this review. I made a pass through this and have provided some suggestions on how I think this should be done though.
|
|
||
| const CARRIER_ENVOY_HEADER_KEY = 'x-ot-span-context'; | ||
|
|
||
| const BINARY_PROTO = { |
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.
Not sure if this should be in here like this. I tried using a local file but it doesn't get generated with webpack. Any tips or recommendations for proto?
I think we should generate the lightstep.proto in the same way that we generate the collector.proto. The resulting file would end up in the src/imp/generated_proto directory. See the Makefile.
If we do that, we can probably avoid the dependency on protobufjs since we already use google-protobuf.
| let msg = binaryCarrier.create(payload); | ||
| let buffer = binaryCarrier.encode(msg).finish(); | ||
| let bufferString = pb.util.base64.encode(buffer, 0, buffer.length); | ||
| carrier[this._envoyHeaderKey] = bufferString; |
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 could be mistaken, but for binary, isn't the carrier just a byte array? If so, I don't think there is a notion of a string key, with a binary value. I think it just writes bytes into the array.
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.
it still needs a key in the headers, and you still need to base64 the output. maybe this would be one-step with google protos?
keep in mind that adding another proto will cause the tracer file size to creep up again, to your above point
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.
Do any of the other Lightstep tracers have an EnvoyPropagator? As I look around I only see BinaryPropagator (this is true for Go and Python anyway).
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.
C++ has one too that just uses the binary propagator to do the encoding but then puts it in the envoy key header.
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 was thinking that we should probably try to do the same. Would it be possible to split to this work into a BinaryPropagator and an Envoy propagator (or instrumentation) that uses it to do the header manipulation?
| let traceGUID = null; | ||
| let sampled = true; | ||
|
|
||
| if (carrier[this._envoyHeaderKey] === undefined) { |
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 believe the same comment for inject about the carrier being a byte array applies here as well.
| this._propagators[this._opentracing.FORMAT_HTTP_HEADERS] = new LightStepPropagator(this); | ||
| this._propagators[this._opentracing.FORMAT_TEXT_MAP] = new LightStepPropagator(this); | ||
| this._propagators[this._opentracing.FORMAT_BINARY] = new UnsupportedPropagator(this, | ||
| this._propagators[this._opentracing.FORMAT_BINARY] = new LightStepPropagator(this, |
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.
It looks like go uses the BinaryPropagator by default: https://github.com/lightstep/lightstep-tracer-go/blob/master/tracer.go#L180. I think that corresponds to the EnvoyPropagator from this PR.
I think this makes sense, but have we thought about how this will work with or impact the no-protobuf version of this library?
| @@ -0,0 +1,11 @@ | |||
| // Underscore.js-like wrapper to left pad a string to a certain length with a character | |||
| export default function _leftpad(str, len, ch) { | |||
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.
is this going to be used in node.js only ? , if so then use String.prototype.repeat instead
| var span = Tracer.startSpan('my_span'); | ||
| var spanContext = span.context(); | ||
| it('should propagate text map carriers', () => { | ||
| let span = Tracer.startSpan('my_span'); |
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.
why let, instead of const ?
| var span = Tracer.startSpan('my_span'); | ||
| var spanContext = span.context(); | ||
| it('should propagate http header carriers', () => { | ||
| let span = Tracer.startSpan('my_span'); |
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.
let -> const
| Tracer._propagators[Tracer._opentracing.FORMAT_HTTP_HEADERS] = new lightstep.B3Propagator(Tracer); | ||
| var span = Tracer.startSpan('my_span'); | ||
| var spanContext = span.context(); | ||
| let span = Tracer.startSpan('my_span'); |
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.
let -> const
| expect(carrier['ot-baggage-creditcard']).to.equal('visa'); | ||
|
|
||
| var extractedContext = Tracer.extract(opentracing.FORMAT_HTTP_HEADERS, carrier); | ||
| let extractedContext = Tracer.extract(opentracing.FORMAT_HTTP_HEADERS, carrier); |
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.
let -> const
| }; | ||
|
|
||
| var context = Tracer.extract(opentracing.FORMAT_HTTP_HEADERS, headers); | ||
| let context = Tracer.extract(opentracing.FORMAT_HTTP_HEADERS, headers); |
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.
let -> const
| }; | ||
|
|
||
| var context = Tracer.extract(opentracing.FORMAT_HTTP_HEADERS, headers); | ||
| let context = Tracer.extract(opentracing.FORMAT_HTTP_HEADERS, headers); |
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.
let -> const
| it('should propagate binary carriers', () => { | ||
| Tracer._propagators[Tracer._opentracing.FORMAT_BINARY] = new lightstep.EnvoyPropagator(Tracer); | ||
|
|
||
| let carrier = {}; |
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.
let -> const
| var span = Tracer.startSpan('test'); | ||
| describe('Tracer#flush', () => { | ||
| it('supports passing no arguments', () => { | ||
| let span = Tracer.startSpan('test'); |
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.
let -> const
| it("supports passing a callback argument", function(done) { | ||
| var span = Tracer.startSpan('test'); | ||
| it('supports passing a callback argument', (done) => { | ||
| let span = Tracer.startSpan('test'); |
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.
let -> const
Adding support for Envoy Propagator, i.e. injecting Span context as a binary string under a single
x-ot-span-contextheader. This is required for applications making requests to services behind Istio. Istio currently uses the envoy propagator which defaults to looking for this header as an incoming value to decode existence of trace.cc: @austinlparker