-
Notifications
You must be signed in to change notification settings - Fork 51
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
add functionality for --force-parent-span-id #241
add functionality for --force-parent-span-id #241
Conversation
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.
PR overall is high quality and matches the code around it. Thank you!
The "parentdeadbeef" issue I noted in comments is a mistake I made in parseHex()
or elsewhere that will need a follow-up. I'm inclined to merge this as-is, and follow up with another PR to fix the hex parsing issue.
README.md
Outdated
@@ -119,6 +119,7 @@ then config file, then environment variables. | |||
| --attrs | OTEL_CLI_ATTRIBUTES | span_attributes | k=v,a=b | | |||
| --force-trace-id | OTEL_CLI_FORCE_TRACE_ID | force_trace_id | 00112233445566778899aabbccddeeff | | |||
| --force-span-id | OTEL_CLI_FORCE_SPAN_ID | force_span_id | beefcafefacedead | | |||
| --force-parent-span-id | OTEL_CLI_FORCE_PARENT_SPAN_ID | force_parent_span_id | parentbeefcafede | |
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.
minor nitpick, "parentbeefcafede" isn't hex
data_for_test.go
Outdated
Config: FixtureConfig{ | ||
CliArgs: []string{ | ||
"status", | ||
"--endpoint", "{{endpoint}}", | ||
"--force-trace-id", "00112233445566778899aabbccddeeff", | ||
"--force-span-id", "beefcafefacedead", | ||
"--force-parent-span-id", "parentbeefcafede", |
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.
following off prior comment, if this passes, we have a test & safety gap allowing non-hex to pass through
@@ -106,6 +106,10 @@ func NewProtobufSpanWithConfig(c Config) *tracepb.Span { | |||
span.SpanId, err = parseHex(c.ForceSpanId, 8) | |||
c.SoftFailIfErr(err) | |||
} | |||
if c.ForceParentSpanId != "" { | |||
span.ParentSpanId, err = parseHex(c.ForceParentSpanId, 8) | |||
c.SoftFailIfErr(err) |
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 wonder why this isn't failing?
I'm really glad you built the test this way, this should be failing and it's problematic if it's not.
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.
My bad for thinking tests passed before. They don't. I think if you update the test case to be hex it'll work fine.
hey @tobert, thanks for the feedback. I pushed that change from string to hex, so hopefully it should pass now. 🤞 |
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 pushed a few more changes and a fix to get this ready to merge. Thanks!
similar to
--force-trace-id
and--force-span-id
, this PR adds the ability to specify--force-parent-span-id
orOTEL_CLI_FORCE_PARENT_SPAN_ID
to override a parent span id.cc/ #240