Skip to content

Commit 424d680

Browse files
committed
pass punctuator name as constructor argument
1 parent 7c0f04f commit 424d680

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

kafka-streams-framework/src/main/java/org/hypertrace/core/kafkastreams/framework/punctuators/AbstractThrottledPunctuator.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,28 @@ public abstract class AbstractThrottledPunctuator<T> implements Punctuator {
2323
private final KeyValueStore<Long, List<T>> eventStore;
2424
private final ThrottledPunctuatorConfig config;
2525
private final MeterRegistry meterRegistry;
26+
private final String punctuatorName;
2627

2728
public AbstractThrottledPunctuator(
2829
Clock clock,
2930
ThrottledPunctuatorConfig config,
3031
KeyValueStore<Long, List<T>> eventStore,
31-
MeterRegistry meterRegistry) {
32+
MeterRegistry meterRegistry,
33+
String punctuatorName) {
3234
this.clock = clock;
3335
this.config = config;
3436
this.eventStore = eventStore;
3537
this.meterRegistry = meterRegistry;
38+
this.punctuatorName = resolvePunctuatorName(punctuatorName);
3639
}
3740

3841
public AbstractThrottledPunctuator(
3942
Clock clock, ThrottledPunctuatorConfig config, KeyValueStore<Long, List<T>> eventStore) {
40-
this(clock, config, eventStore, null);
43+
this(clock, config, eventStore, null, null);
44+
}
45+
46+
private String resolvePunctuatorName(String name) {
47+
return (name != null && !name.isBlank()) ? name : this.getClass().getSimpleName();
4148
}
4249

4350
public void scheduleTask(long scheduleMs, T event) {
@@ -165,12 +172,12 @@ private long normalize(long timestamp) {
165172

166173
private void publishMetrics(int totalProcessedTasks, boolean yielded) {
167174
if (meterRegistry != null) {
168-
String className = this.getClass().getSimpleName();
169175
meterRegistry
170-
.counter("throttled.punctuator.processed.task.count", Tags.of("class", className))
176+
.counter(
177+
"throttled.punctuator.processed.task.count", Tags.of("punctuator", punctuatorName))
171178
.increment(totalProcessedTasks);
172179
meterRegistry.gauge(
173-
"throttled.punctuator.yielded", Tags.of("class", className), yielded ? 1 : 0);
180+
"throttled.punctuator.yielded", Tags.of("punctuator", punctuatorName), yielded ? 1 : 0);
174181
}
175182
}
176183
}

0 commit comments

Comments
 (0)