-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[cmd/telemetrygen] remove reliance on JSON unmarshalling for status code string #26985
[cmd/telemetrygen] remove reliance on JSON unmarshalling for status code string #26985
Conversation
…mmand - strings were not valid JSON and would therefore cause the JSON Unmarshal to return an error - each status code is now captured explicitly in a switch case statement - mixed case is now supported when passing it as a string also - `TestSpanStatuses` test was updated to run as sub-tests
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 @jmsnll for fixing this 👍🏻
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 contribution!
I think we'd better merge this after #26668 is merged, in order to double check is pr is valid.
I merged #26668, @fatsheep9146 can you take another look? |
Thanks, I just merged the main to see if the check is passed @mx-psi After all checks are passed, I will approve the pr. |
All related checks are passed, I approved the pr @mx-psi |
…ode string (open-telemetry#26985) Removes the use of JSON Unmarshalling when determining the provided trace status code. The existing implementation allowed both status code and status strings to be set using the command line flag `--status-code` without issue however it's not obvious that the default command line value must be a JSON string as encountered in open-telemetry#25906 I've replaced the existing code with a switch-case statement which is more explicit. Additionally, the code now checks the lowercase version of the provided string, enabling support for mixed-case inputs such as `--status-code unset` and `--status-code Unset` flags. I'm undecided if this is actually better or required since we now understand the original cause of the issue. Example usage is now: ``` telemetrygen traces --otlp-insecure --traces 1 --status-code 0 # unset telemetrygen traces --otlp-insecure --traces 1 --status-code 1 # error telemetrygen traces --otlp-insecure --traces 1 --status-code 2 # ok telemetrygen traces --otlp-insecure --traces 1 --status-code unset telemetrygen traces --otlp-insecure --traces 1 --status-code error telemetrygen traces --otlp-insecure --traces 1 --status-code ok ``` Fixes open-telemetry#25906 Added additional test cases and implemented sub-tests as the tests were quitting after the first falsified case. --------- Co-authored-by: Ziqi Zhao <[email protected]> Co-authored-by: Pablo Baeyens <[email protected]>
Description:
Removes the use of JSON Unmarshalling when determining the provided trace status code.
The existing implementation allowed both status code and status strings to be set using the command line flag
--status-code
without issue however it's not obvious that the default command line value must be a JSON string as encountered in #25906I've replaced the existing code with a switch-case statement which is more explicit. Additionally, the code now checks the lowercase version of the provided string, enabling support for mixed-case inputs such as
--status-code unset
and--status-code Unset
flags.I'm undecided if this is actually better or required since we now understand the original cause of the issue.
Example usage is now:
Link to tracking Issue: Fixes #25906
Testing:
Added additional test cases and implemented sub-tests as the tests were quitting after the first falsified case.
Documentation: No updates to documentation.