Skip to content

Instantly share code, notes, and snippets.

@lmonkiewicz
Last active July 13, 2023 13:58
Show Gist options
  • Save lmonkiewicz/558bd31ae0d82a62ef50d9068b35f7b1 to your computer and use it in GitHub Desktop.
Save lmonkiewicz/558bd31ae0d82a62ef50d9068b35f7b1 to your computer and use it in GitHub Desktop.
metricOperations.increment(KafkaMetrics.METRIC_NAME,
Tags.of(KafkaTags.topic(topic),
KafkaTags.exception(exception.getClass().getName()),
KafkaTags.processor(context.applicationId())
));
@RequiredArgsConstructor
@Component
public class MetricOperations {
private final MeterRegistry meterRegistry;
public Counter counter(String metricName, Tags tags) {
return meterRegistry.counter(metricName, tags);
}
public void increment(String metricName, Tags tags) {
counter(metricName, tags).increment();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment