Conversation
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 4, 2026 12:58
e952b37 to
fabb545
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 4, 2026 13:28
fabb545 to
bf492a4
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 9, 2026 13:13
bf492a4 to
4cd789b
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 9, 2026 14:34
4cd789b to
c77b098
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
2 times, most recently
from
September 11, 2026 09:52
fda8ed5 to
e388efc
Compare
solnic
removed this pull request from stack #1192
September 11, 2026 09:57
solnic
added this pull request to stack #1206
September 11, 2026 09:58
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 11, 2026 12:18
e388efc to
6fd4c6b
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 11, 2026 12:35
6fd4c6b to
e08be02
Compare
solnic
removed this pull request from stack #1206
September 14, 2026 08:49
solnic
added this pull request to stack #1210
September 15, 2026 08:50
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 15, 2026 09:13
e08be02 to
76795fa
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 15, 2026 13:44
76795fa to
a89784a
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 15, 2026 14:28
a89784a to
6a8288a
Compare
solnic
marked this pull request as ready for review
September 16, 2026 08:20
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 16, 2026 13:27
6a8288a to
3515519
Compare
solnic
removed this pull request from stack #1210
September 16, 2026 13:27
solnic
added this pull request to stack #1211
September 16, 2026 13:28
solnic
removed this pull request from stack #1211
September 16, 2026 13:33
solnic
changed the base branch from
feat/runtime-metrics-collector
to
feat/runtime-metrics-system-limits
September 16, 2026 13:34
solnic
added this pull request to stack #1214
September 16, 2026 13:34
solnic
marked this pull request as draft
September 16, 2026 13:37
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 16, 2026 13:55
3515519 to
7cbd054
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
4 times, most recently
from
September 17, 2026 08:32
6b3eed1 to
45f4265
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
2 times, most recently
from
September 17, 2026 10:00
1dbe3ae to
ec0c38b
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
2 times, most recently
from
September 17, 2026 11:27
2839899 to
29b6766
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 17, 2026 11:54
29b6766 to
6eef7d2
Compare
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 17, 2026 13:14
6eef7d2 to
e2616d8
Compare
solnic
marked this pull request as ready for review
September 17, 2026 13:15
solnic
force-pushed
the
feat/runtime-metrics-scheduler-utilization
branch
from
September 18, 2026 07:16
e2616d8 to
061c090
Compare
Comment on lines
+113
to
+122
| defp dispatch_utilization(previous, current) do | ||
| {active, total} = | ||
| previous | ||
| |> Enum.zip(current) | ||
| |> Enum.reduce({0, 0}, fn {{_, active0, total0}, {_, active1, total1}}, {active, total} -> | ||
| {active + (active1 - active0), total + (total1 - total0)} | ||
| end) | ||
|
|
||
| :telemetry.execute(@scheduler_event, %{utilization: ratio(active, total)}, %{}) | ||
| end |
There was a problem hiding this comment.
Bug: The dispatch_utilization/2 function is missing a guard for an empty previous argument, which can cause a spurious 0.0 metric to be emitted on the first successful sample.
Severity: LOW
Suggested Fix
Add a function clause to dispatch_utilization/2 to handle cases where the first argument is an empty list, preventing the incorrect metric calculation. For example: defp dispatch_utilization([], _current), do: :ok.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: lib/sentry/metrics/runtime.ex#L113-L122
Potential issue: The `dispatch_utilization/2` function does not handle cases where the
`previous` sample is an empty list but the `current` sample is not. This can occur if
the first call to `scheduler_sample()` returns `[]` (due to
`:erlang.statistics(:scheduler_wall_time)` returning `:undefined` initially) and a
subsequent call returns valid data. In this scenario, `Enum.zip([], current_data)`
results in an empty list, the reduce operation defaults to `{0, 0}`, and `ratio(0, 0)`
calculates `0.0`. This leads to a spurious `0.0` utilization metric being emitted for a
single polling cycle before normal operation resumes.
Also affects:
lib/sentry/metrics/runtime.ex:96~102
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
elixir.runtime.scheduler.utilization, a number between0.0and1.0for how much of the VM's capacity to run code is actually in use.0.0is idle,1.0means there is no headroom left.In practical terms, this will show you how busy the VM's main worker threads were - running application code plus the runtime's own work (GC, memory management, drivers, BIFs) - excluding time blocked on I/O.
Screenshot
If this is close to 1.0 very often for significant periods, you may want an alert set up.