Skip to content

fix(instr): Fix Kafka state gauge emission#6156

Open
Dav1dde wants to merge 1 commit into
masterfrom
dav1d/fix-kafka-state-instr
Open

fix(instr): Fix Kafka state gauge emission#6156
Dav1dde wants to merge 1 commit into
masterfrom
dav1d/fix-kafka-state-instr

Conversation

@Dav1dde

@Dav1dde Dav1dde commented Jun 30, 2026

Copy link
Copy Markdown
Member

Our current metrics backend doesn't actually stop emitting gauges, it continuous to emit gauges with the last seen value (which is good), this breaks the intent of the metric.

This fixes the gauge, but has some caveats (like brokers can't disappear and it doesn't handle unknown states), but I think these are acceptable compromises for this metric, as practically these things never happen and the alternatives are much more complicated.

@Dav1dde Dav1dde requested review from a team as code owners June 30, 2026 19:41
@Dav1dde Dav1dde self-assigned this Jun 30, 2026

for state in KAFKA_BROKER_STATES {
relay_statsd::metric!(
gauge(KafkaGauges::BrokerState) = u64::from(*state == broker.state),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if you made this a counter instead? That would auto-clear in a sense, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah but this becomes really awkward with different aggregation intervals. I think that would be harder to visualize.

Honestly, at this point I am thinking about making this a Sentry Metric instead, as that metric alone will cost us ~200-300$ a month.

Before doing that though, I'd still like to see it in Datadog at least for a few days to get an idea of how things are supposed to look work before turning it off.

@Dav1dde Dav1dde changed the title ref(instr): Fix Kafka state gauge emission fix(instr): Fix Kafka state gauge emission Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants