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

Don't log full exception stack for expected NPE in noticeTracer #2143

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

jasonjkeller
Copy link
Contributor

@jasonjkeller jasonjkeller commented Nov 13, 2024

Resolves #2141

There's a point early in the agent's lifecycle where the ProfilerService service is not yet initialized that can result in the agent logging the following exception stack:

2024-11-12T16:05:05,468-0800 [22649 36] com.newrelic.agent.instrumentation.ClassTransformerServiceImpl FINEST: exception in noticeTracer: null. This may affect thread profile v2.
java.lang.NullPointerException: Cannot invoke "com.newrelic.agent.profile.ProfilerService.getTransactionProfileService()" because the return value of "com.newrelic.agent.service.ServiceFactory.getProfilerService()" is null
	at com.newrelic.agent.instrumentation.InstrumentationImpl.noticeTracer(InstrumentationImpl.java:381) [newrelic-agent-8.15.0.jar:8.15.0]
	at com.newrelic.agent.instrumentation.InstrumentationImpl.createTracer(InstrumentationImpl.java:199) [newrelic-agent-8.15.0.jar:8.15.0]
	at java.lang.ProcessImpl.waitFor(ProcessImpl.java) [?:?]
	at com.newrelic.agent.utilization.DataFetcher.executeCommand(DataFetcher.java:241) [newrelic-agent-8.15.0.jar:8.15.0]
	at com.newrelic.agent.utilization.DataFetcher.access$000(DataFetcher.java:33) [newrelic-agent-8.15.0.jar:8.15.0]
	at com.newrelic.agent.utilization.DataFetcher$1.call(DataFetcher.java:65) [newrelic-agent-8.15.0.jar:8.15.0]
	at com.newrelic.agent.utilization.DataFetcher$1.call(DataFetcher.java:42) [newrelic-agent-8.15.0.jar:8.15.0]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
	at java.lang.Thread.run(Thread.java:833) [?:?]

Since this is not indicative of a real problem it doesn't seem necessary to always log an exception stack that muddies up the agent logs. This PR changes the logging to just log the message so that it's less alarming:

2024-11-13T14:39:48,969-0800 [45830 44] com.newrelic.agent.instrumentation.ClassTransformerServiceImpl FINEST: Exception in noticeTracer. This may affect thread profile v2. Tracer: null. Error message: Cannot invoke "com.newrelic.agent.profile.ProfilerService.getTransactionProfileService()" because the return value of "com.newrelic.agent.service.ServiceFactory.getProfilerService()" is null

@jasonjkeller jasonjkeller self-assigned this Nov 13, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 70.70%. Comparing base (305a4d9) to head (aa52824).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...lic/agent/instrumentation/InstrumentationImpl.java 16.66% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2143   +/-   ##
=========================================
  Coverage     70.69%   70.70%           
+ Complexity     9985     9982    -3     
=========================================
  Files           841      841           
  Lines         40290    40291    +1     
  Branches       6107     6107           
=========================================
+ Hits          28485    28487    +2     
+ Misses         9062     9059    -3     
- Partials       2743     2745    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jasonjkeller jasonjkeller merged commit c195631 into main Nov 14, 2024
111 checks passed
@jasonjkeller jasonjkeller deleted the notice-tracer-logging branch November 14, 2024 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fix NullPointerException when calling InstrumentationImpl.noticeTracer
4 participants