-
Notifications
You must be signed in to change notification settings - Fork 175
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
Conform zipkin traceId, spanId, parentId specs #604
base: develop
Are you sure you want to change the base?
Conversation
Using v1 API defined in https://github.com/openzipkin/zipkin-api/blob/7692ca7be4dc3be9225db550d60c4d30e6e9ec59/zipkin-api.yaml traceId to 32 character lowercase hex string spanId to 16 character lowercase hex string parentId to be absent for root span
@@ -124,8 +124,9 @@ def new(cls) -> "TraceInfo": | |||
with any upstream requests. | |||
|
|||
""" | |||
trace_id = str(random.getrandbits(64)) | |||
return cls(trace_id=trace_id, parent_id=None, span_id=trace_id, sampled=None, flags=None) | |||
trace_id = "{0:0{1}x}".format(random.getrandbits(128), 32) |
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.
padded string with leading 0's to reach 32 characters - necessary in case hex string comes up short.
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.
trace_id = "{0:0{1}x}".format(random.getrandbits(128), 32) | |
trace_id = f"{random.getrandbits(128):032x}" |
Parameterizing the 32 makes it quite hard to read the format string, and using f-strings makes this a little easier to understand as well.
This needs to be opt-in and default to false, as the older version of baseplate.py/go library will reject hex ids. We already implemented the opt-in in .go, see the comment there: https://pkg.go.dev/github.com/reddit/baseplate.go/tracing#TracerConfig.UseUUID |
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! It sounds like we're going ahead with the hex format so this looks good but as @fishy pointed out we'll need this to be opt-in for now.
@@ -124,8 +124,9 @@ def new(cls) -> "TraceInfo": | |||
with any upstream requests. | |||
|
|||
""" | |||
trace_id = str(random.getrandbits(64)) | |||
return cls(trace_id=trace_id, parent_id=None, span_id=trace_id, sampled=None, flags=None) | |||
trace_id = "{0:0{1}x}".format(random.getrandbits(128), 32) |
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.
trace_id = "{0:0{1}x}".format(random.getrandbits(128), 32) | |
trace_id = f"{random.getrandbits(128):032x}" |
Parameterizing the 32 makes it quite hard to read the format string, and using f-strings makes this a little easier to understand as well.
trace_id = str(random.getrandbits(64)) | ||
return cls(trace_id=trace_id, parent_id=None, span_id=trace_id, sampled=None, flags=None) | ||
trace_id = "{0:0{1}x}".format(random.getrandbits(128), 32) | ||
span_id = "{0:0{1}x}".format(random.getrandbits(64), 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.
span_id = "{0:0{1}x}".format(random.getrandbits(64), 16) | |
span_id = f"{random.getrandbits(64):016x}" |
@@ -279,7 +279,9 @@ def _to_span_obj( | |||
"binaryAnnotations": binary_annotations, | |||
} | |||
|
|||
span["parentId"] = self.span.parent_id or 0 |
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.
Hm. This means we don't send a parentId at all if it's undefined. Is that right? No default?
Using v1 API defined in https://github.com/openzipkin/zipkin-api/blob/7692ca7be4dc3be9225db550d60c4d30e6e9ec59/zipkin-api.yaml
traceId to 32 character lowercase hex string
spanId to 16 character lowercase hex string
parentId to be absent for root span
Currently required changes to prove out a grafana-agent + tempo tracing architecture.