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 tracer bug with struct literal and enforced_keys #230

Merged
merged 1 commit into from
May 29, 2020

Conversation

binaryseed
Copy link
Collaborator

Fixes a tracer compilation issue when an argument is a matched struct with enforced_keys

fixes #229

@@ -223,6 +223,12 @@ defmodule NewRelic.Tracer.Macro do
Macro.postwalk(args, &rewrite_call_term/1)
end

# Unwrap Structs into Maps when reporting
# They can't always be re-referenced directly since they can have enforced_keys
def rewrite_call_term({:%, _, [{:__aliases__, _, _} = struct, {:%{}, line, members}]}) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Had to play around in iex, but to make sure I understand: this function works because the first value of that tuple would be :%{} if this was a map, vs :% when it's a struct, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it's basically unwrapping a struct literal into plain map.

It's data that's only used for reporting so it's not changing any aspect of the function definition itself.

@binaryseed binaryseed merged commit 3d2c161 into newrelic:master May 29, 2020
@binaryseed binaryseed deleted the tracer-struct branch May 29, 2020 20:03
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.

Compilation error when tracing function with NaiveDateTime
2 participants