Skip to content

Make ActorMetricsSpec processing-time and time-in-mailbox tests robust - #8

Merged
pjfanning merged 1 commit into
mainfrom
robust-actor-metrics-spec
Oct 10, 2026
Merged

pjfanning merged 1 commit into
mainfrom
robust-actor-metrics-spec

Conversation

@pjfanning

Copy link
Copy Markdown
Owner

Fixes the ActorMetricsSpec failure seen on #6 (https://github.com/pjfanning/Kamon/actions/runs/38085378060/job/114310667451): "record the processing-time of the receive function" failed with 2 was not equal to 1.

Cause

ActorMonitor records an actor's processing time and time-in-mailbox after receive returns, which can be after the reply has reached the test. This is the same race #5 fixes in RouterMetricsSpec.

  • createTestActor(..., resetState = true) sends a Ping, waits for the Pong and resets the metrics. The Ping's metrics could be recorded after the reset, so the test counted 2.
  • The tests read the distribution once, so they could also run before their own message was recorded.

Changes

  • The fixture waits for the Ping's time-in-mailbox (recorded last) before resetting.
  • The processing-time and time-in-mailbox tests read inside eventually with resetState = false.
  • patienceConfig is 5 s / 5 ms, the same as RouterMetricsSpec. The default 150 ms is tight on CI.

kamon-pekko/Test/compile and scalafmtCheckAll pass locally; CI runs the tests.

🤖 Generated with Claude Code

Both metrics are recorded after the actor's receive returns, which can be
after the reply has arrived. The fixture reset could run before the Ping's
metrics were recorded ("2 was not equal to 1"), and the tests could read
before their own message's metrics were recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjfanning
pjfanning merged commit b148ee8 into main Oct 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant