-
Notifications
You must be signed in to change notification settings - Fork 373
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
[PROF-11045] Fix profiling warnings being really hard to silence #4232
Conversation
Since most folks are not using ractors, this is more of a "FYI/BTW". Also, I've slightly tweaked the text to reduce the overall string, while keeping the same info.
…est suite execution
Receiving the logger as argument means that we'll use the latest logger configured via `Datadog.configure`; in contrast with using the `Datadog.logger` directly, since during components initialization the **older/fallback** logger gets used, which won't reflect any settings given. The distinction is subtle but important: consider the case of setting log level. Prior to this PR, the log level got ignored by the `Profiling::Component` since the old/fallback logger usually did not pick itt up. After this PR, enabling profiling and changing the log level in the same `Datadog.configure` block will produce the expected effect of Profiling::Component respecting that log level.
We had left these TODOs a while ago and since I'm cleaning up a number of logging-related things in the profiling component, I decided to go ahead and clear these ones as well.
This makes sure these information messages, when printed, are not printed more than once. I considered what to do with the warning messages as well, but since having individual OnlyOnce instances is quite a bit of boilerplate for the number of warnings we are emitting, I decided to target only this one for now.
Datadog ReportBranch report: ✅ 0 Failed, 22311 Passed, 1476 Skipped, 5m 35.67s Total Time |
These regressions are false positives, I'll see what I can do about updating our config to correct this. |
BenchmarksBenchmark execution time: 2024-12-17 14:38:21 Comparing candidate commit 12ca619 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4232 +/- ##
=======================================
Coverage 97.75% 97.75%
=======================================
Files 1355 1355
Lines 82145 82149 +4
Branches 4216 4216
=======================================
+ Hits 80301 80305 +4
Misses 1844 1844 ☔ View full report in Codecov by Sentry. |
What does this PR do?
This PR fixes the report we had in #4231 that the profiling initialization warnings were hard to silence.
In particular, due to the way the profiling component was accessing the dd-trace-rb logger, any configuration changes to change the log level were actually not visible to the profiling component. This issue is now fixed, and enabling profiling + changing the log level in the same
Datadog.configure
block will be respected.I also included a few more improvements:
OnlyOnce
so even when it does get logged, it will only get logged at most onceMotivation:
Fixes #4231
Change log entry
Yes. Fix profiling warnings being really hard to silence
Additional Notes:
There's still one case where it's not possible to avoid the warning: when starting profiling via an environment variable (e.g.
DD_PROFILING_ENABLED=true bundle exec ddprofrb ruby <somescript>
).This is a result of there not being a way to set the log level of dd-trace-rb via an environment variable. I decided to not tackle this one for now; hopefully the fixes above are enough of an improvement to the status quo ;)
How to test the change?
Here's two sample test cases:
DD_PROFILING_ENABLED=true DD_PROFILING_ALLOCATION_ENABLED=true bundle exec ddprofrb exec ruby -e "Datadog.configure { |c| c.logger.level = Logger::ERROR; c.profiling.enabled = true };"
With this PR prints the "using Ractors may result in allocation profiling stopping" only once, whereas in master it prints it multiple times
DD_PROFILING_ALLOCATION_ENABLED=true bundle exec ruby -e "require 'datadog/auto_instrument'; Datadog.configure { |c| c.logger.level = Logger::ERROR; c.profiling.enabled = true }"
With this PR does not print the message; whereas in master it prints it once.