fix parent_id formatting inconsistency#1833
Conversation
| }, | ||
| "kind": "SpanKind.INTERNAL", | ||
| "parent_id": null, | ||
| "parent_id": "0x00000000deadbef0", |
| elif isinstance(self.parent, SpanContext): | ||
| parent_id = trace_api.format_span_id(self.parent.span_id) | ||
| parent_id = "0x{}".format( | ||
| trace_api.format_span_id(self.parent.span_id) |
There was a problem hiding this comment.
I'm confused by this. Doesn't format_span_id already format as hex and wouldn't this add 0x twice to the string?
There was a problem hiding this comment.
it changes the values to hex, but doesnt prepend the string w/ 0x, see the _format_context method at line 526
There was a problem hiding this comment.
Probably a gap in my understanding but wouldn't that be inconsistent with trace id and span id values then? Seems weird that we'd render parent_id differently from span/trace ID. Are we forced to do this because we documented it this way? Sounds like a bug in the documentation then :)
There was a problem hiding this comment.
format context prepends 0x to the trace_id and span_id
@staticmethod
@staticmethod
def _format_context(context):
def _format_context(context):
x_ctx = OrderedDict()
x_ctx = OrderedDict()
x_ctx["trace_id"] = "0x{}".format(
x_ctx["trace_id"] = "0x{}".format(
trace_api.format_trace_id(context.trace_id)
trace_api.format_trace_id(context.trace_id)
)
)
x_ctx["span_id"] = "0x{}".format(
x_ctx["span_id"] = "0x{}".format(
trace_api.format_span_id(context.span_id)
trace_api.format_span_id(context.span_id)
)
)
x_ctx["trace_state"] = repr(context.trace_state)
x_ctx["trace_state"] = repr(context.trace_state)
return x_ctx
There was a problem hiding this comment.
This change makes the formatting consistent in parent_id as well
Description
Fixes #1832, funny enough the documentation was showing the parent_id with a leading
0xwhich means it's likely this was working at some point.Type of change
Please delete options that are not relevant.
Does This PR Require a Contrib Repo Change?
Checklist: