Skip to content

feat: instrumenting ShardHome latency#32885

Merged
johanandren merged 10 commits intosharding-telemetryfrom
shard-home-latency
Feb 16, 2026
Merged

feat: instrumenting ShardHome latency#32885
johanandren merged 10 commits intosharding-telemetryfrom
shard-home-latency

Conversation

@sebastian-alfers
Copy link
Contributor

No description provided.

Copy link
Contributor

@johanandren johanandren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but potentially align the method names to say exactly what they are callbacks for instead of fixing the Javadoc from my feedback.

def dependencies: immutable.Seq[String]

/**
* Triggered when the shard coordinator requests the home of a shard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is called in the ShardRegion though, so "when a region requests the home of a shard"?

def requestGetShardHome(): Unit

/**
* Triggered when the shard coordinator responds with the home of a shard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not when it response but when the region receives the response (so potentially cluster roundtrip network + the time for the coordinator to reply)?

Copy link
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good, with a few comments


override def dependencies: immutable.Seq[String] = Nil

override def requestGetShardHome(): Unit = ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to include typeName and maybe even shard id as parameters?

}
}

private def requestShardHome(coordinator: Option[ActorRef], shard: ShardId): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't coordinator already an instance variable in ShardRegion, so no need to pass it as parameter here?

requestDurations.nonEmpty shouldBe true
requestDurations.foreach { duration =>
duration > 0 shouldBe true
duration < 20 shouldBe true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be flaky in CI, it may take longer than 20 milliseconds, and you should measure such durations with System.nanoTime

it's not even guaranteed that it will be > 0

I don't think you need to use clock time at all in the test, but just set it to 1 in requestGetShardHome and 2 in responseShardHome. Just some deterministic values that can be asserted to verify that the methods have been called.

@johanandren johanandren merged commit 9c2e143 into sharding-telemetry Feb 16, 2026
10 checks passed
@johanandren johanandren deleted the shard-home-latency branch February 16, 2026 10:53
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.

3 participants