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

fix(tracing): don't print error when passing nil to span:set_attribute #12079

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

samugi
Copy link
Member

@samugi samugi commented Nov 21, 2023

Summary

An error log was printed whenever a nil attribute was set for a span. This implies every variable has to be nil-checked before it can be assigned to some span attribute. In general it feels more natural to expect that passing nil is accepted without producing any error log or warning.

  • passing a nil value to span:set_attribute is a NOOP if the attribute does not already exist, else it means unsetting that attribute (just like before). Now both of these are applied silently, without printing an error.

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • (no) There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Full changelog

  • [Implement ...]

Issue reference

Fix #[issue number]

@samugi samugi force-pushed the fix/allow-nil-span-attribute branch from 9d5e751 to f6b9da3 Compare November 21, 2023 15:59
@samugi samugi changed the title fix(tracing): allow passing nil to span:set_attribute feat(tracing): allow passing nil to span:set_attribute Nov 21, 2023
@samugi samugi force-pushed the fix/allow-nil-span-attribute branch from f6b9da3 to a1af072 Compare November 21, 2023 16:01
@samugi samugi changed the title feat(tracing): allow passing nil to span:set_attribute fix(tracing): don't print error when passing nil to span:set_attribute Nov 21, 2023
@samugi samugi force-pushed the fix/allow-nil-span-attribute branch from a1af072 to b043ac5 Compare November 21, 2023 16:14
Copy link
Member

@kikito kikito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved - but the nil check could be done before calculating vtyp in order to make the code more performant

* passing a nil value to `span:set_attribute` is a NOOP if the attribute
  does not already exists, else it means unsetting that attribute
* considered a fix because previously this was causing a stack trace
  when the DNS spans were created without a port
@samugi samugi force-pushed the fix/allow-nil-span-attribute branch from b043ac5 to 8db31d6 Compare December 3, 2023 13:02
@samugi samugi merged commit e9ac7c1 into master Dec 5, 2023
24 checks passed
@samugi samugi deleted the fix/allow-nil-span-attribute branch December 5, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants