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: excessive hash creation on context attr merging #1117

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

robertlaurin
Copy link
Contributor

Fixes the ordering of attribute merging in some places, switches to using merge! to avoid creating an additional hash on merge.

Copy link
Contributor

@arielvalentin arielvalentin left a comment

Choose a reason for hiding this comment

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

I wonder if there is a linter we could leverage for this 🤔

@robertlaurin
Copy link
Contributor Author

robertlaurin commented Feb 2, 2022

I wonder if there is a linter we could leverage for this

Yeah I thought about it too, but I don't know how we could make it nuanced enough, we don't also want to use it where we want to preserve the thing that is getting merged.

Like here for example, I think we want to preserve the original hash as we potentially nest various client contexts

def context_with_attributes(attributes_hash, parent_context: Context.current)
attributes_hash = attributes(parent_context).merge(attributes_hash)
parent_context.set_value(CURRENT_ATTRIBUTES_HASH, attributes_hash)
end

Also we do not want to accidentally .merge! on the client context attributes as that could have buggy side effects.

@robertlaurin robertlaurin merged commit bc1291a into main Feb 2, 2022
@robertlaurin robertlaurin deleted the use-merge-with-a-bang branch February 2, 2022 22:33
@open-telemetry open-telemetry deleted a comment Feb 2, 2022
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.

3 participants