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

explicitly check key exists in SimpleCarrier.Get #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tobert
Copy link
Contributor

@tobert tobert commented Sep 29, 2021

Doesn't seem to crash the tests but the old code made me nervous so here we are.

Doesn't seem to crash the tests but the old code made me nervous so here
we are.

Signed-off-by: Amy Tobey <atobey@equinix.com>
@tobert
Copy link
Contributor Author

tobert commented Sep 29, 2021

I think Go maps return the empty value on missing key. I still like that this explicitly says "this function will return empty string if there is no traceparent".

Signed-off-by: Amy Tobey <atobey@equinix.com>
@tobert
Copy link
Contributor Author

tobert commented Sep 29, 2021

Don't mind me arguing with myself. I think I'm right about this and feel compelled to explain:

return otp[key] also returns empty string when the key is missing so it is technically correct.

The change I'm making here is to make it explicit that this function's behavior is to return empty string. It is not a side-effect of map behavior. The correct logic is "we looked and there was no traceparent, you can tell because we gave you back an empty string" not "just do whatever map does".

@tobert
Copy link
Contributor Author

tobert commented Sep 29, 2021

Also it occurs to me that in some situations we can end up with the all-zeroes traceparent string here. I think the propagator stuff avoids that but need to validate what it does when non-recording.

@tobert
Copy link
Contributor Author

tobert commented Sep 29, 2021

(all zeroes is fine I think, I'm just fussy about consistent and/or documented behavior in libs like this)

@edw-eqix edw-eqix removed their request for review May 1, 2023 20:46
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.

1 participant