diff --git a/build.gradle b/build.gradle
index 00e4f013ae..88391a17f3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -49,26 +49,27 @@ allprojects {
project.ext.versions = [
kafka : '3.6.2',
- guava : '23.0',
- jackson : '2.15.2',
- jersey : '3.1.2',
- jetty : '12.0.7',
+ guava : '33.1.0-jre',
+ jackson : '2.17.0',
+ jersey : '3.1.6',
+ jetty : '12.0.8',
curator : '5.4.0',
- dropwizard_metrics: '4.1.0',
- micrometer_metrics: '1.11.1',
- wiremock : '3.3.1',
- spock : '2.4-M1-groovy-4.0',
- groovy : '4.0.12',
- avro : '1.9.1',
+ dropwizard_metrics: '4.2.25',
+ micrometer_metrics: '1.12.5',
+ wiremock : '3.5.2',
+ spock : '2.4-M4-groovy-4.0',
+ groovy : '4.0.21',
+ avro : '1.11.3',
json2avro : '0.2.14',
+ // TODO: newest version requires subject alternative name in a certificate during host verification, current test cert does not have a one
okhttp : '3.9.1',
- undertow : '2.0.29.Final',
- spring_web : '6.1.2',
- failsafe : '2.3.1',
- junit_jupiter : '5.9.1',
- testcontainers : '1.18.1',
- spring : '3.2.1',
- assertj : '3.24.2'
+ undertow : '2.3.12.Final',
+ spring_web : '6.1.6',
+ failsafe : '2.4.4',
+ junit_jupiter : '5.10.2',
+ testcontainers : '1.19.8',
+ spring : '3.2.4',
+ assertj : '3.25.3'
]
repositories {
@@ -77,15 +78,14 @@ allprojects {
dependencies {
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.4'
- implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
+ implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
testImplementation group: 'junit', name: 'junit', version: '4.11'
testImplementation group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.10.0'
testImplementation group: 'pl.pragmatists', name: 'JUnitParams', version: '1.0.2'
- testImplementation group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
+ testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.11.0'
testImplementation group: 'org.assertj', name: 'assertj-core', version: versions.assertj
- testImplementation group: 'com.jayway.awaitility', name: 'awaitility', version: '1.6.1'
- testImplementation group: 'com.googlecode.catch-exception', name: 'catch-exception', version: '1.2.0'
+ testImplementation group: 'org.awaitility', name: 'awaitility', version: '4.2.1'
annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: versions.spring
}
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index dc2d859510..9f07d83fc8 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -30,19 +30,6 @@ services:
- kafka_data:/var/lib/kafka/data
- kafka_secrets:/etc/kafka/secrets
- graphite:
- image: graphiteapp/graphite-statsd:1.1.3
- ports:
- - '2003-2004:2003-2004'
- - '2023-2024:2023-2024'
- - '8125:8125/udp'
- - '8126:8126'
- - '8082:80'
- volumes:
- - graphite_conf:/opt/graphite/conf
- - graphite_data:/opt/graphite/storage
- - statsd_data:/opt/statsd
-
frontend:
build:
context: ../
@@ -52,7 +39,6 @@ services:
depends_on:
- zk
- kafka
- - graphite
consumers:
build:
@@ -61,7 +47,6 @@ services:
depends_on:
- zk
- kafka
- - graphite
management:
build:
@@ -72,7 +57,6 @@ services:
depends_on:
- zk
- kafka
- - graphite
schema-registry:
image: "confluentinc/cp-schema-registry:${CONFLUENT_IMAGES_TAG}"
@@ -87,9 +71,6 @@ services:
- "8081:8081"
volumes:
- graphite_conf:
- graphite_data:
- statsd_data:
zk_secrets:
zk_data:
zk_log:
diff --git a/docker/latest/consumers/consumers.yaml b/docker/latest/consumers/consumers.yaml
index 76af83d9b5..f64008630f 100644
--- a/docker/latest/consumers/consumers.yaml
+++ b/docker/latest/consumers/consumers.yaml
@@ -8,11 +8,6 @@ consumer:
clusters:
- datacenter: "dc"
brokerList: "kafka:29092"
- graphite:
- host: "graphite"
- metrics:
- metric-registry:
- graphiteReporterEnabled: true
workload:
consumerPerSubscription: 1
schema:
diff --git a/docker/latest/frontend/frontend.yaml b/docker/latest/frontend/frontend.yaml
index 2ccd0f3432..0ba33ab769 100644
--- a/docker/latest/frontend/frontend.yaml
+++ b/docker/latest/frontend/frontend.yaml
@@ -8,11 +8,6 @@ frontend:
clusters:
- datacenter: "dc"
brokerList: "kafka:29092"
- graphite:
- host: "graphite"
- metrics:
- metric-registry:
- graphiteReporterEnabled: true
schema:
cache:
refreshAfterWrite: 1m
diff --git a/docker/latest/management/management.yaml b/docker/latest/management/management.yaml
index 0953e3660d..a678f65d33 100644
--- a/docker/latest/management/management.yaml
+++ b/docker/latest/management/management.yaml
@@ -17,11 +17,6 @@ kafka:
connectionTimeout: 3000
bootstrapKafkaServer: kafka:29092
-graphite:
- client:
- enabled: true
- externalMonitoringUrl: graphite:8082
-
server:
port: 8090
diff --git a/docs/docs/configuration/buffer-persistence.md b/docs/docs/configuration/buffer-persistence.md
index a4e3b9ca66..875776f508 100644
--- a/docs/docs/configuration/buffer-persistence.md
+++ b/docs/docs/configuration/buffer-persistence.md
@@ -1,4 +1,4 @@
-# Publishing buffer persistence
+# Publishing buffer persistence [deprecated]
Hermes Frontend API has option to register callbacks triggered during different phases of message lifetime:
@@ -15,7 +15,7 @@ to disk. Map structure is continuously persisted to disk, as it is stored in off
When Hermes Frontend starts up it scans filesystem in search of existing persisted map. If found, it is read and any
persisted events are sent to Message Store. This way recovering after crash is fully automatic. If Hermes process or
-server crashes, nothing is lost.
+server crashes, events that were flushed to disk are recovered.
There is additional protection against flooding subscribers with outdated events. When reading events from persisted
storage, Hermes filters out messages older than N hours, where N is a system parameter and is set to 3 days by default.
diff --git a/docs/docs/configuration/consumers-tuning.md b/docs/docs/configuration/consumers-tuning.md
index f4433b819f..904df5eede 100644
--- a/docs/docs/configuration/consumers-tuning.md
+++ b/docs/docs/configuration/consumers-tuning.md
@@ -2,18 +2,18 @@
## HTTP Sender
-Option | Description | Default value
----------------------------------------------------- | ----------------------------------------------------------- | -------------
-consumer.http-client.serial.http1.threadPoolSize | size of thread pool for sender threads (global) | 30
-consumer.http-client.serial.http1.maxConnectionsPerDestination | max connections per remote host | 100
+| Option | Description | Default value |
+|----------------------------------------------------------------|-------------------------------------------------|---------------|
+| consumer.http-client.serial.http1.threadPoolSize | size of thread pool for sender threads (global) | 30 |
+| consumer.http-client.serial.http1.maxConnectionsPerDestination | max connections per remote host | 100 |
## Consumers core
-Option | Description | Default value
------------------------------ | ------------------------------------------------------------------------ | -------------
-consumer.commit.offset.period | interval between committing offsets to Kafka | 60s
-consumer.threadPoolSize | thread pool for threads involved in consuming, 1 thread per subscription | 500
-consumer.serialConsumer.inflightSize | how many messages can be kept in send queue, per subscription | 100
+| Option | Description | Default value |
+|--------------------------------------|--------------------------------------------------------------------------|---------------|
+| consumer.commit.offset.period | interval between committing offsets to Kafka | 60s |
+| consumer.threadPoolSize | thread pool for threads involved in consuming, 1 thread per subscription | 500 |
+| consumer.serialConsumer.inflightSize | how many messages can be kept in send queue, per subscription | 100 |
## Workload constraints management
@@ -26,10 +26,10 @@ subscriptions assigned to itself.
These numbers can be configured:
-Option | Description | Default value
---------------------------------------------------- | ----------------------------------------- | ---------------------
-consumer.workload.consumersPerSubscription | Number of consumers to which the subscription will be assigned. If this value is greater than the number of available consumers, Hermes will assign the subscription to all available consumers. | 2
-consumer.workload.maxSubscriptionsPerConsumer | The maximum number of subscriptions assigned to a single consumer. If all consumers have the maximum number of subscriptions assigned, a new subscription will not be activated until a new consumer is added or another subscription is unassigned. | 200
+| Option | Description | Default value |
+|-----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
+| consumer.workload.consumersPerSubscription | Number of consumers to which the subscription will be assigned. If this value is greater than the number of available consumers, Hermes will assign the subscription to all available consumers. | 2 |
+| consumer.workload.maxSubscriptionsPerConsumer | The maximum number of subscriptions assigned to a single consumer. If all consumers have the maximum number of subscriptions assigned, a new subscription will not be activated until a new consumer is added or another subscription is unassigned. | 200 |
Additionally, Hermes allows to configure the property `consumer.workload.consumersPerSubscription` for specific
topics or subscriptions in the runtime via REST API.
diff --git a/docs/docs/overview/architecture.md b/docs/docs/overview/architecture.md
index 7726745068..6d647e64d2 100644
--- a/docs/docs/overview/architecture.md
+++ b/docs/docs/overview/architecture.md
@@ -16,7 +16,7 @@ Hermes integrates with multiple systems, each having different role.
* **Message Store** - stores and routes messages, current implementation: Kafka
* **Metadata Store** - shared metadata storage for all Hermes modules, current implementation: Zookeeper
-* **Metrics Store** *[optional]* - stores metrics gathered by Hermes, current implementation: Graphite
+* **Metrics Store** *[optional]* - stores metrics gathered by Hermes, currently Hermes exposes metrics in Prometheus format
* **Tracking Store** *[optional]* - stores tracking (message trace) information, current implementation: ElasticSearch
## Message flow
diff --git a/docs/docs/quickstart.md b/docs/docs/quickstart.md
index c31db5a01a..3ad00ea47b 100644
--- a/docs/docs/quickstart.md
+++ b/docs/docs/quickstart.md
@@ -56,7 +56,7 @@ image: allegro/hermes-management:hermes-[specific version tag]
## Development
The default `docker-compose` setup will start all hermes modules (consumers, frontend, management), together
-with its dependencies (Kafka, ZooKeeper, Graphite, Schema Registry). To run a specific module with gradle/IntelliJ,
+with its dependencies (Kafka, ZooKeeper, Schema Registry). To run a specific module with gradle/IntelliJ,
just comment out the module in `services` section of the `docker-compose.yml` file, and start the java process locally:
`./gradlew -p hermes-frontend run`
@@ -175,7 +175,6 @@ management:
depends_on:
- zk
- kafka
- - graphite
[...]
```
diff --git a/docs/docs/user/java-client.md b/docs/docs/user/java-client.md
index 57e78b766b..942c9675a7 100644
--- a/docs/docs/user/java-client.md
+++ b/docs/docs/user/java-client.md
@@ -19,7 +19,7 @@ At the moment there are four implementations of `HermesSender`:
for asynchronous transmission
* **WebClientHermesSender** - for services using [Spring WebFlux](https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html);
uses [WebClient](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/reactive/function/client/WebClient.html)
-* **JerseyHermesSender** - recommended for services using [Jersey]()
+* **JerseyHermesSender** - recommended for services using [Jersey]()
* **OkHttpHermesSender** - supports both HTTP/1.1 and HTTP/2 protocols, uses [OkHttp3 client](http://square.github.io/okhttp/)
diff --git a/docs/docs/user/publishing.md b/docs/docs/user/publishing.md
index 034d2ce623..4889a49fcb 100644
--- a/docs/docs/user/publishing.md
+++ b/docs/docs/user/publishing.md
@@ -134,22 +134,21 @@ Failure statuses:
Each topic can define level of acknowledgement (ACK):
* leader ACK - only one Kafka node (leader) needs to acknowledge reception of message
-* all ACK - all nodes that hold copy of message need to acknowledge reception of message
+* all ACK - at least [min.insync.replicas](https://kafka.apache.org/documentation/#brokerconfigs_min.insync.replicas) nodes must acknowledge reception of message
-For most of the topic leader ACK is enough. This guarantees roughly 99.999..% reception rate. Only in rare cases, during
-Kafka cluster rebalancing or nodes outage Kafka might confirm that message was received, while it was not saved and it
-will be lost.
+ACK configuration has the following consequences:
-What does it mean in practice? Numbers differ per case and they are affected by multiple factors like frequency of
-rebalancing taking place on Kafka clusters, Kafka version etc. In our production environment using ACK leader means we falsely
-believe message was received by Kafka once per 20 million events. This is a very rough estimate that should show you
-the scale, if you need numbers to base your decision on - please conduct own measurements.
+- with `ACK leader` message writes are replicated asynchronously, thus the acknowledgment latency will be low. However, message write may be lost
+when there is a topic leadership change - e.g. due to rebalance or broker restart.
+- with `ACK all` messages writes are synchronously replicated to replicas. Write acknowledgement latency will be much higher than with leader ACK,
+it will also have higher variance due to tail latency. However, messages will be persisted as long as the whole replica set does not go down simultaneously.
-If you need 100% guarantee that message was saved, force all replicas to send ACK. The downside of this is much longer
-response times, they tend to vary a lot as well. Thanks to Hermes buffering (described in paragraphs below), we are able
-to guarantee some sane response times to our clients even in *ACK all* mode.
+Publishers are advised to select topic ACK level based on their latency and durability requirements.
-## Buffering
+Hermes also provides a feature called Buffering (described in paragraphs below) which provides consistent write latency
+despite long Kafka response times. Note that, however, this mode may decrease message durability for `ACK all` setting.
+
+## Buffering [deprecated]
Hermes administrator can set maximum time, for which Hermes will wait for Kafka acknowledgment. By default, it is set to
65ms. After that time, **202** response is sent to client. Event is kept in Kafka producer buffer and it's delivery will
@@ -161,7 +160,7 @@ Kafka is back online.
### Buffer persistence
-By default events are buffered in memory only. This raises the question about what happens in case of Hermes node failure
+By default, events are buffered in memory only. This raises the question about what happens in case of Hermes node failure
(or force kill of process). Hermes Frontend API exposes callbacks that can be used to implement persistence model of
buffered events.
@@ -169,6 +168,46 @@ Default implementation uses [OpenHFT ChronicleMap](https://github.com/OpenHFT/Ch
to disk. Map structure is continuously persisted to disk, as it is stored in offheap memory as
[memory mapped file](https://en.wikipedia.org/wiki/Memory-mapped_file).
+Using buffering with ACK all setting means that durability of events may be lowered when **202** status code is received. If Hermes instance
+is killed before message is spilled to disk or the data on disk becomes corrupted, the message is gone. Thus `ACK all` with **202** status code
+is similar to `ACK leader` because a single node failure could cause the message be lost.
+
+### Deprecation notice
+The buffering mechanism in Hermes is considered deprecated and is set to be removed in the future.
+
+## Remote DC fallback
+
+Hermes supports a remote datacenter fallback mechanism for [multi datacenter deployments](https://hermes-pubsub.readthedocs.io/en/latest/configuration/kafka-and-zookeeper/#multiple-kafka-and-zookeeper-clusters).
+
+Fallback is configured on per topic basis, using a `fallbackToRemoteDatacenterEnabled` property:
+
+```http request
+PUT /topics/my.group.my-topic
+
+{
+ "fallbackToRemoteDatacenterEnabled": true,
+}
+```
+
+Using this setting automatically disables buffering mechanism for a topic.
+
+When using this setting for a topic, Hermes will try to send a message to a local datacenter Kafka first and will fall back to remote datacenter Kafka
+if the local send fails.
+
+Hermes also provides a speculative fallback mechanism which will send messages to remote Kafka if the local Kafka is not responding in a timely manner.
+Speculative send is performed after `frontend.kafka.fail-fast-producer.speculativeSendDelay` elapses.
+
+When using remote DC fallback, Hermes attempts to send a message to Kafka for the duration of `frontend.handlers.maxPublishRequestDuration` property. If after
+`maxPublishRequestDuration` Hermes has not received an acknowledgment from Kafka, it will respond with **500** status code to the client.
+
+Table below summarizes remote fallback configuration options:
+
+| Option | Scope | Default value |
+|--------------------------------------------------------|--------|---------------|
+| fallbackToRemoteDatacenterEnabled | topic | false |
+| frontend.kafka.fail-fast-producer.speculativeSendDelay | global | 250ms |
+| frontend.handlers.maxPublishRequestDuration | global | 500ms |
+
## Partition assignment
`Partition-Key` header can be used by publishers to specify Kafka `key` which will be used for partition assignment for a message. This will ensure
that all messages with given `Partition-Key` will be sent to the same Kafka partition.
diff --git a/hermes-api/build.gradle b/hermes-api/build.gradle
index c6554f612b..54c06d0400 100644
--- a/hermes-api/build.gradle
+++ b/hermes-api/build.gradle
@@ -4,19 +4,19 @@ plugins {
}
dependencies {
- api group: 'org.hibernate.validator', name: 'hibernate-validator', version: '8.0.0.Final'
+ api group: 'org.hibernate.validator', name: 'hibernate-validator', version: '8.0.1.Final'
api group: 'jakarta.ws.rs', name: 'jakarta.ws.rs-api', version: '3.1.0'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: versions.jackson
api group: 'com.fasterxml.jackson.jakarta.rs', name: 'jackson-jakarta-rs-json-provider', version: versions.jackson
api group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: versions.jackson
implementation group: 'com.google.guava', name: 'guava', version: versions.guava
- api group: 'com.damnhandy', name: 'handy-uri-templates', version: '2.0.2'
+ api group: 'com.damnhandy', name: 'handy-uri-templates', version: '2.1.8'
api group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '4.0.0'
- implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '4.0.3'
- implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '4.0.3'
- implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '2.1.1'
+ implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '4.0.5'
+ implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '4.0.5'
+ implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '3.0.0'
testImplementation group: 'org.spockframework', name: 'spock-core', version: versions.spock
diff --git a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Subscription.java b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Subscription.java
index 3a8c673590..14849437df 100644
--- a/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Subscription.java
+++ b/hermes-api/src/main/java/pl/allegro/tech/hermes/api/Subscription.java
@@ -52,6 +52,8 @@ public class Subscription implements Anonymizable {
private boolean trackingEnabled = false;
private TrackingMode trackingMode = TrackingMode.TRACKING_OFF;
private boolean http2Enabled = false;
+ private boolean profilingEnabled = false;
+ private long profilingThresholdMs = 0;
@Valid
@NotNull
private OwnerId owner;
@@ -94,6 +96,8 @@ private Subscription(TopicName topicName,
EndpointAddressResolverMetadata endpointAddressResolverMetadata,
SubscriptionOAuthPolicy oAuthPolicy,
boolean http2Enabled,
+ boolean profilingEnabled,
+ long profilingThresholdMs,
boolean subscriptionIdentityHeadersEnabled,
boolean autoDeleteWithTopicEnabled) {
this.topicName = topicName;
@@ -112,6 +116,8 @@ private Subscription(TopicName topicName,
this.filters = filters;
this.mode = mode;
this.http2Enabled = http2Enabled;
+ this.profilingEnabled = profilingEnabled;
+ this.profilingThresholdMs = profilingThresholdMs;
this.subscriptionName = new SubscriptionName(name, topicName);
this.headers = headers;
this.endpointAddressResolverMetadata = endpointAddressResolverMetadata;
@@ -137,11 +143,13 @@ public static Subscription createSerialSubscription(TopicName topicName,
EndpointAddressResolverMetadata endpointAddressResolverMetadata,
SubscriptionOAuthPolicy oAuthPolicy,
boolean http2Enabled,
+ boolean profilingEnabled,
+ long profilingThresholdMs,
boolean subscriptionIdentityHeadersEnabled,
boolean autoDeleteWithTopicEnabled) {
return new Subscription(topicName, name, endpoint, state, description, subscriptionPolicy, trackingEnabled, trackingMode,
owner, monitoringDetails, contentType, DeliveryType.SERIAL, filters, mode, headers,
- endpointAddressResolverMetadata, oAuthPolicy, http2Enabled, subscriptionIdentityHeadersEnabled, autoDeleteWithTopicEnabled);
+ endpointAddressResolverMetadata, oAuthPolicy, http2Enabled, profilingEnabled, profilingThresholdMs, subscriptionIdentityHeadersEnabled, autoDeleteWithTopicEnabled);
}
public static Subscription createBatchSubscription(TopicName topicName,
@@ -164,7 +172,7 @@ public static Subscription createBatchSubscription(TopicName topicName,
boolean autoDeleteWithTopicEnabled) {
return new Subscription(topicName, name, endpoint, state, description, subscriptionPolicy, trackingEnabled, trackingMode,
owner, monitoringDetails, contentType, DeliveryType.BATCH, filters, SubscriptionMode.ANYCAST, headers,
- endpointAddressResolverMetadata, oAuthPolicy, http2Enabled, subscriptionIdentityHeadersEnabled, autoDeleteWithTopicEnabled);
+ endpointAddressResolverMetadata, oAuthPolicy, http2Enabled, false, 0, subscriptionIdentityHeadersEnabled, autoDeleteWithTopicEnabled);
}
@JsonCreator
@@ -187,6 +195,8 @@ public static Subscription create(
@JsonProperty("endpointAddressResolverMetadata") EndpointAddressResolverMetadata endpointAddressResolverMetadata,
@JsonProperty("oAuthPolicy") SubscriptionOAuthPolicy oAuthPolicy,
@JsonProperty("http2Enabled") boolean http2Enabled,
+ @JsonProperty("profilingEnabled") boolean profilingEnabled,
+ @JsonProperty("profilingThresholdMs") long profilingThresholdMs,
@JsonProperty("subscriptionIdentityHeadersEnabled") boolean subscriptionIdentityHeadersEnabled,
@JsonProperty("autoDeleteWithTopicEnabled") boolean autoDeleteWithTopicEnabled) {
@@ -219,6 +229,8 @@ public static Subscription create(
endpointAddressResolverMetadata == null ? EndpointAddressResolverMetadata.empty() : endpointAddressResolverMetadata,
oAuthPolicy,
http2Enabled,
+ profilingEnabled,
+ profilingThresholdMs,
subscriptionIdentityHeadersEnabled,
autoDeleteWithTopicEnabled
);
@@ -257,6 +269,8 @@ public boolean equals(Object obj) {
&& Objects.equals(this.headers, other.headers)
&& Objects.equals(this.endpointAddressResolverMetadata, other.endpointAddressResolverMetadata)
&& Objects.equals(this.http2Enabled, other.http2Enabled)
+ && Objects.equals(this.profilingEnabled, other.profilingEnabled)
+ && Objects.equals(this.profilingThresholdMs, other.profilingThresholdMs)
&& Objects.equals(this.oAuthPolicy, other.oAuthPolicy)
&& Objects.equals(this.subscriptionIdentityHeadersEnabled, other.subscriptionIdentityHeadersEnabled)
&& Objects.equals(this.autoDeleteWithTopicEnabled, other.autoDeleteWithTopicEnabled);
@@ -391,6 +405,14 @@ public boolean isHttp2Enabled() {
return http2Enabled;
}
+ public boolean isProfilingEnabled() {
+ return profilingEnabled;
+ }
+
+ public long getProfilingThresholdMs() {
+ return profilingThresholdMs;
+ }
+
public boolean isSubscriptionIdentityHeadersEnabled() {
return subscriptionIdentityHeadersEnabled;
}
@@ -437,6 +459,8 @@ public Subscription anonymize() {
endpointAddressResolverMetadata,
oAuthPolicy != null ? oAuthPolicy.anonymize() : null,
http2Enabled,
+ profilingEnabled,
+ profilingThresholdMs,
subscriptionIdentityHeadersEnabled,
autoDeleteWithTopicEnabled
);
diff --git a/hermes-benchmark/build.gradle b/hermes-benchmark/build.gradle
index abd76e7967..6262b38a8a 100644
--- a/hermes-benchmark/build.gradle
+++ b/hermes-benchmark/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id 'me.champeau.jmh' version '0.6.8'
+ id 'me.champeau.jmh' version '0.7.2'
}
configurations {
@@ -26,10 +26,9 @@ jmh {
}
dependencies {
- jmh group: 'org.openjdk.jmh', name: 'jmh-core', version: '1.12'
- jmh group: 'org.openjdk.jmh', name: 'jmh-generator-annprocess', version: '1.12'
- jmh group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.1'
- jmh group: 'org.spf4j', name: 'spf4j-jmh', version: '8.0.3'
+ jmh group: 'org.openjdk.jmh', name: 'jmh-core', version: '1.37'
+ jmh group: 'org.openjdk.jmh', name: 'jmh-generator-annprocess', version: '1.37'
+ jmh group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.5'
jmh project(':hermes-frontend')
jmh project(':hermes-test-helper')
jmh project(':hermes-common')
diff --git a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesPublisher.java b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesPublisher.java
index 610eafea81..65d758873d 100644
--- a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesPublisher.java
+++ b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesPublisher.java
@@ -1,6 +1,5 @@
package pl.allegro.tech.hermes.benchmark.environment;
-import com.codahale.metrics.MetricRegistry;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.CookieSpecs;
@@ -28,14 +27,12 @@ public class HermesPublisher {
private static final Logger logger = LoggerFactory.getLogger(HermesPublisher.class);
private final CloseableHttpAsyncClient httpClient;
- private final MetricRegistry metricRegistry;
private final URI targetUrl;
private final HttpEntity body;
- public HermesPublisher(int maxConnectionsPerRoute, String targetUrl, String body, MetricRegistry metricRegistry)
+ public HermesPublisher(int maxConnectionsPerRoute, String targetUrl, String body)
throws IOReactorException, UnsupportedEncodingException {
this.targetUrl = URI.create(targetUrl);
- this.metricRegistry = metricRegistry;
RequestConfig requestConfig = RequestConfig.custom()
.setCookieSpec(CookieSpecs.IGNORE_COOKIES)
@@ -71,9 +68,7 @@ public int publish() {
try {
Future future = httpClient.execute(httpPost, null);
response = future.get().getStatusLine().getStatusCode();
- metricRegistry.counter("response." + response).inc();
} catch (RuntimeException | InterruptedException | ExecutionException exception) {
- metricRegistry.counter("client.exceptions").inc();
logger.error("Client exception", exception);
}
return response;
diff --git a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerEnvironment.java b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerEnvironment.java
index 52aece4222..2f987a610f 100644
--- a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerEnvironment.java
+++ b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerEnvironment.java
@@ -1,6 +1,5 @@
package pl.allegro.tech.hermes.benchmark.environment;
-import com.codahale.metrics.MetricRegistry;
import org.apache.commons.io.IOUtils;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Scope;
@@ -23,7 +22,6 @@ public class HermesServerEnvironment {
public static final String BENCHMARK_TOPIC = "bench.topic";
private HermesPublisher publisher;
- private MetricRegistry metricRegistry;
private HermesServer hermesServer;
@@ -39,10 +37,9 @@ public void setupEnvironment() throws Exception {
@Setup(Level.Trial)
public void setupPublisher() throws Exception {
- metricRegistry = new MetricRegistry();
String messageBody = loadMessageResource("completeMessage");
- publisher = new HermesPublisher(MAX_CONNECTIONS_PER_ROUTE, "http://localhost:8080/topics/" + BENCHMARK_TOPIC, messageBody, metricRegistry);
+ publisher = new HermesPublisher(MAX_CONNECTIONS_PER_ROUTE, "http://localhost:8080/topics/" + BENCHMARK_TOPIC, messageBody);
}
@TearDown(Level.Trial)
@@ -52,7 +49,6 @@ public void shutdownServers() throws Exception {
@TearDown(Level.Trial)
public void shutdownPublisherAndReportMetrics() throws Exception {
- reportMetrics();
publisher.stop();
}
@@ -65,7 +61,4 @@ public static String loadMessageResource(String name) throws IOException {
.getResourceAsStream(String.format("/message/%s.json", name))));
}
- private void reportMetrics() {
- metricRegistry.getCounters().forEach((key, value) -> logger.info(key + ": " + value.getCount()));
- }
}
diff --git a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerFactory.java b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerFactory.java
index c47b324f7b..47c5dbca6f 100644
--- a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerFactory.java
+++ b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/HermesServerFactory.java
@@ -1,12 +1,10 @@
package pl.allegro.tech.hermes.benchmark.environment;
-import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.undertow.server.HttpHandler;
import pl.allegro.tech.hermes.api.Topic;
import pl.allegro.tech.hermes.common.message.wrapper.AvroMessageContentWrapper;
-import pl.allegro.tech.hermes.common.metric.HermesMetrics;
import pl.allegro.tech.hermes.common.metric.MetricsFacade;
import pl.allegro.tech.hermes.frontend.cache.topic.TopicsCache;
import pl.allegro.tech.hermes.frontend.config.HTTPHeadersProperties;
@@ -28,7 +26,6 @@
import pl.allegro.tech.hermes.frontend.readiness.HealthCheckService;
import pl.allegro.tech.hermes.frontend.server.HermesServer;
import pl.allegro.tech.hermes.frontend.validator.MessageValidators;
-import pl.allegro.tech.hermes.metrics.PathsCompiler;
import pl.allegro.tech.hermes.schema.DirectCompiledSchemaRepository;
import pl.allegro.tech.hermes.schema.DirectSchemaVersionsRepository;
import pl.allegro.tech.hermes.schema.RawSchemaClient;
@@ -52,8 +49,7 @@ class HermesServerFactory {
static HermesServer provideHermesServer() throws IOException {
ThroughputLimiter throughputLimiter = (exampleTopic, throughput) -> quotaConfirmed();
- HermesMetrics hermesMetrics = new HermesMetrics(new MetricRegistry(), new PathsCompiler(""));
- MetricsFacade metricsFacade = new MetricsFacade(new SimpleMeterRegistry(), hermesMetrics);
+ MetricsFacade metricsFacade = new MetricsFacade(new SimpleMeterRegistry());
TopicsCache topicsCache = new InMemoryTopicsCache(metricsFacade, topic);
BrokerMessageProducer brokerMessageProducer = new InMemoryBrokerMessageProducer();
RawSchemaClient rawSchemaClient = new InMemorySchemaClient(topic.getName(), loadMessageResource("schema"), 1, 1);
diff --git a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/InMemoryTopicsCache.java b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/InMemoryTopicsCache.java
index d673c51187..d7425b67d5 100644
--- a/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/InMemoryTopicsCache.java
+++ b/hermes-benchmark/src/jmh/java/pl/allegro/tech/hermes/benchmark/environment/InMemoryTopicsCache.java
@@ -1,13 +1,14 @@
package pl.allegro.tech.hermes.benchmark.environment;
+import com.codahale.metrics.MetricRegistry;
import pl.allegro.tech.hermes.api.Topic;
import pl.allegro.tech.hermes.common.kafka.KafkaTopic;
import pl.allegro.tech.hermes.common.kafka.KafkaTopicName;
import pl.allegro.tech.hermes.common.kafka.KafkaTopics;
-import pl.allegro.tech.hermes.common.metric.HermesMetrics;
import pl.allegro.tech.hermes.common.metric.MetricsFacade;
import pl.allegro.tech.hermes.frontend.cache.topic.TopicsCache;
import pl.allegro.tech.hermes.frontend.metric.CachedTopic;
+import pl.allegro.tech.hermes.frontend.metric.ThroughputRegistry;
import java.util.List;
import java.util.Optional;
@@ -17,12 +18,14 @@ class InMemoryTopicsCache implements TopicsCache {
private final MetricsFacade metricsFacade;
private final KafkaTopics kafkaTopics;
private final Topic topic;
+ private final ThroughputRegistry throughputRegistry;
InMemoryTopicsCache(MetricsFacade metricsFacade, Topic topic) {
this.metricsFacade = metricsFacade;
this.topic = topic;
this.kafkaTopics = new KafkaTopics(new KafkaTopic(KafkaTopicName.valueOf(topic.getQualifiedName()), topic.getContentType()));
+ this.throughputRegistry = new ThroughputRegistry(metricsFacade, new MetricRegistry());
}
@Override
@@ -32,6 +35,7 @@ public Optional getTopic(String qualifiedTopicName) {
new CachedTopic(
topic,
metricsFacade,
+ throughputRegistry,
kafkaTopics
)
);
diff --git a/hermes-client/build.gradle b/hermes-client/build.gradle
index c8dd30dfe6..8e2fa2c039 100644
--- a/hermes-client/build.gradle
+++ b/hermes-client/build.gradle
@@ -3,7 +3,6 @@ plugins {
}
dependencies {
- compileOnly group: 'io.dropwizard.metrics', name: 'metrics-core', version: versions.dropwizard_metrics
compileOnly group: 'io.micrometer', name: 'micrometer-core', version: versions.micrometer_metrics
compileOnly group: 'org.glassfish.jersey.core', name: 'jersey-client', version: versions.jersey
compileOnly group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: versions.jersey
@@ -12,15 +11,14 @@ dependencies {
compileOnly group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp
implementation group: 'net.jodah', name: 'failsafe', version: versions.failsafe
- api group: 'io.projectreactor', name: 'reactor-core', version: '3.4.25'
+ api group: 'io.projectreactor', name: 'reactor-core', version: '3.6.5'
testImplementation group: 'org.spockframework', name: 'spock-core', version: versions.spock
testImplementation group: 'org.spockframework', name: 'spock-junit4', version: versions.spock
testImplementation group: 'org.wiremock', name: 'wiremock-standalone', version: versions.wiremock
- testImplementation group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
- testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.5.0'
+ testImplementation group: 'jakarta.servlet', name: 'jakarta.servlet-api', version: '6.0.0'
+ testImplementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.9.0'
- testImplementation group: 'io.dropwizard.metrics', name: 'metrics-core', version: versions.dropwizard_metrics
testImplementation group: 'io.micrometer', name: 'micrometer-core', version: versions.micrometer_metrics
testImplementation group: 'org.glassfish.jersey.core', name: 'jersey-client', version: versions.jersey
testImplementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: versions.jersey
@@ -28,6 +26,6 @@ dependencies {
testImplementation group: 'org.springframework', name: 'spring-context', version: versions.spring_web
testImplementation group: 'org.springframework', name: 'spring-webflux', version: versions.spring_web
testImplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: versions.okhttp
- testImplementation group: 'io.projectreactor.netty', name: 'reactor-netty', version: '1.0.25'
- testImplementation group: 'io.projectreactor', name: 'reactor-test', version: '3.4.25'
+ testImplementation group: 'io.projectreactor.netty', name: 'reactor-netty', version: '1.1.18'
+ testImplementation group: 'io.projectreactor', name: 'reactor-test', version: '3.6.5'
}
diff --git a/hermes-client/src/main/java/pl/allegro/tech/hermes/client/metrics/DropwizardMetricsProvider.java b/hermes-client/src/main/java/pl/allegro/tech/hermes/client/metrics/DropwizardMetricsProvider.java
deleted file mode 100644
index ded184d90e..0000000000
--- a/hermes-client/src/main/java/pl/allegro/tech/hermes/client/metrics/DropwizardMetricsProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package pl.allegro.tech.hermes.client.metrics;
-
-import com.codahale.metrics.MetricRegistry;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-public class DropwizardMetricsProvider implements MetricsProvider {
-
- private final MetricRegistry metrics;
-
-
- public DropwizardMetricsProvider(MetricRegistry metrics) {
- this.metrics = metrics;
- }
-
- @Override
- public void counterIncrement(String topic, String key) {
- metrics.counter(prefix + topic + "." + key).inc();
- }
-
- @Override
- public void counterIncrement(String topic, String key, Map tags) {
- counterIncrement(topic, buildCounterName(key, tags));
- }
-
- @Override
- public void timerRecord(String topic, String key, long duration, TimeUnit unit) {
- metrics.timer(prefix + topic + "." + key).update(duration, unit);
- }
-
- @Override
- public void histogramUpdate(String topic, String key, int value) {
- metrics.histogram(prefix + topic + "." + key).update(value);
- }
-
- private String buildCounterName(String key, Map tags) {
- return key + "." + String.join(".", tags.values());
- }
-}
diff --git a/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMetricsTest.groovy b/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMetricsTest.groovy
deleted file mode 100644
index c608c1c5cc..0000000000
--- a/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMetricsTest.groovy
+++ /dev/null
@@ -1,207 +0,0 @@
-package pl.allegro.tech.hermes.client
-
-import com.codahale.metrics.MetricRegistry
-import pl.allegro.tech.hermes.client.metrics.DropwizardMetricsProvider
-import pl.allegro.tech.hermes.client.metrics.MetricsProvider
-import spock.lang.Specification
-
-import java.time.Duration
-import java.time.temporal.ChronoUnit
-import java.util.concurrent.CompletableFuture
-
-import static java.util.concurrent.CompletableFuture.completedFuture
-import static pl.allegro.tech.hermes.client.HermesClientBuilder.hermesClient
-
-class HermesClientMetricsTest extends Specification {
-
- private MetricRegistry metrics = new MetricRegistry()
- private MetricsProvider metricsProvider = new DropwizardMetricsProvider(metrics)
-
- def "should measure publish latency"() {
- given:
- HermesClient client = hermesClient(delayedHermesSender(Duration.ofMillis(100)))
- .withRetrySleep(0)
- .withMetrics(metricsProvider).build()
-
- when:
- client.publish("com.group.topic", "123").join()
-
- then:
- metrics.counter("hermes-client.com_group.topic.status.201").count == 1
- metrics.timer("hermes-client.com_group.topic.latency").getSnapshot().getMax() >= Duration.ofMillis(100).get(ChronoUnit.NANOS)
- }
-
- def "should close timer on exceptional completion and log failure metric"() {
- given:
- HermesClient client = hermesClient({uri, msg -> failingFuture(new RuntimeException())})
- .withRetrySleep(0)
- .withRetries(3)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client.publish("com.group.topic", "123").join() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.failure").count == 4
- metrics.timers.containsKey("hermes-client.com_group.topic.latency")
-
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 4
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 3
- }
-
- def "should update max retries exceeded metric"() {
- given:
- HermesClient client = hermesClient({uri, msg -> failingFuture(new RuntimeException())})
- .withRetrySleep(0)
- .withRetries(3)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client.publish("com.group.topic", "123").join() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.failure").count == 4
- metrics.counter("hermes-client.com_group.topic.retries.count").count == 3
- metrics.counter("hermes-client.com_group.topic.retries.exhausted").count == 1
- metrics.counter("hermes-client.com_group.topic.retries.success").count == 0
- metrics.histogram("hermes-client.com_group.topic.retries.attempts").getSnapshot().size() == 0
- metrics.timers.containsKey("hermes-client.com_group.topic.latency")
-
- metrics.counter("hermes-client.com_group.topic.publish.finally.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 4
- metrics.counter("hermes-client.com_group.topic.publish.attempt").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.retry.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.retry.attempt").count == 1
- }
-
- def "should update retries metrics"() {
- given:
- HermesClient client1 = hermesClient(failingHermesSender(2))
- .withRetrySleep(0)
- .withRetries(4)
- .withMetrics(metricsProvider).build()
-
- HermesClient client2 = hermesClient(failingHermesSender(5))
- .withRetrySleep(0)
- .withRetries(6)
- .withMetrics(metricsProvider).build()
-
- HermesClient client3 = hermesClient(failingHermesSender(3))
- .withRetrySleep(0)
- .withRetries(2)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client1.publish("com.group.topic", "123").join() })
- silence({ client2.publish("com.group.topic", "456").join() })
- silence({ client3.publish("com.group.topic", "789").join() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.failure").count == 10
- metrics.counter("hermes-client.com_group.topic.retries.exhausted").count == 1
- metrics.counter("hermes-client.com_group.topic.retries.success").count == 2
- metrics.counter("hermes-client.com_group.topic.retries.count").count == 9
- metrics.histogram("hermes-client.com_group.topic.retries.attempts").getSnapshot().getMin() == 2
- metrics.histogram("hermes-client.com_group.topic.retries.attempts").getSnapshot().getMax() == 5
- metrics.timers.containsKey("hermes-client.com_group.topic.latency")
-
- metrics.counter("hermes-client.com_group.topic.publish.finally.success").count == 2
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 10
- metrics.counter("hermes-client.com_group.topic.publish.attempt").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.retry.success").count == 2
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 9
- metrics.counter("hermes-client.com_group.topic.publish.retry.attempt").count == 3
- }
-
- def "should update failure metrics when there is an application-level error"() {
- given:
- HermesClient client1 = hermesClient(badRequestHermesSender())
- .withRetrySleep(0)
- .withRetries(4)
- .withMetrics(metricsProvider).build()
-
- HermesClient client2 = hermesClient(badRequestHermesSender())
- .withRetrySleep(0)
- .withRetries(6)
- .withMetrics(metricsProvider).build()
-
- HermesClient client3 = hermesClient(badRequestHermesSender())
- .withRetrySleep(0)
- .withRetries(2)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client1.publish("com.group.topic", "123").join() })
- silence({ client2.publish("com.group.topic", "456").join() })
- silence({ client3.publish("com.group.topic", "789").join() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.publish.finally.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.attempt").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.retry.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.retry.attempt").count == 0
- }
-
- private CompletableFuture successFuture(HermesMessage message) {
- return completedFuture(HermesResponseBuilder.hermesResponse(message).withHttpStatus(201).build())
- }
-
- private CompletableFuture badRequestFuture(HermesMessage message) {
- return completedFuture(HermesResponseBuilder.hermesResponse(message).withHttpStatus(400).build())
- }
-
- private CompletableFuture failingFuture(Throwable throwable) {
- CompletableFuture future = new CompletableFuture<>()
- future.completeExceptionally(throwable)
- return future
- }
-
- private HermesSender failingHermesSender(int errorNo) {
- new HermesSender() {
- int i = 0
- @Override
- CompletableFuture send(URI uri, HermesMessage message) {
- i++
- if (i <= errorNo) {
- return failingFuture(new RuntimeException())
- }
- return successFuture(message)
- }
- }
- }
-
- private HermesSender delayedHermesSender(Duration sendLatencyMs) {
- new HermesSender() {
- @Override
- CompletableFuture send(URI uri, HermesMessage message) {
- Thread.sleep(sendLatencyMs.toMillis())
- return successFuture(message)
- }
- }
- }
-
- private HermesSender badRequestHermesSender() {
- new HermesSender() {
- @Override
- CompletableFuture send(URI uri, HermesMessage message) {
- return badRequestFuture(message)
- }
- }
- }
-
- private void silence(Runnable runnable) {
- try {
- runnable.run()
- } catch (Exception ex) {
- // do nothing
- }
- }
-
-}
diff --git a/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMicrometerTaggedMetricsTest.groovy b/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMicrometerTaggedMetricsTest.groovy
index d7175066ec..05b760eea9 100644
--- a/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMicrometerTaggedMetricsTest.groovy
+++ b/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/HermesClientMicrometerTaggedMetricsTest.groovy
@@ -7,7 +7,6 @@ import pl.allegro.tech.hermes.client.metrics.MicrometerTaggedMetricsProvider
import spock.lang.Specification
import java.time.Duration
-import java.time.temporal.ChronoUnit
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit
@@ -31,8 +30,8 @@ class HermesClientMicrometerTaggedMetricsTest extends Specification {
then:
metrics.counter("hermes-client.status", "code", String.valueOf(201), "topic", "com_group.topic").count() == 1
def timer = metrics.timer("hermes-client.latency", "topic", "com_group.topic")
- timer.totalTime(TimeUnit.NANOSECONDS) >= Duration.ofMillis(100).get(ChronoUnit.NANOS)
- timer.totalTime(TimeUnit.NANOSECONDS) < Duration.ofMillis(300).get(ChronoUnit.NANOS)
+ timer.totalTime(TimeUnit.NANOSECONDS) >= Duration.ofMillis(100).toNanos()
+ timer.totalTime(TimeUnit.NANOSECONDS) < Duration.ofMillis(1000).toNanos()
}
def "should close timer on exceptional completion and log failure metric"() {
diff --git a/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/ReactiveHermesClientMetricsTest.groovy b/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/ReactiveHermesClientMetricsTest.groovy
deleted file mode 100644
index c1993857dd..0000000000
--- a/hermes-client/src/test/groovy/pl/allegro/tech/hermes/client/ReactiveHermesClientMetricsTest.groovy
+++ /dev/null
@@ -1,205 +0,0 @@
-package pl.allegro.tech.hermes.client
-
-import com.codahale.metrics.MetricRegistry
-import pl.allegro.tech.hermes.client.metrics.DropwizardMetricsProvider
-import pl.allegro.tech.hermes.client.metrics.MetricsProvider
-import reactor.core.publisher.Mono
-import spock.lang.Specification
-
-import java.time.Duration
-import java.time.temporal.ChronoUnit
-
-import static pl.allegro.tech.hermes.client.ReactiveHermesClientBuilder.hermesClient
-
-class ReactiveHermesClientMetricsTest extends Specification {
-
- private MetricRegistry metrics = new MetricRegistry()
- private MetricsProvider metricsProvider = new DropwizardMetricsProvider(metrics)
-
- def "should measure publish latency"() {
- given:
- ReactiveHermesClient client = hermesClient(delayedHermesSender(Duration.ofMillis(100)))
- .withRetrySleep(0)
- .withMetrics(metricsProvider).build()
-
- when:
- client.publish("com.group.topic", "123").block()
-
- then:
- metrics.counter("hermes-client.com_group.topic.status.201").count == 1
- metrics.timer("hermes-client.com_group.topic.latency").getSnapshot().getMax() >= Duration.ofMillis(100).get(ChronoUnit.NANOS)
- metrics.timer("hermes-client.com_group.topic.latency").getSnapshot().getMax() < Duration.ofMillis(300).get(ChronoUnit.NANOS)
- }
-
- def "should close timer on exceptional completion and log failure metric"() {
- given:
- ReactiveHermesClient client = hermesClient({uri, msg -> failingMono(new RuntimeException())})
- .withRetrySleep(0)
- .withRetries(3)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client.publish("com.group.topic", "123").block() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.failure").count == 4
- metrics.timers.containsKey("hermes-client.com_group.topic.latency")
-
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 4
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 3
- }
-
- def "should update max retries exceeded metric"() {
- given:
- ReactiveHermesClient client = hermesClient({uri, msg -> failingMono(new RuntimeException())})
- .withRetrySleep(0)
- .withRetries(3)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client.publish("com.group.topic", "123").block() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.failure").count == 4
- metrics.counter("hermes-client.com_group.topic.retries.count").count == 3
- metrics.counter("hermes-client.com_group.topic.retries.exhausted").count == 1
- metrics.counter("hermes-client.com_group.topic.retries.success").count == 0
- metrics.histogram("hermes-client.com_group.topic.retries.attempts").getSnapshot().size() == 0
- metrics.timers.containsKey("hermes-client.com_group.topic.latency")
-
- metrics.counter("hermes-client.com_group.topic.publish.finally.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 4
- metrics.counter("hermes-client.com_group.topic.publish.attempt").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.retry.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.retry.attempt").count == 1
- }
-
- def "should update retries metrics"() {
- given:
- ReactiveHermesClient client1 = hermesClient(failingHermesSender(2))
- .withRetrySleep(0)
- .withRetries(4)
- .withMetrics(metricsProvider).build()
-
- ReactiveHermesClient client2 = hermesClient(failingHermesSender(5))
- .withRetrySleep(0)
- .withRetries(6)
- .withMetrics(metricsProvider).build()
-
- ReactiveHermesClient client3 = hermesClient(failingHermesSender(3))
- .withRetrySleep(0)
- .withRetries(2)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client1.publish("com.group.topic", "123").block() })
- silence({ client2.publish("com.group.topic", "456").block() })
- silence({ client3.publish("com.group.topic", "789").block() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.failure").count == 10
- metrics.counter("hermes-client.com_group.topic.retries.exhausted").count == 1
- metrics.counter("hermes-client.com_group.topic.retries.success").count == 2
- metrics.counter("hermes-client.com_group.topic.retries.count").count == 9
- metrics.histogram("hermes-client.com_group.topic.retries.attempts").getSnapshot().getMin() == 2
- metrics.histogram("hermes-client.com_group.topic.retries.attempts").getSnapshot().getMax() == 5
- metrics.timers.containsKey("hermes-client.com_group.topic.latency")
-
- metrics.counter("hermes-client.com_group.topic.publish.finally.success").count == 2
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 1
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 10
- metrics.counter("hermes-client.com_group.topic.publish.attempt").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.retry.success").count == 2
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 9
- metrics.counter("hermes-client.com_group.topic.publish.retry.attempt").count == 3
- }
-
- def "should update failure metrics when there is an application-level error"() {
- given:
- ReactiveHermesClient client1 = hermesClient(badRequestHermesSender())
- .withRetrySleep(0)
- .withRetries(4)
- .withMetrics(metricsProvider).build()
-
- ReactiveHermesClient client2 = hermesClient(badRequestHermesSender())
- .withRetrySleep(0)
- .withRetries(6)
- .withMetrics(metricsProvider).build()
-
- ReactiveHermesClient client3 = hermesClient(badRequestHermesSender())
- .withRetrySleep(0)
- .withRetries(2)
- .withMetrics(metricsProvider).build()
-
- when:
- silence({ client1.publish("com.group.topic", "123").block() })
- silence({ client2.publish("com.group.topic", "456").block() })
- silence({ client3.publish("com.group.topic", "789").block() })
-
- then:
- metrics.counter("hermes-client.com_group.topic.publish.finally.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.finally.failure").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.failure").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.attempt").count == 3
- metrics.counter("hermes-client.com_group.topic.publish.retry.success").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.retry.failure").count == 0
- metrics.counter("hermes-client.com_group.topic.publish.retry.attempt").count == 0
- }
-
- private Mono successMono(HermesMessage message) {
- return Mono.just(HermesResponseBuilder.hermesResponse(message).withHttpStatus(201).build())
- }
-
- private Mono badRequestMono(HermesMessage message) {
- return Mono.just(HermesResponseBuilder.hermesResponse(message).withHttpStatus(400).build())
- }
-
- private Mono failingMono(Throwable throwable) {
- return Mono.error(throwable)
- }
-
- private ReactiveHermesSender failingHermesSender(int errorNo) {
- new ReactiveHermesSender() {
- int i = 0
- @Override
- Mono sendReactively(URI uri, HermesMessage message) {
- i++
- if (i <= errorNo) {
- return failingMono(new RuntimeException())
- }
- return successMono(message)
- }
- }
- }
-
- private ReactiveHermesSender delayedHermesSender(Duration sendLatencyMs) {
- new ReactiveHermesSender() {
- @Override
- Mono sendReactively(URI uri, HermesMessage message) {
- Thread.sleep(sendLatencyMs.toMillis())
- return successMono(message)
- }
- }
- }
-
- private ReactiveHermesSender badRequestHermesSender() {
- new ReactiveHermesSender() {
- @Override
- Mono sendReactively(URI uri, HermesMessage message) {
- return badRequestMono(message)
- }
- }
- }
-
- private void silence(Runnable runnable) {
- try {
- runnable.run()
- } catch (Exception ex) {
- // do nothing
- }
- }
-
-}
diff --git a/hermes-common/build.gradle b/hermes-common/build.gradle
index ccf959276b..d1e850d4d6 100644
--- a/hermes-common/build.gradle
+++ b/hermes-common/build.gradle
@@ -25,23 +25,21 @@ dependencies {
api group: 'tech.allegro.schema.json2avro', name: 'converter', version: versions.json2avro
api group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
- implementation group: 'commons-codec', name: 'commons-codec', version: '1.9'
+ implementation group: 'commons-codec', name: 'commons-codec', version: '1.16.1'
implementation group: 'com.google.guava', name: 'guava', version: versions.guava
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: versions.jackson
api group: 'org.apache.avro', name: 'avro', version: versions.avro
- api group: 'com.jayway.jsonpath', name: 'json-path', version: '2.5.0'
+ api group: 'com.jayway.jsonpath', name: 'json-path', version: '2.9.0'
- implementation group: 'io.dropwizard.metrics', name: 'metrics-graphite', version: versions.dropwizard_metrics
- implementation group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: versions.dropwizard_metrics
- implementation group: 'org.mpierce.metrics.reservoir', name: 'hdrhistogram-metrics-reservoir', version: '1.1.0'
+ implementation group: 'io.dropwizard.metrics', name: 'metrics-core', version: versions.dropwizard_metrics
- implementation group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.0'
+ implementation group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1'
api group: 'io.micrometer', name: 'micrometer-core', version: versions.micrometer_metrics
api group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: versions.micrometer_metrics
- implementation group: 'org.slf4j', name: 'log4j-over-slf4j', version: '2.0.4'
- implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.7'
+ implementation group: 'org.slf4j', name: 'log4j-over-slf4j', version: '2.0.13'
+ implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.14'
api(group: 'org.apache.kafka', name: 'kafka-clients', version: versions.kafka) {
exclude group: 'net.sf.jopt-simple'
}
@@ -50,12 +48,10 @@ dependencies {
testImplementation project(':hermes-test-helper')
- testImplementation group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
+ testImplementation group: 'jakarta.servlet', name: 'jakarta.servlet-api', version: '6.0.0'
testImplementation group: 'org.spockframework', name: 'spock-core', version: versions.spock
testImplementation group: 'org.spockframework', name: 'spock-junit4', version: versions.spock
- testImplementation (group: 'com.jayway.awaitility', name: 'awaitility-groovy', version: '1.7.0') {
- exclude group: 'org.codehaus.groovy', module: 'groovy-all'
- }
+ testImplementation group: 'org.awaitility', name: 'awaitility-groovy', version: '4.2.1'
testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: versions.junit_jupiter
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/GraphiteParameters.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/GraphiteParameters.java
deleted file mode 100644
index 84314096c4..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/GraphiteParameters.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package pl.allegro.tech.hermes.common.di.factories;
-
-public interface GraphiteParameters {
-
- String getPrefix();
-
- String getHost();
-
- int getPort();
-}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/MetricRegistryFactory.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/MetricRegistryFactory.java
deleted file mode 100644
index 1d1de61579..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/MetricRegistryFactory.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package pl.allegro.tech.hermes.common.di.factories;
-
-import com.codahale.metrics.ConsoleReporter;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.MetricAttribute;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.MetricSet;
-import com.codahale.metrics.graphite.Graphite;
-import com.codahale.metrics.graphite.GraphiteReporter;
-import com.codahale.metrics.jvm.FileDescriptorRatioGauge;
-import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
-import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Sets;
-import jakarta.inject.Named;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import pl.allegro.tech.hermes.common.metric.HermesMetrics;
-import pl.allegro.tech.hermes.common.metric.MetricRegistryWithHdrHistogramReservoir;
-import pl.allegro.tech.hermes.common.util.InstanceIdResolver;
-
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-public class MetricRegistryFactory {
-
- private static final Logger logger = LoggerFactory.getLogger(MetricRegistryFactory.class);
- private final MetricRegistryParameters metricRegistryParameters;
- private final GraphiteParameters graphiteParameters;
- private final InstanceIdResolver instanceIdResolver;
- private final String moduleName;
-
- public MetricRegistryFactory(MetricRegistryParameters metricRegistryParameters,
- GraphiteParameters graphiteParameters,
- InstanceIdResolver instanceIdResolver,
- @Named("moduleName") String moduleName) {
- this.metricRegistryParameters = metricRegistryParameters;
- this.graphiteParameters = graphiteParameters;
- this.instanceIdResolver = instanceIdResolver;
- this.moduleName = moduleName;
- }
-
- public MetricRegistry provide() {
- MetricRegistry registry = new MetricRegistryWithHdrHistogramReservoir();
-
- if (metricRegistryParameters.isGraphiteReporterEnabled()) {
- String prefix = Joiner.on(".").join(
- graphiteParameters.getPrefix(),
- moduleName,
- instanceIdResolver.resolve().replaceAll("\\.", HermesMetrics.REPLACEMENT_CHAR));
-
- GraphiteReporter
- .forRegistry(registry)
- .prefixedWith(prefix)
- .disabledMetricAttributes(getDisabledAttributesFromConfig())
- .build(new Graphite(new InetSocketAddress(
- graphiteParameters.getHost(),
- graphiteParameters.getPort()
- )))
- .start(metricRegistryParameters.getReportPeriod().toSeconds(), TimeUnit.SECONDS);
- }
- if (metricRegistryParameters.isConsoleReporterEnabled()) {
- ConsoleReporter.forRegistry(registry).build().start(
- metricRegistryParameters.getReportPeriod().toSeconds(), TimeUnit.SECONDS
- );
- }
- registerJvmMetrics(registry);
-
- return registry;
- }
-
- private void registerJvmMetrics(MetricRegistry metricRegistry) {
- registerAll("jvm.gc", new GarbageCollectorMetricSet(), metricRegistry);
- registerAll("jvm.memory", new MemoryUsageGaugeSet(), metricRegistry);
- metricRegistry.register("jvm.descriptors", new FileDescriptorRatioGauge());
- }
-
- private void registerAll(String prefix, MetricSet metricSet, MetricRegistry registry) {
- for (Map.Entry entry : metricSet.getMetrics().entrySet()) {
- if (entry.getValue() instanceof MetricSet) {
- registerAll(prefix + "." + entry.getKey(), (MetricSet) entry.getValue(), registry);
- } else {
- registry.register(prefix + "." + entry.getKey(), entry.getValue());
- }
- }
- }
-
- private Set getDisabledAttributesFromConfig() {
- Set disabledAttributes = Sets.newHashSet();
- String disabledAttributesFromConfig = metricRegistryParameters.getDisabledAttributes();
- List disabledAttributesList = Arrays.asList(disabledAttributesFromConfig.split("\\s*,\\s*"));
-
- disabledAttributesList.forEach(singleAttribute -> {
- try {
- disabledAttributes.add(MetricAttribute.valueOf(singleAttribute));
- } catch (IllegalArgumentException e) {
- logger.warn("Failed to add disabled attribute from config: {}", e.getMessage());
- }
- });
-
- return disabledAttributes;
- }
-}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/MetricRegistryParameters.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/MetricRegistryParameters.java
deleted file mode 100644
index d112cea526..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/di/factories/MetricRegistryParameters.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package pl.allegro.tech.hermes.common.di.factories;
-
-import java.time.Duration;
-
-public interface MetricRegistryParameters {
-
- boolean isZookeeperReporterEnabled();
-
- boolean isGraphiteReporterEnabled();
-
- boolean isConsoleReporterEnabled();
-
- String getDisabledAttributes();
-
- Duration getReportPeriod();
-}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/message/converter/AvroBinaryDecoders.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/message/converter/AvroBinaryDecoders.java
index c77be92b29..1d092f655b 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/message/converter/AvroBinaryDecoders.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/message/converter/AvroBinaryDecoders.java
@@ -5,7 +5,7 @@
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.BinaryDecoder;
import org.apache.avro.io.DecoderFactory;
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import tech.allegro.schema.json2avro.converter.AvroConversionException;
import java.io.ByteArrayInputStream;
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerMetrics.java
index 8ef5a5d086..c6b3bb2af0 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerMetrics.java
@@ -9,20 +9,15 @@
import java.util.function.ToDoubleFunction;
-import static pl.allegro.tech.hermes.common.metric.Gauges.BATCH_BUFFER_AVAILABLE_BYTES;
-import static pl.allegro.tech.hermes.common.metric.Gauges.BATCH_BUFFER_TOTAL_BYTES;
-import static pl.allegro.tech.hermes.common.metric.Gauges.THREADS;
import static pl.allegro.tech.hermes.common.metric.SubscriptionTagsFactory.subscriptionTags;
public class ConsumerMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
private final GaugeRegistrar gaugeRegistrar;
- public ConsumerMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public ConsumerMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.gaugeRegistrar = new GaugeRegistrar(meterRegistry, hermesMetrics);
+ this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerQueueUtilizationGauge(T obj, String queueName, ToDoubleFunction f) {
@@ -31,31 +26,28 @@ public void registerQueueUtilizationGauge(T obj, String queueName, ToDouble
public HermesCounter queueFailuresCounter(String name) {
return HermesCounters.from(
- meterRegistry.counter("queue." + name + ".failures"),
- hermesMetrics.counter("queue." + name + ".failures")
+ meterRegistry.counter("queue." + name + ".failures")
);
}
public void registerConsumerProcessesThreadsGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge(THREADS, "consumer-processes.threads", obj, f);
+ gaugeRegistrar.registerGauge("consumer-processes.threads", obj, f);
}
public void registerRunningConsumerProcessesGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerRunningConsumerProcessesCountGauge(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("consumer-processes.running", obj, f);
}
public void registerDyingConsumerProcessesGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerDyingConsumerProcessesCountGauge(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("consumer-processes.dying", obj, f);
}
public void registerBatchBufferTotalBytesGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge(BATCH_BUFFER_TOTAL_BYTES, "batch-buffer.total-bytes", obj, f);
+ gaugeRegistrar.registerGauge("batch-buffer.total-bytes", obj, f);
}
public void registerBatchBufferAvailableBytesGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge(BATCH_BUFFER_AVAILABLE_BYTES, "batch-buffer.available-bytes", obj, f);
+ gaugeRegistrar.registerGauge("batch-buffer.available-bytes", obj, f);
}
public HermesCounter oAuthSubscriptionTokenRequestCounter(Subscription subscription, String providerName) {
@@ -63,29 +55,25 @@ public HermesCounter oAuthSubscriptionTokenRequestCounter(Subscription subscript
meterRegistry.counter("oauth.token-requests", Tags.concat(
subscriptionTags(subscription.getQualifiedName()),
"provider", providerName
- )),
- hermesMetrics.oAuthSubscriptionTokenRequestMeter(subscription, providerName)
+ ))
);
}
public HermesTimer oAuthProviderLatencyTimer(String providerName) {
return HermesTimer.from(
- meterRegistry.timer("oauth.token-request-latency", Tags.of("provider", providerName)),
- hermesMetrics.oAuthProviderLatencyTimer(providerName)
+ meterRegistry.timer("oauth.token-request-latency", Tags.of("provider", providerName))
);
}
public HermesCounter processedSignalsCounter(String name) {
return HermesCounters.from(
- meterRegistry.counter("signals.processed", Tags.of("signal", name)),
- hermesMetrics.counter("supervisor.signal." + name)
+ meterRegistry.counter("signals.processed", Tags.of("signal", name))
);
}
public HermesCounter droppedSignalsCounter(String name) {
return HermesCounters.from(
- meterRegistry.counter("signals.dropped", Tags.of("signal", name)),
- hermesMetrics.counter("supervisor.signal.dropped." + name)
+ meterRegistry.counter("signals.dropped", Tags.of("signal", name))
);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerSenderMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerSenderMetrics.java
index 76bba6dde7..d3d8a3c80e 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerSenderMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ConsumerSenderMetrics.java
@@ -13,33 +13,27 @@
public class ConsumerSenderMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
private final GaugeRegistrar gaugeRegistrar;
- ConsumerSenderMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ ConsumerSenderMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.gaugeRegistrar = new GaugeRegistrar(meterRegistry, hermesMetrics);
+ this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerRequestQueueSizeGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerConsumerSenderRequestQueueSize(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("http-clients.request-queue-size", obj, f);
}
public void registerHttp1SerialClientRequestQueueSizeGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerConsumerSenderHttp1SerialClientRequestQueueSize(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("http-clients.serial.http1.request-queue-size", obj, f);
}
public void registerHttp1BatchClientRequestQueueSizeGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerConsumerSenderHttp1BatchClientRequestQueueSize(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("http-clients.batch.http1.request-queue-size", obj, f);
}
public void registerHttp2RequestQueueSizeGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerConsumerSenderHttp2RequestQueueSize(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("http-clients.serial.http2.request-queue-size", obj, f);
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Counters.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Counters.java
deleted file mode 100644
index 486c053e38..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Counters.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package pl.allegro.tech.hermes.common.metric;
-
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.GROUP;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.SUBSCRIPTION;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.TOPIC;
-
-public class Counters {
-
- public static final String PUBLISHED = "published." + GROUP + "." + TOPIC;
- public static final String DELIVERED = "delivered." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
- public static final String DISCARDED = "discarded." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
- public static final String RETRIES = "retries." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
- public static final String MAXRATE_RATE_HISTORY_FAILURES =
- "consumers-rate.max-rate.node." + GROUP + "." + TOPIC + "." + SUBSCRIPTION + ".history.failures";
- public static final String MAXRATE_FETCH_FAILURES =
- "consumers-rate.max-rate.node." + GROUP + "." + TOPIC + "." + SUBSCRIPTION + ".fetch.failures";
-}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/DeserializationMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/DeserializationMetrics.java
index e8628afbf8..3efe8fac71 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/DeserializationMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/DeserializationMetrics.java
@@ -1,50 +1,43 @@
package pl.allegro.tech.hermes.common.metric;
+import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags;
import pl.allegro.tech.hermes.metrics.HermesCounter;
import pl.allegro.tech.hermes.metrics.counters.HermesCounters;
-import static com.codahale.metrics.MetricRegistry.name;
-
public class DeserializationMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
private static final String BASE_PATH = "content.avro.deserialization";
private static final String ERRORS_PATH = BASE_PATH + ".errors";
- public DeserializationMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public DeserializationMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public HermesCounter errorsForHeaderSchemaVersion() {
return HermesCounters.from(
- deserializationErrorCounter("headerSchemaVersion"),
- hermesMetrics.counter(name(ERRORS_PATH, "headerSchemaVersion"))
+ deserializationErrorCounter("headerSchemaVersion")
);
}
public HermesCounter errorsForHeaderSchemaId() {
return HermesCounters.from(
- deserializationErrorCounter("headerSchemaId"),
- hermesMetrics.counter(name(ERRORS_PATH, "headerSchemaId"))
+ deserializationErrorCounter("headerSchemaId")
);
}
public HermesCounter errorsForSchemaIdAwarePayload() {
return HermesCounters.from(
- deserializationErrorCounter("payloadWithSchemaId"),
- hermesMetrics.counter(name(ERRORS_PATH, "payloadWithSchemaId"))
+ deserializationErrorCounter("payloadWithSchemaId")
);
}
public HermesCounter errorsForSchemaVersionTruncation() {
return HermesCounters.from(
- deserializationErrorCounter("schemaVersionTruncation"),
- hermesMetrics.counter(name(ERRORS_PATH, "schemaVersionTruncation"))
+ deserializationErrorCounter("schemaVersionTruncation")
);
}
@@ -54,40 +47,35 @@ private io.micrometer.core.instrument.Counter deserializationErrorCounter(String
public HermesCounter missingSchemaIdInPayload() {
return HermesCounters.from(
- meterRegistry.counter(name(BASE_PATH, "missing_schemaIdInPayload")),
- hermesMetrics.counter(name(BASE_PATH, "missed", "schemaIdInPayload"))
+ meterRegistry.counter(BASE_PATH + ".missing_schemaIdInPayload")
);
}
public HermesCounter usingHeaderSchemaVersion() {
return HermesCounters.from(
- deserializationAttemptCounter("headerSchemaVersion"),
- hermesMetrics.counter(name(BASE_PATH, "using", "headerSchemaVersion"))
+ deserializationAttemptCounter("headerSchemaVersion")
);
}
public HermesCounter usingHeaderSchemaId() {
return HermesCounters.from(
- deserializationAttemptCounter("headerSchemaId"),
- hermesMetrics.counter(name(BASE_PATH, "using", "headerSchemaId"))
+ deserializationAttemptCounter("headerSchemaId")
);
}
public HermesCounter usingSchemaIdAware() {
return HermesCounters.from(
- deserializationAttemptCounter("payloadWithSchemaId"),
- hermesMetrics.counter(name(BASE_PATH, "using", "schemaIdAware"))
+ deserializationAttemptCounter("payloadWithSchemaId")
);
}
public HermesCounter usingSchemaVersionTruncation() {
return HermesCounters.from(
- deserializationAttemptCounter("schemaVersionTruncation"),
- hermesMetrics.counter(name(BASE_PATH, "using", "schemaVersionTruncation"))
+ deserializationAttemptCounter("schemaVersionTruncation")
);
}
- private io.micrometer.core.instrument.Counter deserializationAttemptCounter(String deserializationType) {
+ private Counter deserializationAttemptCounter(String deserializationType) {
return meterRegistry.counter(BASE_PATH, Tags.of("deserialization_type", deserializationType));
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/GaugeRegistrar.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/GaugeRegistrar.java
index 2d2a7b4c4d..cbcb86ba84 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/GaugeRegistrar.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/GaugeRegistrar.java
@@ -8,40 +8,22 @@
public class GaugeRegistrar {
private final MeterRegistry meterRegistry;
- private final HermesMetrics hermesMetrics;
- public GaugeRegistrar(MeterRegistry meterRegistry, HermesMetrics hermesMetrics) {
+ public GaugeRegistrar(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.hermesMetrics = hermesMetrics;
- }
-
- public void registerGauge(String graphiteName,
- String prometheusName,
- T stateObj,
- ToDoubleFunction f,
- Iterable tags) {
- meterRegistry.gauge(prometheusName, tags, stateObj, f);
- hermesMetrics.registerGauge(graphiteName, () -> f.applyAsDouble(stateObj));
- }
-
- public void registerGauge(String graphiteName,
- String prometheusName,
- T stateObj,
- ToDoubleFunction f) {
- registerGauge(graphiteName, prometheusName, stateObj, f, Tags.empty());
}
public void registerGauge(String name,
T stateObj,
ToDoubleFunction f) {
- registerGauge(name, name, stateObj, f);
+ registerGauge(name, stateObj, f, Tags.empty());
}
public void registerGauge(String name,
T stateObj,
ToDoubleFunction f,
Iterable tags) {
- registerGauge(name, name, stateObj, f, tags);
+ meterRegistry.gauge(name, tags, stateObj, f);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Gauges.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Gauges.java
index c75cbfcdea..5202b7355d 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Gauges.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Gauges.java
@@ -1,37 +1,17 @@
package pl.allegro.tech.hermes.common.metric;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.GROUP;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.SUBSCRIPTION;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.TOPIC;
-
public class Gauges {
- public static final String BATCH_BUFFER_TOTAL_BYTES = "batch-buffer-total-bytes";
- public static final String BATCH_BUFFER_AVAILABLE_BYTES = "batch-buffer-available-bytes";
- public static final String THREADS = "threads";
public static final String INFLIGHT_REQUESTS = "inflight-requests";
- public static final String OUTPUT_RATE = "output-rate." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
public static final String BACKUP_STORAGE_SIZE = "backup-storage.size";
- public static final String MAX_RATE_CALCULATION_DURATION = "consumers-rate.max-rate.coordinator.duration";
- public static final String MAX_RATE_VALUE =
- "consumers-rate.max-rate.node." + GROUP + "." + TOPIC + "." + SUBSCRIPTION + ".max-rate";
- public static final String MAX_RATE_ACTUAL_RATE_VALUE =
- "consumers-rate.max-rate.node." + GROUP + "." + TOPIC + "." + SUBSCRIPTION + ".rate";
- public static final String RUNNING_CONSUMER_PROCESSES_COUNT = "consumer-processes.running-consumer-processes.count";
- public static final String DYING_CONSUMER_PROCESSES_COUNT = "consumer-processes.dying-consumer-processes.count";
- public static final String CONSUMER_SENDER_REQUEST_QUEUE_SIZE = "http-clients.request-queue-size";
- public static final String CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_REQUEST_QUEUE_SIZE = "http-clients.serial.http1.request-queue-size";
public static final String CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_ACTIVE_CONNECTIONS = "http-clients.serial.http1.active-connections";
public static final String CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_IDLE_CONNECTIONS = "http-clients.serial.http1.idle-connections";
- public static final String CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_REQUEST_QUEUE_SIZE = "http-clients.batch.http1.request-queue-size";
public static final String CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_ACTIVE_CONNECTIONS = "http-clients.batch.http1.active-connections";
public static final String CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_IDLE_CONNECTIONS = "http-clients.batch.http1.idle-connections";
- public static final String CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_REQUEST_QUEUE_SIZE = "http-clients.serial.http2.request-queue-size";
public static final String CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_CONNECTIONS = "http-clients.serial.http2.connections";
public static final String CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_PENDING_CONNECTIONS = "http-clients.serial.http2.pending-connections";
- public static final String INFLIGHT = "inflight." + GROUP + "." + TOPIC + "." + SUBSCRIPTION + ".count";
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/HermesMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/HermesMetrics.java
deleted file mode 100644
index 23d477ac6e..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/HermesMetrics.java
+++ /dev/null
@@ -1,274 +0,0 @@
-package pl.allegro.tech.hermes.common.metric;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.Timer;
-import pl.allegro.tech.hermes.api.Subscription;
-import pl.allegro.tech.hermes.api.SubscriptionName;
-import pl.allegro.tech.hermes.api.TopicName;
-import pl.allegro.tech.hermes.metrics.PathContext;
-import pl.allegro.tech.hermes.metrics.PathsCompiler;
-
-import static pl.allegro.tech.hermes.common.metric.Histograms.INFLIGHT_TIME;
-import static pl.allegro.tech.hermes.common.metric.Meters.ERRORS_HTTP_BY_CODE;
-import static pl.allegro.tech.hermes.common.metric.Meters.ERRORS_HTTP_BY_FAMILY;
-import static pl.allegro.tech.hermes.common.metric.Meters.ERRORS_OTHER;
-import static pl.allegro.tech.hermes.common.metric.Meters.ERRORS_TIMEOUTS;
-import static pl.allegro.tech.hermes.common.metric.Meters.SUBSCRIPTION_STATUS;
-import static pl.allegro.tech.hermes.metrics.PathContext.pathContext;
-
-public class HermesMetrics {
-
- public static final String REPLACEMENT_CHAR = "_";
-
- private final MetricRegistry metricRegistry;
- private final PathsCompiler pathCompiler;
-
- public HermesMetrics(
- MetricRegistry metricRegistry,
- PathsCompiler pathCompiler) {
- this.metricRegistry = metricRegistry;
- this.pathCompiler = pathCompiler;
- }
-
- public static String escapeDots(String value) {
- return value.replaceAll("\\.", REPLACEMENT_CHAR);
- }
-
- public Timer timer(String metric) {
- return metricRegistry.timer(metricRegistryName(metric));
- }
-
- public Timer timer(String metric, TopicName topicName) {
- return metricRegistry.timer(metricRegistryName(metric, topicName));
- }
-
- public Timer timer(String metric, TopicName topicName, String name) {
- return metricRegistry.timer(metricRegistryName(metric, topicName, name));
- }
-
- public Meter meter(String metric) {
- return metricRegistry.meter(metricRegistryName(metric));
- }
-
- public Meter meter(String metric, TopicName topicName, String name) {
- return metricRegistry.meter(metricRegistryName(metric, topicName, name));
- }
-
- public Meter meter(String metric, TopicName topicName) {
- return metricRegistry.meter(metricRegistryName(metric, topicName));
- }
-
- public Meter httpStatusCodeMeter(int statusCode) {
- return metricRegistry.meter(pathCompiler.compile(Meters.STATUS_CODES, pathContext().withHttpCode(statusCode).build()));
- }
-
- public Meter httpStatusCodeMeter(int statusCode, TopicName topicName) {
- return metricRegistry.meter(pathCompiler.compile(Meters.TOPIC_STATUS_CODES,
- pathContext().withHttpCode(statusCode).withGroup(topicName.getGroupName()).withTopic(topicName.getName()).build()));
- }
-
- public Histogram histogram(String metric) {
- return metricRegistry.histogram(metricRegistryName(metric));
- }
-
- public Counter counter(String metric) {
- return metricRegistry.counter(metricRegistryName(metric));
- }
-
- public Counter counter(String metric, TopicName topicName) {
- return metricRegistry.counter(metricRegistryName(metric, topicName));
- }
-
- public Counter counter(String metric, TopicName topicName, String name) {
- return metricRegistry.counter(metricRegistryName(metric, topicName, name));
- }
-
- public void registerProducerInflightRequest(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.INFLIGHT_REQUESTS), gauge);
- }
-
- public void registerMessageRepositorySizeGauge(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.BACKUP_STORAGE_SIZE), gauge);
- }
-
- public void registerConsumerSenderRequestQueueSize(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.CONSUMER_SENDER_REQUEST_QUEUE_SIZE), gauge);
- }
-
- public void registerConsumerSenderHttp1SerialClientRequestQueueSize(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_REQUEST_QUEUE_SIZE), gauge);
- }
-
- public void registerConsumerSenderHttp1BatchClientRequestQueueSize(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_REQUEST_QUEUE_SIZE), gauge);
- }
-
- public void registerConsumerSenderHttp2RequestQueueSize(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_REQUEST_QUEUE_SIZE), gauge);
- }
-
- public void registerInflightGauge(SubscriptionName subscription, Gauge> gauge) {
- registerGauge(metricRegistryName(Gauges.INFLIGHT, subscription.getTopicName(), subscription.getName()), gauge);
- }
-
- public void unregisterInflightGauge(SubscriptionName subscription) {
- unregister(Gauges.INFLIGHT, subscription);
- }
-
- public static void close(Timer.Context... timers) {
- for (Timer.Context timer : timers) {
- if (timer != null) {
- timer.close();
- }
- }
- }
-
- public void registerGauge(String name, Gauge> gauge) {
- String path = pathCompiler.compile(name);
- if (!metricRegistry.getGauges().containsKey(name)) {
- metricRegistry.register(path, gauge);
- }
- }
-
- public void registerGauge(String name, SubscriptionName subscription, Gauge> gauge) {
- if (!metricRegistry.getGauges().containsKey(name)) {
- metricRegistry.register(metricRegistryName(name, subscription.getTopicName(), subscription.getName()), gauge);
- }
- }
-
- public void unregister(String metric, SubscriptionName subscription) {
- metricRegistry.remove(metricRegistryName(metric, subscription.getTopicName(), subscription.getName()));
- }
-
- public void unregister(String name) {
- String path = pathCompiler.compile(name);
- metricRegistry.remove(path);
- }
-
- private String metricRegistryName(String metricDisplayName, TopicName topicName, String subscription) {
- PathContext pathContext = PathContext.pathContext()
- .withGroup(escapeDots(topicName.getGroupName()))
- .withTopic(escapeDots(topicName.getName()))
- .withSubscription(escapeDots(subscription))
- .build();
-
- return pathCompiler.compile(metricDisplayName, pathContext);
- }
-
- private String metricRegistryName(String metricDisplayName, TopicName topicName) {
- PathContext pathContext = PathContext.pathContext()
- .withGroup(escapeDots(topicName.getGroupName()))
- .withTopic(escapeDots(topicName.getName())).build();
-
- return pathCompiler.compile(metricDisplayName, pathContext);
- }
-
- private String metricRegistryName(String metricDisplayName) {
- return pathCompiler.compile(metricDisplayName);
- }
-
- public Timer schemaTimer(String schemaMetric) {
- return metricRegistry.timer(pathCompiler.compile(schemaMetric, pathContext().withSchemaRepoType("schema-registry").build()));
- }
-
- private Gauge registerExecutorGauge(String path, String executorName, Gauge gauge) {
- return metricRegistry.register(pathCompiler.compile(path, pathContext().withExecutorName(executorName).build()), gauge);
- }
-
- private Counter executorCounter(String path, String executorName) {
- return metricRegistry.counter(pathCompiler.compile(path, pathContext().withExecutorName(executorName).build()));
- }
-
-
- public Histogram messageContentSizeHistogram() {
- return metricRegistry.histogram(pathCompiler.compile(Histograms.GLOBAL_MESSAGE_SIZE));
- }
-
- public Histogram messageContentSizeHistogram(TopicName topic) {
- return metricRegistry.histogram(pathCompiler.compile(Histograms.MESSAGE_SIZE, pathContext()
- .withGroup(escapeDots(topic.getGroupName()))
- .withTopic(escapeDots(topic.getName()))
- .build()));
- }
-
- public Histogram inflightTimeHistogram(SubscriptionName subscription) {
- return metricRegistry.histogram(metricRegistryName(INFLIGHT_TIME, subscription.getTopicName(), subscription.getName()));
- }
-
- public void unregisterInflightTimeHistogram(SubscriptionName subscription) {
- unregister(INFLIGHT_TIME, subscription);
- }
-
- public void registerConsumerHttpAnswer(SubscriptionName subscription, int statusCode, long count) {
- PathContext pathContext = pathContext()
- .withGroup(escapeDots(subscription.getTopicName().getGroupName()))
- .withTopic(escapeDots(subscription.getTopicName().getName()))
- .withSubscription(escapeDots(subscription.getName()))
- .withHttpCode(statusCode)
- .withHttpCodeFamily(httpStatusFamily(statusCode))
- .build();
- metricRegistry.meter(pathCompiler.compile(ERRORS_HTTP_BY_FAMILY, pathContext)).mark(count);
- metricRegistry.meter(pathCompiler.compile(ERRORS_HTTP_BY_CODE, pathContext)).mark(count);
- }
-
- public void unregisterStatusMeters(SubscriptionName subscription) {
- String prefix = metricRegistryName(SUBSCRIPTION_STATUS, subscription.getTopicName(), subscription.getName());
- metricRegistry.removeMatching(MetricFilter.startsWith(prefix));
- }
-
- private String httpStatusFamily(int statusCode) {
- return String.format("%dxx", statusCode / 100);
- }
-
- public Meter consumerErrorsTimeoutMeter(SubscriptionName subscription) {
- return metricRegistry.meter(metricRegistryName(ERRORS_TIMEOUTS, subscription.getTopicName(), subscription.getName()));
- }
-
- public void unregisterConsumerErrorsTimeoutMeter(SubscriptionName subscription) {
- unregister(ERRORS_TIMEOUTS, subscription);
- }
-
- public Meter consumerErrorsOtherMeter(SubscriptionName subscription) {
- return metricRegistry.meter(metricRegistryName(ERRORS_OTHER, subscription.getTopicName(), subscription.getName()));
- }
-
- public void unregisterConsumerErrorsOtherMeter(SubscriptionName subscription) {
- unregister(ERRORS_OTHER, subscription);
- }
-
- public Timer consumersWorkloadRebalanceDurationTimer(String kafkaCluster) {
- PathContext pathContext = pathContext().withKafkaCluster(kafkaCluster).build();
- return metricRegistry.timer(pathCompiler.compile(Timers.CONSUMER_WORKLOAD_REBALANCE_DURATION, pathContext));
- }
-
- public Timer oAuthProviderLatencyTimer(String oAuthProviderName) {
- PathContext pathContext = pathContext()
- .withOAuthProvider(escapeDots(oAuthProviderName))
- .build();
- return metricRegistry.timer(pathCompiler.compile(Timers.OAUTH_PROVIDER_TOKEN_REQUEST_LATENCY, pathContext));
- }
-
- public Meter oAuthSubscriptionTokenRequestMeter(Subscription subscription, String oAuthProviderName) {
- PathContext pathContext = pathContext()
- .withGroup(escapeDots(subscription.getTopicName().getGroupName()))
- .withTopic(escapeDots(subscription.getTopicName().getName()))
- .withSubscription(escapeDots(subscription.getName()))
- .withOAuthProvider(escapeDots(oAuthProviderName))
- .build();
- return metricRegistry.meter(pathCompiler.compile(Meters.OAUTH_SUBSCRIPTION_TOKEN_REQUEST, pathContext));
- }
-
- public void registerRunningConsumerProcessesCountGauge(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.RUNNING_CONSUMER_PROCESSES_COUNT), gauge);
- }
-
- public void registerDyingConsumerProcessesCountGauge(Gauge gauge) {
- metricRegistry.register(metricRegistryName(Gauges.DYING_CONSUMER_PROCESSES_COUNT), gauge);
- }
-}
-
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Histograms.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Histograms.java
index a12b6f58b5..04238a427c 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Histograms.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Histograms.java
@@ -1,12 +1,6 @@
package pl.allegro.tech.hermes.common.metric;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.GROUP;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.SUBSCRIPTION;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.TOPIC;
public class Histograms {
- public static final String MESSAGE_SIZE = "message-size." + GROUP + "." + TOPIC;
- public static final String GLOBAL_MESSAGE_SIZE = "message-size";
- public static final String INFLIGHT_TIME = "inflight." + GROUP + "." + TOPIC + "." + SUBSCRIPTION + ".time";
public static final String PERSISTED_UNDELIVERED_MESSAGE_SIZE = "undelivered-messages.persisted.message-size";
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MaxRateMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MaxRateMetrics.java
index f1a759308d..18a458e52b 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MaxRateMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MaxRateMetrics.java
@@ -9,55 +9,41 @@
import java.util.function.ToDoubleFunction;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static pl.allegro.tech.hermes.common.metric.Counters.MAXRATE_FETCH_FAILURES;
-import static pl.allegro.tech.hermes.common.metric.Counters.MAXRATE_RATE_HISTORY_FAILURES;
-import static pl.allegro.tech.hermes.common.metric.Gauges.MAX_RATE_ACTUAL_RATE_VALUE;
-import static pl.allegro.tech.hermes.common.metric.Gauges.MAX_RATE_CALCULATION_DURATION;
-import static pl.allegro.tech.hermes.common.metric.Gauges.MAX_RATE_VALUE;
-import static pl.allegro.tech.hermes.common.metric.Gauges.OUTPUT_RATE;
import static pl.allegro.tech.hermes.common.metric.SubscriptionTagsFactory.subscriptionTags;
public class MaxRateMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
- MaxRateMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ MaxRateMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public void registerCalculationDurationInMillisGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerGauge(MAX_RATE_CALCULATION_DURATION, () -> (int) f.applyAsDouble(obj));
meterRegistry.more().timeGauge("max-rate.calculation.duration", List.of(), obj, MILLISECONDS, f);
}
public HermesCounter historyUpdateFailuresCounter(SubscriptionName subscription) {
return HermesCounters.from(
- meterRegistry.counter("max-rate.history-update.failures", subscriptionTags(subscription)),
- hermesMetrics.counter(MAXRATE_RATE_HISTORY_FAILURES, subscription.getTopicName(), subscription.getName())
+ meterRegistry.counter("max-rate.history-update.failures", subscriptionTags(subscription))
);
}
public HermesCounter fetchFailuresCounter(SubscriptionName subscription) {
return HermesCounters.from(
- meterRegistry.counter("max-rate.fetch.failures", subscriptionTags(subscription)),
- hermesMetrics.counter(MAXRATE_FETCH_FAILURES, subscription.getTopicName(), subscription.getName())
+ meterRegistry.counter("max-rate.fetch.failures", subscriptionTags(subscription))
);
}
public void registerCalculatedRateGauge(SubscriptionName subscription, T obj, ToDoubleFunction f) {
- hermesMetrics.registerGauge(MAX_RATE_VALUE, subscription, () -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("max-rate.calculated-rate", subscriptionTags(subscription), obj, f);
}
public void registerActualRateGauge(SubscriptionName subscription, T obj, ToDoubleFunction f) {
- hermesMetrics.registerGauge(MAX_RATE_ACTUAL_RATE_VALUE, subscription, () -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("max-rate.actual-rate", subscriptionTags(subscription), obj, f);
}
public void registerOutputRateGauge(SubscriptionName subscription, T obj, ToDoubleFunction f) {
- hermesMetrics.registerGauge(OUTPUT_RATE, subscription, () -> (int) f.applyAsDouble(obj));
meterRegistry.gauge("max-rate.output-rate", subscriptionTags(subscription), obj, f);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Meters.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Meters.java
index 9fd5a360f3..4438260971 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Meters.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Meters.java
@@ -1,45 +1,12 @@
package pl.allegro.tech.hermes.common.metric;
import static pl.allegro.tech.hermes.metrics.PathsCompiler.GROUP;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.HTTP_CODE;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.HTTP_CODE_FAMILY;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.OAUTH_PROVIDER_NAME;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.SUBSCRIPTION;
import static pl.allegro.tech.hermes.metrics.PathsCompiler.TOPIC;
public class Meters {
- public static final String METER = "meter";
- public static final String TOPIC_METER = METER + "." + GROUP + "." + TOPIC;
- public static final String SUBSCRIPTION_METER = TOPIC_METER + "." + SUBSCRIPTION;
- public static final String FILTERED_METER = SUBSCRIPTION_METER + ".filtered";
- public static final String SUBSCRIPTION_BATCH_METER = TOPIC_METER + "." + SUBSCRIPTION + ".batch";
- public static final String FAILED_METER = "failed-meter";
- public static final String FAILED_TOPIC_METER = FAILED_METER + "." + GROUP + "." + TOPIC;
- public static final String FAILED_METER_SUBSCRIPTION = FAILED_TOPIC_METER + "." + SUBSCRIPTION;
public static final String THROUGHPUT_BYTES = "throughput";
public static final String TOPIC_THROUGHPUT_BYTES = THROUGHPUT_BYTES + "." + GROUP + "." + TOPIC;
- public static final String SUBSCRIPTION_THROUGHPUT_BYTES = TOPIC_THROUGHPUT_BYTES + "." + SUBSCRIPTION;
- public static final String STATUS_CODES = "http-status-codes.code" + HTTP_CODE;
- public static final String TOPIC_STATUS_CODES = "http-status-codes." + GROUP + "." + TOPIC + ".code" + HTTP_CODE;
- public static final String SUBSCRIPTION_STATUS = "status." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
- public static final String ERRORS_TIMEOUTS = SUBSCRIPTION_STATUS + ".errors.timeout";
- public static final String ERRORS_OTHER = SUBSCRIPTION_STATUS + ".errors.other";
- public static final String ERRORS_HTTP_BY_FAMILY = SUBSCRIPTION_STATUS + "." + HTTP_CODE_FAMILY;
- public static final String ERRORS_HTTP_BY_CODE = ERRORS_HTTP_BY_FAMILY + "." + HTTP_CODE;
- public static final String DISCARDED_METER = "discarded-meter";
- public static final String DISCARDED_TOPIC_METER = DISCARDED_METER + "." + GROUP + "." + TOPIC;
- public static final String DISCARDED_SUBSCRIPTION_METER = DISCARDED_TOPIC_METER + "." + SUBSCRIPTION;
- public static final String RETRIES_METER = "retries-meter";
- public static final String RETRIES_TOPIC_METER = RETRIES_METER + "." + GROUP + "." + TOPIC;
- public static final String RETRIES_SUBSCRIPTION_METER = RETRIES_TOPIC_METER + "." + SUBSCRIPTION;
- public static final String DELAYED_PROCESSING = "delayed-processing";
- public static final String TOPIC_DELAYED_PROCESSING = DELAYED_PROCESSING + "." + GROUP + "." + TOPIC;
-
- public static final String TOPIC_DUPLICATED_MESSAGE = "duplicated-message" + "." + GROUP + "." + TOPIC;
-
- public static final String OAUTH_SUBSCRIPTION_TOKEN_REQUEST = "oauth.subscription." + GROUP + "." + TOPIC + "." + SUBSCRIPTION
- + ".token-request." + OAUTH_PROVIDER_NAME;
public static final String PERSISTED_UNDELIVERED_MESSAGES_METER = "undelivered-messages.persisted";
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricRegistryWithHdrHistogramReservoir.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricRegistryWithHdrHistogramReservoir.java
deleted file mode 100644
index a8c931742d..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricRegistryWithHdrHistogramReservoir.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package pl.allegro.tech.hermes.common.metric;
-
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.Timer;
-import org.mpierce.metrics.reservoir.hdrhistogram.HdrHistogramResetOnSnapshotReservoir;
-
-public class MetricRegistryWithHdrHistogramReservoir extends MetricRegistry {
-
- @Override
- public Histogram histogram(String name) {
- return histogram(name, () -> new Histogram(new HdrHistogramResetOnSnapshotReservoir()));
- }
-
- @Override
- public Timer timer(String name) {
- return timer(name, () -> new Timer(new HdrHistogramResetOnSnapshotReservoir()));
- }
-}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricsFacade.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricsFacade.java
index ab57f56456..23f489aaf8 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricsFacade.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/MetricsFacade.java
@@ -7,30 +7,11 @@
import java.util.Collection;
-import static pl.allegro.tech.hermes.common.metric.Counters.DELIVERED;
-import static pl.allegro.tech.hermes.common.metric.Counters.DISCARDED;
-import static pl.allegro.tech.hermes.common.metric.Counters.MAXRATE_FETCH_FAILURES;
-import static pl.allegro.tech.hermes.common.metric.Counters.MAXRATE_RATE_HISTORY_FAILURES;
-import static pl.allegro.tech.hermes.common.metric.Counters.RETRIES;
-import static pl.allegro.tech.hermes.common.metric.Gauges.MAX_RATE_ACTUAL_RATE_VALUE;
-import static pl.allegro.tech.hermes.common.metric.Gauges.MAX_RATE_VALUE;
-import static pl.allegro.tech.hermes.common.metric.Gauges.OUTPUT_RATE;
-import static pl.allegro.tech.hermes.common.metric.Meters.DISCARDED_SUBSCRIPTION_METER;
-import static pl.allegro.tech.hermes.common.metric.Meters.FAILED_METER_SUBSCRIPTION;
-import static pl.allegro.tech.hermes.common.metric.Meters.FILTERED_METER;
-import static pl.allegro.tech.hermes.common.metric.Meters.RETRIES_SUBSCRIPTION_METER;
-import static pl.allegro.tech.hermes.common.metric.Meters.SUBSCRIPTION_BATCH_METER;
-import static pl.allegro.tech.hermes.common.metric.Meters.SUBSCRIPTION_METER;
-import static pl.allegro.tech.hermes.common.metric.Meters.SUBSCRIPTION_THROUGHPUT_BYTES;
import static pl.allegro.tech.hermes.common.metric.SubscriptionTagsFactory.subscriptionTags;
-import static pl.allegro.tech.hermes.common.metric.Timers.CONSUMER_IDLE_TIME;
-import static pl.allegro.tech.hermes.common.metric.Timers.RATE_LIMITER_ACQUIRE;
-import static pl.allegro.tech.hermes.common.metric.Timers.SUBSCRIPTION_LATENCY;
public class MetricsFacade {
private final MeterRegistry meterRegistry;
- private final HermesMetrics hermesMetrics;
private final TopicMetrics topicMetrics;
private final SubscriptionMetrics subscriptionMetrics;
private final ConsumerMetrics consumerMetrics;
@@ -47,23 +28,22 @@ public class MetricsFacade {
private final MaxRateMetrics maxRateMetrics;
private final BrokerMetrics brokerMetrics;
- public MetricsFacade(MeterRegistry meterRegistry, HermesMetrics hermesMetrics) {
+ public MetricsFacade(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.hermesMetrics = hermesMetrics;
- this.topicMetrics = new TopicMetrics(hermesMetrics, meterRegistry);
- this.subscriptionMetrics = new SubscriptionMetrics(hermesMetrics, meterRegistry);
- this.consumerMetrics = new ConsumerMetrics(hermesMetrics, meterRegistry);
- this.trackerElasticSearchMetrics = new TrackerElasticSearchMetrics(hermesMetrics, meterRegistry);
- this.persistentBufferMetrics = new PersistentBufferMetrics(hermesMetrics, meterRegistry);
- this.producerMetrics = new ProducerMetrics(hermesMetrics, meterRegistry);
+ this.topicMetrics = new TopicMetrics(meterRegistry);
+ this.subscriptionMetrics = new SubscriptionMetrics(meterRegistry);
+ this.consumerMetrics = new ConsumerMetrics(meterRegistry);
+ this.trackerElasticSearchMetrics = new TrackerElasticSearchMetrics(meterRegistry);
+ this.persistentBufferMetrics = new PersistentBufferMetrics(meterRegistry);
+ this.producerMetrics = new ProducerMetrics(meterRegistry);
this.executorMetrics = new ExecutorMetrics(meterRegistry);
- this.schemaClientMetrics = new SchemaClientMetrics(hermesMetrics, meterRegistry);
- this.undeliveredMessagesMetrics = new UndeliveredMessagesMetrics(hermesMetrics, meterRegistry);
- this.deserializationMetrics = new DeserializationMetrics(hermesMetrics, meterRegistry);
- this.workloadMetrics = new WorkloadMetrics(hermesMetrics, meterRegistry);
- this.consumerSenderMetrics = new ConsumerSenderMetrics(hermesMetrics, meterRegistry);
- this.offsetCommitsMetrics = new OffsetCommitsMetrics(hermesMetrics, meterRegistry);
- this.maxRateMetrics = new MaxRateMetrics(hermesMetrics, meterRegistry);
+ this.schemaClientMetrics = new SchemaClientMetrics(meterRegistry);
+ this.undeliveredMessagesMetrics = new UndeliveredMessagesMetrics(meterRegistry);
+ this.deserializationMetrics = new DeserializationMetrics(meterRegistry);
+ this.workloadMetrics = new WorkloadMetrics(meterRegistry);
+ this.consumerSenderMetrics = new ConsumerSenderMetrics(meterRegistry);
+ this.offsetCommitsMetrics = new OffsetCommitsMetrics(meterRegistry);
+ this.maxRateMetrics = new MaxRateMetrics(meterRegistry);
this.brokerMetrics = new BrokerMetrics(meterRegistry);
}
@@ -134,28 +114,5 @@ public void unregisterAllMetricsRelatedTo(SubscriptionName subscription) {
for (Meter meter : meters) {
meterRegistry.remove(meter);
}
- hermesMetrics.unregister(DISCARDED_SUBSCRIPTION_METER, subscription);
- hermesMetrics.unregister(RETRIES_SUBSCRIPTION_METER, subscription);
- hermesMetrics.unregister(FAILED_METER_SUBSCRIPTION, subscription);
- hermesMetrics.unregister(SUBSCRIPTION_BATCH_METER, subscription);
- hermesMetrics.unregister(SUBSCRIPTION_METER, subscription);
- hermesMetrics.unregister(DELIVERED, subscription);
- hermesMetrics.unregister(DISCARDED, subscription);
- hermesMetrics.unregister(RETRIES, subscription);
- hermesMetrics.unregisterInflightGauge(subscription);
- hermesMetrics.unregisterInflightTimeHistogram(subscription);
- hermesMetrics.unregisterConsumerErrorsTimeoutMeter(subscription);
- hermesMetrics.unregisterConsumerErrorsOtherMeter(subscription);
- hermesMetrics.unregisterStatusMeters(subscription);
- hermesMetrics.unregister(OUTPUT_RATE, subscription);
- hermesMetrics.unregister(MAX_RATE_ACTUAL_RATE_VALUE, subscription);
- hermesMetrics.unregister(MAX_RATE_VALUE, subscription);
- hermesMetrics.unregister(MAXRATE_FETCH_FAILURES, subscription);
- hermesMetrics.unregister(MAXRATE_RATE_HISTORY_FAILURES, subscription);
- hermesMetrics.unregister(CONSUMER_IDLE_TIME, subscription);
- hermesMetrics.unregister(FILTERED_METER, subscription);
- hermesMetrics.unregister(SUBSCRIPTION_LATENCY, subscription);
- hermesMetrics.unregister(RATE_LIMITER_ACQUIRE, subscription);
- hermesMetrics.unregister(SUBSCRIPTION_THROUGHPUT_BYTES, subscription);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/OffsetCommitsMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/OffsetCommitsMetrics.java
index 84527282a4..b3b1376edb 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/OffsetCommitsMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/OffsetCommitsMetrics.java
@@ -7,46 +7,39 @@
public class OffsetCommitsMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
- OffsetCommitsMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ OffsetCommitsMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public HermesCounter skippedCounter() {
return HermesCounters.from(
- meterRegistry.counter("offset-commits.skipped"),
- hermesMetrics.counter("offset-committer.skipped")
+ meterRegistry.counter("offset-commits.skipped")
);
}
public HermesCounter obsoleteCounter() {
return HermesCounters.from(
- meterRegistry.counter("offset-commits.obsolete"),
- hermesMetrics.counter("offset-committer.obsolete")
+ meterRegistry.counter("offset-commits.obsolete")
);
}
public HermesCounter committedCounter() {
return HermesCounters.from(
- meterRegistry.counter("offset-commits.committed"),
- hermesMetrics.counter("offset-committer.committed")
+ meterRegistry.counter("offset-commits.committed")
);
}
public HermesTimer duration() {
return HermesTimer.from(
- meterRegistry.timer("offset-commits.duration"),
- hermesMetrics.timer("offset-committer.duration")
+ meterRegistry.timer("offset-commits.duration")
);
}
public HermesCounter failuresCounter() {
return HermesCounters.from(
- meterRegistry.counter("offset-commits.failures"),
- hermesMetrics.counter("offset-committer.failed")
+ meterRegistry.counter("offset-commits.failures")
);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/PersistentBufferMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/PersistentBufferMetrics.java
index b67c522807..798e3f57fd 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/PersistentBufferMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/PersistentBufferMetrics.java
@@ -8,15 +8,12 @@
public class PersistentBufferMetrics {
private final MeterRegistry meterRegistry;
- private final HermesMetrics hermesMetrics;
- public PersistentBufferMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
+ public PersistentBufferMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.hermesMetrics = hermesMetrics;
}
public void registerBackupStorageSizeGauge(T obj, ToDoubleFunction f) {
- hermesMetrics.registerMessageRepositorySizeGauge(() -> (int) f.applyAsDouble(obj));
meterRegistry.gauge(BACKUP_STORAGE_SIZE, obj, f);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ProducerMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ProducerMetrics.java
index 42f95521e6..0c1b65b913 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ProducerMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ProducerMetrics.java
@@ -9,14 +9,12 @@
import static pl.allegro.tech.hermes.common.metric.Gauges.INFLIGHT_REQUESTS;
public class ProducerMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
private final GaugeRegistrar gaugeRegistrar;
- public ProducerMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public ProducerMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.gaugeRegistrar = new GaugeRegistrar(meterRegistry, hermesMetrics);
+ this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerAckAllTotalBytesGauge(T stateObj, ToDoubleFunction f, String sender, String datacenter) {
@@ -52,20 +50,19 @@ public void registerAckLeaderFailedBatchesGauge(T stateObj, ToDoubleFunction
}
public void registerAckAllMetadataAgeGauge(T stateObj, ToDoubleFunction f, String sender, String datacenter) {
- registerTimeGauge(stateObj, f, ACK_ALL_METADATA_AGE, ACK_ALL_METADATA_AGE, tags(sender, datacenter), TimeUnit.SECONDS);
+ registerTimeGauge(stateObj, f, ACK_ALL_METADATA_AGE, tags(sender, datacenter), TimeUnit.SECONDS);
}
public void registerAckLeaderMetadataAgeGauge(T stateObj, ToDoubleFunction f, String sender, String datacenter) {
- registerTimeGauge(stateObj, f, ACK_LEADER_METADATA_AGE, ACK_LEADER_METADATA_AGE, tags(sender, datacenter), TimeUnit.SECONDS);
+ registerTimeGauge(stateObj, f, ACK_LEADER_METADATA_AGE, tags(sender, datacenter), TimeUnit.SECONDS);
}
public void registerAckAllRecordQueueTimeMaxGauge(T stateObj, ToDoubleFunction f, String sender, String datacenter) {
- registerTimeGauge(stateObj, f, ACK_ALL_RECORD_QUEUE_TIME_MAX, ACK_ALL_RECORD_QUEUE_TIME_MAX, tags(sender, datacenter), TimeUnit.MILLISECONDS);
+ registerTimeGauge(stateObj, f, ACK_ALL_RECORD_QUEUE_TIME_MAX, tags(sender, datacenter), TimeUnit.MILLISECONDS);
}
public void registerAckLeaderRecordQueueTimeMaxGauge(T stateObj, ToDoubleFunction f, String sender, String datacenter) {
- registerTimeGauge(stateObj, f, ACK_LEADER_RECORD_QUEUE_TIME_MAX,
- ACK_LEADER_RECORD_QUEUE_TIME_MAX, tags(sender, datacenter), TimeUnit.MILLISECONDS);
+ registerTimeGauge(stateObj, f, ACK_LEADER_RECORD_QUEUE_TIME_MAX, tags(sender, datacenter), TimeUnit.MILLISECONDS);
}
public double getBufferTotalBytes() {
@@ -88,7 +85,6 @@ public void registerAckAllRecordSendCounter(T stateObj, ToDoubleFunction
public void registerProducerInflightRequestGauge(T stateObj, ToDoubleFunction f) {
meterRegistry.gauge(INFLIGHT_REQUESTS, stateObj, f);
- hermesMetrics.registerProducerInflightRequest(() -> (int) f.applyAsDouble(stateObj));
}
private static Tags tags(String sender, String datacenter) {
@@ -98,12 +94,10 @@ private static Tags tags(String sender, String datacenter) {
private void registerTimeGauge(T stateObj,
ToDoubleFunction f,
- String graphiteName,
- String prometheusName,
+ String name,
Tags tags,
TimeUnit timeUnit) {
- hermesMetrics.registerGauge(graphiteName, () -> f.applyAsDouble(stateObj));
- meterRegistry.more().timeGauge(prometheusName, tags, stateObj, timeUnit, f);
+ meterRegistry.more().timeGauge(name, tags, stateObj, timeUnit, f);
}
private void registerCounter(String name, Tags tags, T stateObj, ToDoubleFunction f) {
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SchemaClientMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SchemaClientMetrics.java
index a32f1d6910..020bffcc83 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SchemaClientMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SchemaClientMetrics.java
@@ -5,29 +5,22 @@
import io.micrometer.core.instrument.Timer;
import pl.allegro.tech.hermes.metrics.HermesTimer;
-import static pl.allegro.tech.hermes.common.metric.Timers.GET_SCHEMA_LATENCY;
-import static pl.allegro.tech.hermes.common.metric.Timers.GET_SCHEMA_VERSIONS_LATENCY;
-
public class SchemaClientMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
- public SchemaClientMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public SchemaClientMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public HermesTimer schemaTimer() {
return HermesTimer.from(
- timer("schema.get-schema"),
- hermesMetrics.schemaTimer(GET_SCHEMA_LATENCY)
+ timer("schema.get-schema")
);
}
public HermesTimer versionsTimer() {
return HermesTimer.from(
- timer("schema.get-versions"),
- hermesMetrics.schemaTimer(GET_SCHEMA_VERSIONS_LATENCY)
+ timer("schema.get-versions")
);
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionHermesCounter.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionHermesCounter.java
index 73da4f18f1..2d9d237b5a 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionHermesCounter.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionHermesCounter.java
@@ -1,31 +1,23 @@
package pl.allegro.tech.hermes.common.metric;
-import com.codahale.metrics.Meter;
import io.micrometer.core.instrument.Counter;
import pl.allegro.tech.hermes.api.SubscriptionName;
-import pl.allegro.tech.hermes.metrics.counters.MeterBackedHermesCounter;
+import pl.allegro.tech.hermes.metrics.counters.DefaultHermesCounter;
-public class SubscriptionHermesCounter extends MeterBackedHermesCounter {
+public class SubscriptionHermesCounter extends DefaultHermesCounter {
- private final String graphiteName;
private final SubscriptionName subscription;
private SubscriptionHermesCounter(Counter micrometerCounter,
- Meter graphiteMeter,
- String graphiteName, SubscriptionName subscription) {
- super(micrometerCounter, graphiteMeter);
- this.graphiteName = graphiteName;
+ SubscriptionName subscription) {
+ super(micrometerCounter);
this.subscription = subscription;
}
- public static SubscriptionHermesCounter from(Counter micrometerCounter, Meter graphiteMeter,
- String graphiteName, SubscriptionName subscription) {
- return new SubscriptionHermesCounter(micrometerCounter, graphiteMeter, graphiteName, subscription);
+ public static SubscriptionHermesCounter from(Counter micrometerCounter, SubscriptionName subscription) {
+ return new SubscriptionHermesCounter(micrometerCounter, subscription);
}
- String getGraphiteName() {
- return graphiteName;
- }
SubscriptionName getSubscription() {
return subscription;
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionMetrics.java
index 4f4916bc05..95a1b85369 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/SubscriptionMetrics.java
@@ -15,130 +15,94 @@
import static pl.allegro.tech.hermes.common.metric.SubscriptionTagsFactory.subscriptionTags;
public class SubscriptionMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
- public SubscriptionMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public SubscriptionMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public SubscriptionHermesCounter throughputInBytes(SubscriptionName subscription) {
return SubscriptionHermesCounter.from(
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_THROUGHPUT, subscription),
- hermesMetrics.meter(Meters.SUBSCRIPTION_THROUGHPUT_BYTES, subscription.getTopicName(), subscription.getName()),
- Meters.SUBSCRIPTION_THROUGHPUT_BYTES, subscription);
+ micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_THROUGHPUT, subscription), subscription);
}
public HermesCounter successes(SubscriptionName subscription) {
- return size -> {
- hermesMetrics.meter(Meters.METER).mark(size);
- hermesMetrics.meter(Meters.TOPIC_METER, subscription.getTopicName()).mark(size);
- hermesMetrics.meter(Meters.SUBSCRIPTION_METER, subscription.getTopicName(), subscription.getName()).mark(size);
- hermesMetrics.counter(Counters.DELIVERED, subscription.getTopicName(), subscription.getName()).inc(size);
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_DELIVERED, subscription).increment(size);
- };
+ return size -> micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_DELIVERED, subscription).increment(size);
}
public HermesCounter batchSuccesses(SubscriptionName subscription) {
return HermesCounters.from(
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_BATCHES, subscription),
- hermesMetrics.meter(Meters.SUBSCRIPTION_BATCH_METER, subscription.getTopicName(), subscription.getName())
+ micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_BATCHES, subscription)
);
}
public HermesCounter discarded(SubscriptionName subscription) {
- return size -> {
- hermesMetrics.meter(Meters.DISCARDED_METER).mark(size);
- hermesMetrics.meter(Meters.DISCARDED_TOPIC_METER, subscription.getTopicName()).mark(size);
- hermesMetrics.meter(Meters.DISCARDED_SUBSCRIPTION_METER, subscription.getTopicName(), subscription.getName()).mark(size);
- hermesMetrics.counter(Counters.DISCARDED, subscription.getTopicName(), subscription.getName()).inc(size);
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_DISCARDED, subscription).increment(size);
- };
+ return size -> micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_DISCARDED, subscription).increment(size);
+
}
public HermesCounter retries(SubscriptionName subscription) {
- return size -> {
- hermesMetrics.meter(Meters.RETRIES_METER).mark(size);
- hermesMetrics.meter(Meters.RETRIES_TOPIC_METER, subscription.getTopicName()).mark(size);
- hermesMetrics.meter(Meters.RETRIES_SUBSCRIPTION_METER, subscription.getTopicName(), subscription.getName()).mark(size);
- hermesMetrics.counter(Counters.RETRIES, subscription.getTopicName(), subscription.getName()).inc(size);
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_RETRIES, subscription).increment(size);
- };
+ return size -> micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_RETRIES, subscription).increment(size);
}
public HermesTimer latency(SubscriptionName subscription) {
return HermesTimer.from(
- meterRegistry.timer(SubscriptionMetricsNames.SUBSCRIPTION_LATENCY, subscriptionTags(subscription)),
- hermesMetrics.timer(Timers.SUBSCRIPTION_LATENCY, subscription.getTopicName(), subscription.getName())
+ meterRegistry.timer(SubscriptionMetricsNames.SUBSCRIPTION_LATENCY, subscriptionTags(subscription))
);
}
public HermesTimer rateLimiterAcquire(SubscriptionName subscription) {
return HermesTimer.from(
- meterRegistry.timer(SubscriptionMetricsNames.SUBSCRIPTION_RATE_LIMITER_ACQUIRE, subscriptionTags(subscription)),
- hermesMetrics.timer(Timers.RATE_LIMITER_ACQUIRE, subscription.getTopicName(), subscription.getName())
+ meterRegistry.timer(SubscriptionMetricsNames.SUBSCRIPTION_RATE_LIMITER_ACQUIRE, subscriptionTags(subscription))
);
}
public void registerInflightGauge(SubscriptionName subscription, T obj, ToDoubleFunction f) {
- hermesMetrics.registerInflightGauge(subscription, () -> (int) f.applyAsDouble(obj));
meterRegistry.gauge(SubscriptionMetricsNames.SUBSCRIPTION_INFLIGHT, subscriptionTags(subscription), obj, f);
}
public HermesTimer consumerIdleTimer(SubscriptionName subscription) {
return HermesTimer.from(
- meterRegistry.timer(SubscriptionMetricsNames.SUBSCRIPTION_IDLE_DURATION, subscriptionTags(subscription)),
- hermesMetrics.timer(Timers.CONSUMER_IDLE_TIME, subscription.getTopicName(), subscription.getName())
+ meterRegistry.timer(SubscriptionMetricsNames.SUBSCRIPTION_IDLE_DURATION, subscriptionTags(subscription))
);
}
public HermesCounter filteredOutCounter(SubscriptionName subscription) {
return HermesCounters.from(
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_FILTERED_OUT, subscription),
- hermesMetrics.meter(Meters.FILTERED_METER, subscription.getTopicName(), subscription.getName())
+ micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_FILTERED_OUT, subscription)
);
}
public HermesCounter httpAnswerCounter(SubscriptionName subscription, int statusCode) {
- return size -> {
- meterRegistry.counter(
- SubscriptionMetricsNames.SUBSCRIPTION_HTTP_STATUS_CODES,
- Tags.concat(subscriptionTags(subscription), "status_code", String.valueOf(statusCode))
- ).increment(size);
- hermesMetrics.registerConsumerHttpAnswer(subscription, statusCode, size);
- };
+ return size -> meterRegistry.counter(
+ SubscriptionMetricsNames.SUBSCRIPTION_HTTP_STATUS_CODES,
+ Tags.concat(subscriptionTags(subscription), "status_code", String.valueOf(statusCode))
+ ).increment(size);
}
public HermesCounter timeoutsCounter(SubscriptionName subscription) {
return HermesCounters.from(
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_TIMEOUTS, subscription),
- hermesMetrics.consumerErrorsTimeoutMeter(subscription)
+ micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_TIMEOUTS, subscription)
);
}
public HermesCounter otherErrorsCounter(SubscriptionName subscription) {
return HermesCounters.from(
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_OTHER_ERRORS, subscription),
- hermesMetrics.consumerErrorsOtherMeter(subscription)
+ micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_OTHER_ERRORS, subscription)
);
}
public HermesCounter failuresCounter(SubscriptionName subscription) {
return HermesCounters.from(
- micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_FAILURES, subscription),
- hermesMetrics.meter(Meters.FAILED_METER_SUBSCRIPTION, subscription.getTopicName(), subscription.getName())
+ micrometerCounter(SubscriptionMetricsNames.SUBSCRIPTION_FAILURES, subscription)
);
}
public HermesHistogram inflightTimeInMillisHistogram(SubscriptionName subscriptionName) {
- return value -> {
- DistributionSummary.builder(SubscriptionMetricsNames.SUBSCRIPTION_INFLIGHT_TIME)
- .tags(subscriptionTags(subscriptionName))
- .register(meterRegistry)
- .record(value / 1000d);
- hermesMetrics.inflightTimeHistogram(subscriptionName).update(value);
- };
+ return value -> DistributionSummary.builder(SubscriptionMetricsNames.SUBSCRIPTION_INFLIGHT_TIME)
+ .tags(subscriptionTags(subscriptionName))
+ .register(meterRegistry)
+ .record(value / 1000d);
}
private Counter micrometerCounter(String metricName, SubscriptionName subscription) {
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Timers.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Timers.java
deleted file mode 100644
index f130b21410..0000000000
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/Timers.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package pl.allegro.tech.hermes.common.metric;
-
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.GROUP;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.KAFKA_CLUSTER;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.OAUTH_PROVIDER_NAME;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.SCHEMA_REPO_TYPE;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.SUBSCRIPTION;
-import static pl.allegro.tech.hermes.metrics.PathsCompiler.TOPIC;
-
-public class Timers {
-
- public static final String ACK_ALL_BROKER_LATENCY = "ack-all.broker-latency";
- public static final String ACK_LEADER_BROKER_LATENCY = "ack-leader.broker-latency";
-
- public static final String ACK_ALL_LATENCY = "ack-all.latency";
- public static final String ACK_ALL_TOPIC_LATENCY = ACK_ALL_LATENCY + "." + GROUP + "." + TOPIC;
-
- public static final String ACK_LEADER_LATENCY = "ack-leader.latency";
- public static final String ACK_LEADER_TOPIC_LATENCY = ACK_LEADER_LATENCY + "." + GROUP + "." + TOPIC;
-
- public static final String LATENCY = "latency";
- public static final String SUBSCRIPTION_LATENCY = LATENCY + "." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
- public static final String RATE_LIMITER_ACQUIRE = "rate-limiter-acquire" + "." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
-
- public static final String SCHEMA = "schema." + SCHEMA_REPO_TYPE;
- public static final String GET_SCHEMA_LATENCY = SCHEMA + ".get-schema";
- public static final String GET_SCHEMA_VERSIONS_LATENCY = SCHEMA + ".get-schema-versions";
-
- public static final String CONSUMER_WORKLOAD_REBALANCE_DURATION = "consumers-workload." + KAFKA_CLUSTER + ".rebalance-duration";
- public static final String CONSUMER_IDLE_TIME = "idle-time." + GROUP + "." + TOPIC + "." + SUBSCRIPTION;
-
- public static final String OAUTH_PROVIDER_TOKEN_REQUEST_LATENCY = "oauth.provider." + OAUTH_PROVIDER_NAME + ".token-request-latency";
-}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TopicMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TopicMetrics.java
index bab7b92e01..e7ae1dcf89 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TopicMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TopicMetrics.java
@@ -12,132 +12,110 @@
import pl.allegro.tech.hermes.metrics.HermesHistogram;
import pl.allegro.tech.hermes.metrics.HermesTimer;
import pl.allegro.tech.hermes.metrics.counters.HermesCounters;
-import pl.allegro.tech.hermes.metrics.counters.MeterBackedHermesCounter;
-
-import static pl.allegro.tech.hermes.common.metric.Meters.DELAYED_PROCESSING;
public class TopicMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
- public TopicMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public TopicMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public HermesTimer ackAllGlobalLatency() {
return HermesTimer.from(
- meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_ALL_GLOBAL_LATENCY),
- hermesMetrics.timer(Timers.ACK_ALL_LATENCY)
+ meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_ALL_GLOBAL_LATENCY)
);
}
public HermesTimer ackAllTopicLatency(TopicName topic) {
return HermesTimer.from(
- micrometerTimer(TopicMetricsNames.TOPIC_ACK_ALL_LATENCY, topic),
- hermesMetrics.timer(Timers.ACK_ALL_TOPIC_LATENCY, topic));
+ micrometerTimer(TopicMetricsNames.TOPIC_ACK_ALL_LATENCY, topic));
}
public HermesTimer ackAllBrokerLatency() {
return HermesTimer.from(
- meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_ALL_BROKER_LATENCY),
- hermesMetrics.timer(Timers.ACK_ALL_BROKER_LATENCY));
+ meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_ALL_BROKER_LATENCY));
}
public HermesTimer ackLeaderGlobalLatency() {
return HermesTimer.from(
- meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_LEADER_GLOBAL_LATENCY),
- hermesMetrics.timer(Timers.ACK_LEADER_LATENCY));
+ meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_LEADER_GLOBAL_LATENCY));
}
public HermesTimer ackLeaderTopicLatency(TopicName topic) {
return HermesTimer.from(
- micrometerTimer(TopicMetricsNames.TOPIC_ACK_LEADER_LATENCY, topic),
- hermesMetrics.timer(Timers.ACK_LEADER_TOPIC_LATENCY, topic));
+ micrometerTimer(TopicMetricsNames.TOPIC_ACK_LEADER_LATENCY, topic));
}
public HermesTimer ackLeaderBrokerLatency() {
return HermesTimer.from(
- meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_LEADER_BROKER_LATENCY),
- hermesMetrics.timer(Timers.ACK_LEADER_BROKER_LATENCY));
+ meterRegistry.timer(TopicMetricsNames.TOPIC_ACK_LEADER_BROKER_LATENCY));
}
- public MeterBackedHermesCounter topicThroughputBytes(TopicName topicName) {
+ public HermesCounter topicThroughputBytes(TopicName topicName) {
return HermesCounters.from(
- micrometerCounter(TopicMetricsNames.TOPIC_THROUGHPUT, topicName),
- hermesMetrics.meter(Meters.TOPIC_THROUGHPUT_BYTES, topicName)
+ micrometerCounter(TopicMetricsNames.TOPIC_THROUGHPUT, topicName)
);
}
- public MeterBackedHermesCounter topicGlobalThroughputBytes() {
+ public HermesCounter topicGlobalThroughputBytes() {
return HermesCounters.from(
- meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_THROUGHPUT),
- hermesMetrics.meter(Meters.THROUGHPUT_BYTES)
+ meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_THROUGHPUT)
);
}
public HermesCounter topicPublished(TopicName topicName, String datacenter) {
return HermesCounters.from(
- micrometerCounter(TopicMetricsNames.TOPIC_PUBLISHED, topicName, Tag.of("storageDc", datacenter)),
- hermesMetrics.counter(Counters.PUBLISHED, topicName)
+ micrometerCounter(TopicMetricsNames.TOPIC_PUBLISHED, topicName, Tag.of("storageDc", datacenter))
);
}
public HermesCounter topicGlobalRequestCounter() {
return HermesCounters.from(
- meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_REQUESTS),
- hermesMetrics.meter(Meters.METER)
+ meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_REQUESTS)
);
}
public HermesCounter topicRequestCounter(TopicName topicName) {
return HermesCounters.from(
- micrometerCounter(TopicMetricsNames.TOPIC_REQUESTS, topicName),
- hermesMetrics.meter(Meters.TOPIC_METER, topicName)
+ micrometerCounter(TopicMetricsNames.TOPIC_REQUESTS, topicName)
);
}
public HermesCounter topicGlobalDelayedProcessingCounter() {
return HermesCounters.from(
- meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_DELAYED_PROCESSING),
- hermesMetrics.meter(DELAYED_PROCESSING)
+ meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_DELAYED_PROCESSING)
);
}
public HermesCounter topicDelayedProcessingCounter(TopicName topicName) {
return HermesCounters.from(
- micrometerCounter(TopicMetricsNames.TOPIC_DELAYED_PROCESSING, topicName),
- hermesMetrics.meter(Meters.TOPIC_DELAYED_PROCESSING, topicName)
+ micrometerCounter(TopicMetricsNames.TOPIC_DELAYED_PROCESSING, topicName)
);
}
public HermesCounter topicGlobalHttpStatusCodeCounter(int statusCode) {
return HermesCounters.from(
- meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_HTTP_STATUS_CODES, Tags.of("status_code", String.valueOf(statusCode))),
- hermesMetrics.httpStatusCodeMeter(statusCode)
+ meterRegistry.counter(TopicMetricsNames.TOPIC_GLOBAL_HTTP_STATUS_CODES, Tags.of("status_code", String.valueOf(statusCode)))
);
}
public HermesCounter topicHttpStatusCodeCounter(TopicName topicName, int statusCode) {
return HermesCounters.from(
meterRegistry.counter(TopicMetricsNames.TOPIC_HTTP_STATUS_CODES, topicTags(topicName)
- .and("status_code", String.valueOf(statusCode))),
- hermesMetrics.httpStatusCodeMeter(statusCode, topicName)
+ .and("status_code", String.valueOf(statusCode)))
);
}
public HermesCounter topicDuplicatedMessageCounter(TopicName topicName) {
return HermesCounters.from(
- micrometerCounter(TopicMetricsNames.TOPIC_DUPLICATED_MESSAGE, topicName),
- hermesMetrics.meter(Meters.TOPIC_DUPLICATED_MESSAGE, topicName)
+ micrometerCounter(TopicMetricsNames.TOPIC_DUPLICATED_MESSAGE, topicName)
);
}
public HermesHistogram topicGlobalMessageContentSizeHistogram() {
return DefaultHermesHistogram.of(
DistributionSummary.builder(TopicMetricsNames.TOPIC_GLOBAL_MESSAGE_SIZE_BYTES)
- .register(meterRegistry),
- hermesMetrics.messageContentSizeHistogram()
+ .register(meterRegistry)
);
}
@@ -145,8 +123,7 @@ public HermesHistogram topicMessageContentSizeHistogram(TopicName topicName) {
return DefaultHermesHistogram.of(
DistributionSummary.builder(TopicMetricsNames.TOPIC_MESSAGE_SIZE_BYTES)
.tags(topicTags(topicName))
- .register(meterRegistry),
- hermesMetrics.messageContentSizeHistogram(topicName)
+ .register(meterRegistry)
);
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TrackerElasticSearchMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TrackerElasticSearchMetrics.java
index b9643f5a30..657fb68c1e 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TrackerElasticSearchMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/TrackerElasticSearchMetrics.java
@@ -5,75 +5,52 @@
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;
private final GaugeRegistrar gaugeRegistrar;
- public TrackerElasticSearchMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
+ public TrackerElasticSearchMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.hermesMetrics = hermesMetrics;
- this.gaugeRegistrar = new GaugeRegistrar(meterRegistry, hermesMetrics);
+ this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerProducerTrackerElasticSearchQueueSizeGauge(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- Gauges.Graphite.PRODUCER_TRACKER_ELASTICSEARCH_QUEUE_SIZE,
- Gauges.Prometheus.TRACKER_ELASTICSEARCH_QUEUE_SIZE,
+ Gauges.TRACKER_ELASTICSEARCH_QUEUE_SIZE,
stateObj, f
);
}
public void registerProducerTrackerElasticSearchRemainingCapacity(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- Gauges.Graphite.PRODUCER_TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
- Gauges.Prometheus.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
+ Gauges.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
stateObj, f
);
}
public void registerConsumerTrackerElasticSearchQueueSizeGauge(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- Gauges.Graphite.CONSUMER_TRACKER_ELASTICSEARCH_QUEUE_SIZE,
- Gauges.Prometheus.TRACKER_ELASTICSEARCH_QUEUE_SIZE,
+ Gauges.TRACKER_ELASTICSEARCH_QUEUE_SIZE,
stateObj, f
);
}
public void registerConsumerTrackerElasticSearchRemainingCapacity(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- Gauges.Graphite.CONSUMER_TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
- Gauges.Prometheus.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
+ Gauges.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
stateObj, f
);
}
public HermesTimer trackerElasticSearchCommitLatencyTimer() {
return HermesTimer.from(
- meterRegistry.timer(Timers.ELASTICSEARCH_COMMIT_LATENCY),
- hermesMetrics.timer(Timers.ELASTICSEARCH_COMMIT_LATENCY)
+ meterRegistry.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";
- }
+ 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 {
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/UndeliveredMessagesMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/UndeliveredMessagesMetrics.java
index ca4edaa24e..3a286a0bf3 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/UndeliveredMessagesMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/UndeliveredMessagesMetrics.java
@@ -7,30 +7,23 @@
import pl.allegro.tech.hermes.metrics.HermesHistogram;
import pl.allegro.tech.hermes.metrics.counters.HermesCounters;
-import static pl.allegro.tech.hermes.common.metric.Histograms.PERSISTED_UNDELIVERED_MESSAGE_SIZE;
-import static pl.allegro.tech.hermes.common.metric.Meters.PERSISTED_UNDELIVERED_MESSAGES_METER;
-
public class UndeliveredMessagesMetrics {
- private final HermesMetrics hermesMetrics;
private final MeterRegistry meterRegistry;
- public UndeliveredMessagesMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ public UndeliveredMessagesMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}
public HermesCounter undeliveredMessagesCounter() {
return HermesCounters.from(
- meterRegistry.counter("undelivered-messages.persisted"),
- hermesMetrics.meter(PERSISTED_UNDELIVERED_MESSAGES_METER)
+ meterRegistry.counter("undelivered-messages.persisted")
);
}
public HermesHistogram undeliveredMessagesSizeHistogram() {
return DefaultHermesHistogram.of(
DistributionSummary.builder("undelivered-messages.persisted.message-size.bytes")
- .register(meterRegistry),
- hermesMetrics.histogram(PERSISTED_UNDELIVERED_MESSAGE_SIZE)
+ .register(meterRegistry)
);
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/WorkloadMetrics.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/WorkloadMetrics.java
index 7c2e840d0f..1faa3486c3 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/WorkloadMetrics.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/WorkloadMetrics.java
@@ -14,27 +14,17 @@ public class WorkloadMetrics {
private static final String CONSUMER_ID_TAG = "consumer-id";
private static final String KAFKA_CLUSTER_TAG = "kafka-cluster";
- private static final String METRICS_PREFIX = "consumer-workload.weighted.";
- private static final String CONSUMER_ID_PLACEHOLDER = "$consumerId";
- private static final String CURRENT_SCORE = METRICS_PREFIX + CONSUMER_ID_PLACEHOLDER + ".current-score";
- private static final String PROPOSED_SCORE = METRICS_PREFIX + CONSUMER_ID_PLACEHOLDER + ".proposed-score";
- private static final String SCORING_ERROR = METRICS_PREFIX + CONSUMER_ID_PLACEHOLDER + ".error";
- private static final String CURRENT_WEIGHT_OPS = METRICS_PREFIX + CONSUMER_ID_PLACEHOLDER + ".current-weight.ops";
- private static final String PROPOSED_WEIGHT_OPS = METRICS_PREFIX + CONSUMER_ID_PLACEHOLDER + ".proposed-weight.ops";
-
- private final HermesMetrics hermesMetrics;
+
private final MeterRegistry meterRegistry;
private final GaugeRegistrar gaugeRegistrar;
- WorkloadMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) {
- this.hermesMetrics = hermesMetrics;
+ WorkloadMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
- this.gaugeRegistrar = new GaugeRegistrar(meterRegistry, hermesMetrics);
+ this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerAllAssignmentsGauge(T obj, String kafkaCluster, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- "consumers-workload." + kafkaCluster + ".all-assignments",
"workload.all-assignments",
obj,
f,
@@ -44,7 +34,6 @@ public void registerAllAssignmentsGauge(T obj, String kafkaCluster, ToDouble
public void registerMissingResourcesGauge(T obj, String kafkaCluster, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- "consumers-workload." + kafkaCluster + ".missing-resources",
"workload.missing-resources",
obj,
f,
@@ -54,7 +43,6 @@ public void registerMissingResourcesGauge(T obj, String kafkaCluster, ToDoub
public void registerDeletedAssignmentsGauge(T obj, String kafkaCluster, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- "consumers-workload." + kafkaCluster + ".deleted-assignments",
"workload.deleted-assignments",
obj,
f,
@@ -64,7 +52,6 @@ public void registerDeletedAssignmentsGauge(T obj, String kafkaCluster, ToDo
public void registerCreatedAssignmentsGauge(T obj, String kafkaCluster, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- "consumers-workload." + kafkaCluster + ".created-assignments",
"workload.created-assignments",
obj,
f,
@@ -74,38 +61,36 @@ public void registerCreatedAssignmentsGauge(T obj, String kafkaCluster, ToDo
public HermesTimer rebalanceDurationTimer(String kafkaCluster) {
return HermesTimer.from(
- meterRegistry.timer("workload.rebalance-duration", Tags.of(KAFKA_CLUSTER_TAG, kafkaCluster)),
- hermesMetrics.consumersWorkloadRebalanceDurationTimer(kafkaCluster)
+ meterRegistry.timer("workload.rebalance-duration", Tags.of(KAFKA_CLUSTER_TAG, kafkaCluster))
);
}
public void registerRunningSubscriptionsGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge("consumers-workload.monitor.running", "workload.subscriptions.running", obj, f);
+ gaugeRegistrar.registerGauge("workload.subscriptions.running", obj, f);
}
public void registerAssignedSubscriptionsGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge("consumers-workload.monitor.assigned", "workload.subscriptions.assigned", obj, f);
+ gaugeRegistrar.registerGauge("workload.subscriptions.assigned", obj, f);
}
public void registerMissingSubscriptionsGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge("consumers-workload.monitor.missing", "workload.subscriptions.missing", obj, f);
+ gaugeRegistrar.registerGauge("workload.subscriptions.missing", obj, f);
}
public void registerOversubscribedGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge("consumers-workload.monitor.oversubscribed", "workload.subscriptions.oversubscribed", obj, f);
+ gaugeRegistrar.registerGauge("workload.subscriptions.oversubscribed", obj, f);
}
public void registerOperationsPerSecondGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge("consumer-workload.weighted.load.ops", "workload.weighted.ops", obj, f);
+ gaugeRegistrar.registerGauge("workload.weighted.ops", obj, f);
}
public void registerCpuUtilizationGauge(T obj, ToDoubleFunction f) {
- gaugeRegistrar.registerGauge("consumer-workload.weighted.load.cpu-utilization", "workload.weighted.cpu-utilization", obj, f);
+ gaugeRegistrar.registerGauge("workload.weighted.cpu-utilization", obj, f);
}
public void registerCurrentScoreGauge(String consumerId, T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- buildFullGraphiteMetricPath(CURRENT_SCORE, consumerId),
"workload.weighted.current-score",
obj,
f,
@@ -115,7 +100,6 @@ public void registerCurrentScoreGauge(String consumerId, T obj, ToDoubleFunc
public void registerProposedErrorGauge(String consumerId, T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- buildFullGraphiteMetricPath(PROPOSED_SCORE, consumerId),
"workload.weighted.proposed-error",
obj,
f,
@@ -125,7 +109,6 @@ public void registerProposedErrorGauge(String consumerId, T obj, ToDoubleFun
public void registerScoringErrorGauge(String consumerId, T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- buildFullGraphiteMetricPath(SCORING_ERROR, consumerId),
"workload.weighted.scoring-error",
obj,
f,
@@ -135,7 +118,6 @@ public void registerScoringErrorGauge(String consumerId, T obj, ToDoubleFunc
public void registerCurrentWeightGauge(String consumerId, T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- buildFullGraphiteMetricPath(CURRENT_WEIGHT_OPS, consumerId),
"workload.weighted.current-weight.ops",
obj,
f,
@@ -145,7 +127,6 @@ public void registerCurrentWeightGauge(String consumerId, T obj, ToDoubleFun
public void registerProposedWeightGauge(String consumerId, T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
- buildFullGraphiteMetricPath(PROPOSED_WEIGHT_OPS, consumerId),
"workload.weighted.proposed-weight.ops",
obj,
f,
@@ -161,16 +142,5 @@ public void unregisterAllWorkloadWeightedGaugesForConsumerIds(Set consum
for (Gauge gauge : gauges) {
meterRegistry.remove(gauge);
}
- for (String consumerId : consumerIds) {
- hermesMetrics.unregister(buildFullGraphiteMetricPath(CURRENT_SCORE, consumerId));
- hermesMetrics.unregister(buildFullGraphiteMetricPath(PROPOSED_SCORE, consumerId));
- hermesMetrics.unregister(buildFullGraphiteMetricPath(SCORING_ERROR, consumerId));
- hermesMetrics.unregister(buildFullGraphiteMetricPath(CURRENT_WEIGHT_OPS, consumerId));
- hermesMetrics.unregister(buildFullGraphiteMetricPath(PROPOSED_WEIGHT_OPS, consumerId));
- }
- }
-
- private String buildFullGraphiteMetricPath(String metric, String consumerId) {
- return metric.replace(CONSUMER_ID_PLACEHOLDER, HermesMetrics.escapeDots(consumerId));
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/counter/zookeeper/ZookeeperCounterReporter.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/counter/zookeeper/ZookeeperCounterReporter.java
index c66efdc640..3293bea92b 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/counter/zookeeper/ZookeeperCounterReporter.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/counter/zookeeper/ZookeeperCounterReporter.java
@@ -7,8 +7,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.allegro.tech.hermes.api.TopicName;
-import pl.allegro.tech.hermes.common.metric.HermesMetrics;
import pl.allegro.tech.hermes.common.metric.counter.CounterStorage;
+import pl.allegro.tech.hermes.metrics.PathsCompiler;
import java.util.Collection;
import java.util.concurrent.Executors;
@@ -101,6 +101,6 @@ private static TopicName escapedTopicName(TopicName topicName) {
}
private static String escapeMetricsReplacementChar(String value) {
- return value.replaceAll(HermesMetrics.REPLACEMENT_CHAR, "\\.");
+ return value.replaceAll(PathsCompiler.REPLACEMENT_CHAR, "\\.");
}
}
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/executor/InstrumentedExecutorServiceFactory.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/executor/InstrumentedExecutorServiceFactory.java
index 621876228e..08a69b7936 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/executor/InstrumentedExecutorServiceFactory.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/executor/InstrumentedExecutorServiceFactory.java
@@ -33,23 +33,51 @@ public ExecutorService getExecutorService(String name, int size, boolean monitor
return monitoringEnabled ? monitor(name, executor) : executor;
}
- public ScheduledExecutorService getScheduledExecutorService(
- String name, int size, boolean monitoringEnabled
- ) {
- ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name + "-scheduled-executor-%d").build();
- ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(size, threadFactory);
- return monitoringEnabled ? monitor(name, executor) : executor;
+ public class ScheduledExecutorServiceBuilder {
+ final String name;
+ final int size;
+ boolean monitoringEnabled = false;
+ boolean removeOnCancel = false;
+
+ public ScheduledExecutorServiceBuilder(String name, int size) {
+ this.name = name;
+ this.size = size;
+ }
+
+ public ScheduledExecutorServiceBuilder withMonitoringEnabled(boolean monitoringEnabled) {
+ this.monitoringEnabled = monitoringEnabled;
+ return this;
+ }
+
+ public ScheduledExecutorServiceBuilder withRemoveOnCancel(boolean removeOnCancel) {
+ this.removeOnCancel = removeOnCancel;
+ return this;
+ }
+
+ public ScheduledExecutorService create() {
+ ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name + "-scheduled-executor-%d").build();
+ ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(size, threadFactory);
+ executor.setRemoveOnCancelPolicy(removeOnCancel);
+ return monitoringEnabled ? monitor(name, executor) : executor;
+ }
+
+ private ScheduledExecutorService monitor(String threadPoolName, ScheduledExecutorService executor) {
+ return metricsFacade.executor().monitor(executor, threadPoolName);
+ }
}
- private ExecutorService monitor(String threadPoolName, ExecutorService executor) {
- return metricsFacade.executor().monitor(executor, threadPoolName);
+ public ScheduledExecutorServiceBuilder scheduledExecutorBuilder(
+ String name, int size
+ ) {
+ return new ScheduledExecutorServiceBuilder(name, size);
}
- private ScheduledExecutorService monitor(String threadPoolName, ScheduledExecutorService executor) {
+ private ExecutorService monitor(String threadPoolName, ExecutorService executor) {
return metricsFacade.executor().monitor(executor, threadPoolName);
}
+
/**
* Copy of {@link java.util.concurrent.Executors#newFixedThreadPool(int, java.util.concurrent.ThreadFactory)}
* with configurable queue capacity.
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/schema/RawSchemaClientFactory.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/schema/RawSchemaClientFactory.java
index e4bf8933cc..028d649399 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/common/schema/RawSchemaClientFactory.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/common/schema/RawSchemaClientFactory.java
@@ -1,7 +1,6 @@
package pl.allegro.tech.hermes.common.schema;
import com.fasterxml.jackson.databind.ObjectMapper;
-import pl.allegro.tech.hermes.common.metric.HermesMetrics;
import pl.allegro.tech.hermes.common.metric.MetricsFacade;
import pl.allegro.tech.hermes.schema.RawSchemaClient;
import pl.allegro.tech.hermes.schema.SubjectNamingStrategy;
diff --git a/hermes-common/src/main/java/pl/allegro/tech/hermes/domain/filtering/avro/AvroPathPredicate.java b/hermes-common/src/main/java/pl/allegro/tech/hermes/domain/filtering/avro/AvroPathPredicate.java
index f49a22d7ba..7cd000a2e5 100644
--- a/hermes-common/src/main/java/pl/allegro/tech/hermes/domain/filtering/avro/AvroPathPredicate.java
+++ b/hermes-common/src/main/java/pl/allegro/tech/hermes/domain/filtering/avro/AvroPathPredicate.java
@@ -1,5 +1,6 @@
package pl.allegro.tech.hermes.domain.filtering.avro;
+import jakarta.annotation.Nullable;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericArray;
import org.apache.avro.generic.GenericRecord;
@@ -26,7 +27,7 @@
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyListIterator;
import static java.util.Collections.singletonList;
-import static org.apache.commons.lang.StringUtils.strip;
+import static org.apache.commons.lang3.StringUtils.strip;
import static pl.allegro.tech.hermes.common.message.converter.AvroRecordToBytesConverter.bytesToRecord;
import static pl.allegro.tech.hermes.domain.filtering.FilteringException.check;
@@ -62,7 +63,7 @@ public boolean test(final FilterableMessage message) {
}
private List