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

Bugfix for code level metrics on active record classes #2092

Merged
merged 7 commits into from
Jun 23, 2023

Conversation

tannalynn
Copy link
Contributor

The regex the agent was using didn't account for the possibility of active record adding attributes to inspect, which resulted in trying to call Object.const_get with a class name that was like "Foo(id: integer, created_at: datetime, updated_at: datetime, name: string)", instead of just "Foo". This would cause an error NameError: wrong constant name that prevent code level metrics from gathering the information and would log a warning.
Now, the regex will only grab word characters and :: for the name, preventing the (.... from being included as the class name.
A test was also added to confirm this works properly and prevent issues in the future.

closes #2064

@tannalynn tannalynn marked this pull request as ready for review June 21, 2023 22:35
lib/new_relic/agent/method_tracer_helpers.rb Outdated Show resolved Hide resolved
lib/new_relic/agent/method_tracer_helpers.rb Outdated Show resolved Hide resolved
lib/new_relic/agent/method_tracer_helpers.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

🎉

@github-actions
Copy link
Contributor

SimpleCov Report

Coverage Threshold
Line 94.18% 94%
Branch 85.75% 85%

@tannalynn tannalynn merged commit 27311f6 into dev Jun 23, 2023
@tannalynn tannalynn deleted the 2064_code_level_metrics_active_record_models branch June 23, 2023 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants