-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bretthoerner
changed the title
cleanup: remove unused team arg from registerLastStep
chore(plugin-server): kafka ack cleanup and metric
Mar 22, 2024
bretthoerner
force-pushed
the
brett/acks
branch
4 times, most recently
from
March 22, 2024 20:19
d5ae975
to
4e7dfcf
Compare
bretthoerner
force-pushed
the
brett/acks
branch
2 times, most recently
from
March 22, 2024 20:37
3a7cd0e
to
d8e572f
Compare
bretthoerner
force-pushed
the
brett/acks
branch
from
March 22, 2024 20:50
d8e572f
to
d112f0a
Compare
xvello
approved these changes
Mar 25, 2024
plugin-server/src/kafka/producer.ts
Outdated
}): 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() |
There was a problem hiding this comment.
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
xvello
approved these changes
Mar 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 forwaitForAcks: 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.