-
Notifications
You must be signed in to change notification settings - Fork 250
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
http_text_format + w3c trace parent #55
Conversation
@fbogsany 👀 lets start the bike shed of the actual http_text_format api. |
api/test/opentelemetry/distributed_context/propagation/trace_parent_test.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
@fbogsany we could also just not parse the headers at and leave teh trace-ids as hex encoded strings? it would require 2x the memory, but would omit serialization and deserializations. Kind of feel like it should be a Number. maybe we should profile first. |
See discussion in #57. A similar point was raised there. I don't mind leaving them as hex strings, but we should still validate them. |
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
e7046b5
to
927aa38
Compare
@fbogsany comments have been addressed |
7d9ff6f
to
ff8440d
Compare
api/lib/opentelemetry/distributed_context/propagation/binary_format.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
end | ||
|
||
def parse_flags(string) | ||
OpenTelemetry::Trace::TraceFlags.from_byte(string.to_i(16)) |
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.
D'you think we should add a from_string
to TraceFlags
and push the responsibility there?
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 the opentelemetry spec list the number of bytes and the hex format? ie 2 digit hex.
if it lives in the w3c but not in the OT spec I would say that would govern where it should live.
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.
The OT spec says TraceFlags is a single byte of boolean flags. Otherwise it defers to the W3C spec.
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.
then it should live here, as this is using a hex encoding of a byte. Therefore the at the boundary it should be a native byte.
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/test/opentelemetry/distributed_context/propagation/trace_parent_test.rb
Show resolved
Hide resolved
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.
Thanks for taking this work on @ibawt. I left a couple comments. I think the diff would be cleaned up if you could rebase this off of master.
@@ -17,7 +16,22 @@ module Propagation | |||
# Propagation is usually implemented via library-specific request interceptors, where the client-side injects values | |||
# and the server-side extracts them. | |||
class HTTPTextFormat | |||
# TODO | |||
def extract(carrier, &block) |
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.
Would an implicit block be better since we opt for yielding and not using the explicit &block
param.
In either case can we document the parameters to this method as well?
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.
imo with an implicit block you have to read the documentation/implementation rather than the function signature. If you feel strongly I don't mind.
documentation for sure.
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 did the changes, have a look. Not so sure about my documentation though.
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.
Looks good. The alternative would have been to use the block param (block.call) instead of using yield
, but its slightly faster to use yield with an implicit block.
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.
So I looked through the rails source, and I think a good rule is, only name the block if we pass it down to another method. Then it's clear the yield is getting "passed" as it were.
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
re: rebase, now you know why I was poking at getting the other merged :D |
71dd7da
to
fabeaee
Compare
fabeaee
to
e0ced19
Compare
@@ -25,6 +25,10 @@ def from_byte(flags) | |||
end | |||
end | |||
|
|||
def to_s |
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.
Add a 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.
so I moved this into the trace parent, as the trace parent defines the flags it can support due to it's version. It also says that we can only send flags we know about re: version.
Also this pushes the "encoding" choice to the parent, which I think is the correct place for it.
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/trace_parent.rb
Outdated
Show resolved
Hide resolved
RE: http_text_format class, I'm not too sold on the "getter" and "setter" as blocks. But I'd like to see how this will integrate with the rest of the code before bike shedding on it too much. Hence most of the |
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
api/lib/opentelemetry/distributed_context/propagation/http_text_format.rb
Outdated
Show resolved
Hide resolved
# @yield [Carrier, String] the header key | ||
# {SpanContext} | ||
def extract(carrier) | ||
raise Error, 'block must be supplied' unless block_given? |
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 think this should be an ordinary ArgumentError
rather than the OT Error
. Same thing below in inject
.
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.
LGTM - thanks @ibawt!
# A TraceParent is an implementation of the W3C trace context specification | ||
# https://www.w3.org/TR/trace-context/ | ||
# {SpanContext} | ||
class TraceParent |
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.
The layout of this class is not what I am used to seeing. I'm not sure if we have a convention, or if we should have one, but typically I'm used to seeing something like:
class MyClass
#constants
MY_CONST = 1
class << self
#public class methods
def public_class_method; end
private
#private class methods
def private_class_method; end
end
#public instance methods
def public_instance_method; end
private
#private instance methods
def private_instance_method; end
end
Would there be any objections to adopting a similar format for OTel Ruby (and this file)?
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.
so you want the "static" methods up top? That doesn't bother me at all, I'll move it up.
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.
Yeah, there are some that are in the class << self
block and a few that are self.
prefixed. If you wouldn't mind moving them into one class << self
block at the top that'd be awesome!
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 updated it, have a look.
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.
Looks great!
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.
Just the question about formatting. I also wanted to mention: #73 as it's related (but can and should be a seperate PR).
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.
Nice work!
# A TraceParent is an implementation of the W3C trace context specification | ||
# https://www.w3.org/TR/trace-context/ | ||
# {SpanContext} | ||
class TraceParent |
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.
Looks great!
w3c Trace Parent support
questions
https://www.w3.org/TR/trace-context/