-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prometheus support in hermes tracker (#1690)
- Loading branch information
Showing
13 changed files
with
160 additions
and
96 deletions.
There are no files selected for viewing
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
68 changes: 68 additions & 0 deletions
68
...ommon/src/main/java/pl/allegro/tech/hermes/common/metric/TrackerElasticSearchMetrics.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package pl.allegro.tech.hermes.common.metric; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import pl.allegro.tech.hermes.metrics.HermesTimer; | ||
|
||
import java.util.function.ToDoubleFunction; | ||
|
||
import static pl.allegro.tech.hermes.metrics.PathsCompiler.HOSTNAME; | ||
|
||
public class TrackerElasticSearchMetrics { | ||
private final MeterRegistry meterRegistry; | ||
private final HermesMetrics hermesMetrics; | ||
|
||
public TrackerElasticSearchMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) { | ||
this.meterRegistry = meterRegistry; | ||
this.hermesMetrics = hermesMetrics; | ||
} | ||
|
||
public <T> void registerProducerTrackerElasticSearchQueueSizeGauge(T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerGauge(Gauges.Graphite.PRODUCER_TRACKER_ELASTICSEARCH_QUEUE_SIZE, () -> f.applyAsDouble(stateObj)); | ||
meterRegistry.gauge(Gauges.Prometheus.TRACKER_ELASTICSEARCH_QUEUE_SIZE, stateObj, f); | ||
} | ||
|
||
public <T> void registerProducerTrackerElasticSearchRemainingCapacity(T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerGauge(Gauges.Graphite.PRODUCER_TRACKER_ELASTICSEARCH_REMAINING_CAPACITY, () -> f.applyAsDouble(stateObj)); | ||
meterRegistry.gauge(Gauges.Prometheus.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY, stateObj, f); | ||
} | ||
|
||
public <T> void registerConsumerTrackerElasticSearchQueueSizeGauge(T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerGauge(Gauges.Graphite.CONSUMER_TRACKER_ELASTICSEARCH_QUEUE_SIZE, () -> f.applyAsDouble(stateObj)); | ||
meterRegistry.gauge(Gauges.Prometheus.TRACKER_ELASTICSEARCH_QUEUE_SIZE, stateObj, f); | ||
} | ||
|
||
public <T> void registerConsumerTrackerElasticSearchRemainingCapacity(T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerGauge(Gauges.Graphite.CONSUMER_TRACKER_ELASTICSEARCH_REMAINING_CAPACITY, () -> f.applyAsDouble(stateObj)); | ||
meterRegistry.gauge(Gauges.Prometheus.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY, stateObj, f); | ||
} | ||
|
||
public HermesTimer trackerElasticSearchCommitLatencyTimer() { | ||
return HermesTimer.from( | ||
meterRegistry.timer(Timers.ELASTICSEARCH_COMMIT_LATENCY), | ||
hermesMetrics.timer(Timers.ELASTICSEARCH_COMMIT_LATENCY) | ||
); | ||
} | ||
|
||
private static class Gauges { | ||
private static class Graphite { | ||
public static final String PRODUCER_TRACKER_ELASTICSEARCH_QUEUE_SIZE = | ||
"producer." + HOSTNAME + ".tracker.elasticsearch.queue-size"; | ||
public static final String PRODUCER_TRACKER_ELASTICSEARCH_REMAINING_CAPACITY = | ||
"producer." + HOSTNAME + ".tracker.elasticsearch.remaining-capacity"; | ||
|
||
public static final String CONSUMER_TRACKER_ELASTICSEARCH_QUEUE_SIZE = | ||
"consumer." + HOSTNAME + ".tracker.elasticsearch.queue-size"; | ||
public static final String CONSUMER_TRACKER_ELASTICSEARCH_REMAINING_CAPACITY = | ||
"consumer." + HOSTNAME + ".tracker.elasticsearch.remaining-capacity"; | ||
} | ||
|
||
private static class Prometheus { | ||
public static final String TRACKER_ELASTICSEARCH_QUEUE_SIZE = "tracker.elasticsearch.queue-size"; | ||
public static final String TRACKER_ELASTICSEARCH_REMAINING_CAPACITY = "tracker.elasticsearch.remaining-capacity"; | ||
} | ||
} | ||
|
||
private static class Timers { | ||
public static final String ELASTICSEARCH_COMMIT_LATENCY = "tracker.elasticsearch.commit-latency"; | ||
} | ||
} |
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
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
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
14 changes: 0 additions & 14 deletions
14
...sticsearch/src/main/java/pl/allegro/tech/hermes/tracker/elasticsearch/metrics/Gauges.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...sticsearch/src/main/java/pl/allegro/tech/hermes/tracker/elasticsearch/metrics/Timers.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.