Skip to content
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

chore(plugin-server): kafka ack cleanup and metric #21111

Merged
merged 5 commits into from
Mar 25, 2024
Merged

Conversation

bretthoerner
Copy link
Contributor

@bretthoerner bretthoerner commented Mar 22, 2024

Problem

We want some observability around how long we're waiting on Kafka produces (where we await the ACKs, which is the vast majority of them).

Changes

Add some metrics.

Additionally did some cleanup and made waitForAck a required argument so that it's abundantly clear at the callsite. I considered just making it always await, but we do have 1 use for waitForAcks: false (plugin logs) and I think we want to make some other places (ingestion warnings, maybe even console logs?) not await in the future.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

Yes.

How did you test this code?

Existing tests updated, no functional change.

@bretthoerner bretthoerner changed the title cleanup: remove unused team arg from registerLastStep chore(plugin-server): kafka ack cleanup and metric Mar 22, 2024
@bretthoerner bretthoerner force-pushed the brett/acks branch 4 times, most recently from d5ae975 to 4e7dfcf Compare March 22, 2024 20:19
@bretthoerner bretthoerner force-pushed the brett/acks branch 2 times, most recently from 3a7cd0e to d8e572f Compare March 22, 2024 20:37
@PostHog PostHog deleted a comment from posthog-bot Mar 22, 2024
@bretthoerner bretthoerner requested a review from a team March 22, 2024 21:01
}): Promise<number | null | undefined> => {
status.debug('📤', 'Producing message', { topic: topic })
const produceSpan = getSpan()?.startChild({ op: 'kafka_produce' })
return await new Promise((resolve, reject) => {
if (waitForAck) {
const ackTimer = ingestEventKafkaAckWait.labels(topic).startTimer()
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we're also measuring the blocking produce call, that can block if the producer queue is full, but it's an OK approximation is long as we keep that in mind. To avoid someone misreading the metric, we could:

  • rename it kafka_produce_latency
  • tag it by waitForAck true/false
  • definitely keep it tagged by topic, we'll need that to filter out topics where we amortize the awaits by batching

@bretthoerner bretthoerner enabled auto-merge (squash) March 25, 2024 12:59
@bretthoerner bretthoerner merged commit 30bafdd into master Mar 25, 2024
128 checks passed
@bretthoerner bretthoerner deleted the brett/acks branch March 25, 2024 13:01
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.

2 participants