Skip to content

WIP: new metrics emitter and histogram strategy #7201

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

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

Groxx
Copy link
Member

@Groxx Groxx commented Aug 22, 2025

Proof of concept on display.

This is an attempt to move away from our opaque and broadly-disliked metrics system, and towards two major changes:

  • use structs to show what tags are available roughly at all time, to make our metrics-emitting easier to understand and safer to change (new fields == build failures until fixed)
  • emit histograms rather than timers (this is just step 1 of like 1000+, to show the core tactic)

Once this runs in prod for a bit, so I have more data to play with, I'll build alerts and dashboards based on the new data, and we can check the runtime cost of these new metrics.
I've selected moderately-used and rather-expensive (high cardinality, high number of calls) metrics for this first one, to try to give us a realistic sample.

Comment on lines 228 to 233
t.metrics.replicationLag(
t.ackLevels.UpdateIfNeededAndGetQueueMaxReadLevel(persistence.HistoryTaskCategoryReplication, pollingCluster),
taskInfos,
msgs,
t.scope,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

I've done it this way mostly because:

  1. the metrics-func is private and local to this file, so it's not too concerning to have it depend on excessively-large objects
  2. each argument is a unique type, so it's not possible to pass them wrong (the main alternative is to pass three integers).

Comment on lines 12 to 14
var Module = fx.Provide(func(s tally.Scope) Emitter {
return Emitter{scope: s}
})
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the only constructor, outside tests. makes it fairly likely that I've got my fx / resource / context / etc injection correct.

Comment on lines +51 to +52
// TODO: this can / likely should be turned into an interface to allow disconnecting from tally,
// to allow providing a specific version or to drop it entirely if desired.
Copy link
Member Author

@Groxx Groxx Aug 22, 2025

Choose a reason for hiding this comment

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

I haven't built that here because the PR is already large, and it's a fair bit simpler to not introduce an interface.

but the resulting Emitter API is very simple compared to Tally, seems likely to be fairly easy to turn into an interface and build a different impl if needed.

@@ -0,0 +1,476 @@
package main
Copy link
Member Author

@Groxx Groxx Aug 22, 2025

Choose a reason for hiding this comment

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

needs a moderate amount of cleanup / "report bad tag formats on the line of code that has the tag, not via a log.Fatal", but you get the idea.

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