FrankChen021 commented on code in PR #20559:
URL: https://github.com/apache/druid/pull/20559#discussion_r4290852393
##########
extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitter.java:
##########
@@ -242,8 +266,14 @@ public void emit(final Event event)
Set<EventType> eventTypes = config.getEventTypes();
if (event instanceof ServiceMetricEvent) {
+ if (shouldSampleOut((ServiceMetricEvent) event)) {
Review Comment:
[P2] Sample before serializing the event
**Finding:** `shouldSampleOut` is called only after `event.toMap()`,
extra-dimension copying, JSON serialization, and UTF-8 allocation. At a low
sampling rate, every metric that is dropped still pays that CPU and allocation
cost, and a sampled-out event with an unserializable user dimension is counted
as invalid instead of being dropped, which undermines the high-volume purpose
of this feature.
**Suggestion:** Evaluate the sampling decision for `ServiceMetricEvent`
before constructing and serializing the payload, and only serialize metrics
that will be queued.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]