Only report gc_time metric if profiler is enabled #877
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let's only report the
gc_time
metric when there's an actual value toreport to avoid confusion of very small GC times.
If the Profiler is disabled, it reports 0.0 as the value for this
metric. We know when the profiler is enabled by asking it
GC::Profiler.enabled?
.By directly asking the Ruby GC profiler, instead of our wrapper based on
the
enable_gc_instrumentation
config option, we allow users to enableand disable the profiler temporarily with
GC::Profiler.enable
andGC::Profiler.disable
calls in their app.If the profiler is enabled, disabled, and then enabled again, it
remembers the total time from the last time it was enabled. By not
reporting 0 when it is disabled we don't reset the cache and don't
trigger a very high duration being reported the next time it's enabled.
Part of #868