Skip to content
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

Merged
merged 6 commits into from
Jul 14, 2023

Conversation

domofactor
Copy link
Contributor

similar to --force-trace-id and --force-span-id, this PR adds the ability to specify --force-parent-span-id or OTEL_CLI_FORCE_PARENT_SPAN_ID to override a parent span id.

cc/ #240

Copy link
Collaborator

@tobert tobert left a 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 |
Copy link
Collaborator

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",
Copy link
Collaborator

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)
Copy link
Collaborator

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.

Copy link
Collaborator

@tobert tobert left a 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.

@domofactor
Copy link
Contributor Author

hey @tobert, thanks for the feedback. I pushed that change from string to hex, so hopefully it should pass now. 🤞

@domofactor domofactor requested a review from tobert July 14, 2023 05:53
README.md Outdated Show resolved Hide resolved
data_for_test.go Outdated Show resolved Hide resolved
data_for_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@tobert tobert left a 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!

@tobert tobert merged commit 0cb7f5a into equinix-labs:main Jul 14, 2023
1 check passed
@domofactor domofactor deleted the add-force-parent-span-id branch September 7, 2023 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants