Skip to content

Commit

Permalink
feat(e2e): Update prometheus e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer committed Mar 31, 2023
1 parent 413b4d8 commit cbfc190
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions e2e/yaks/openshift/monitoring/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.microprofile.metrics.MicroProfileMetricsConstants;
import org.apache.camel.component.micrometer.MicrometerConstants;

import javax.enterprise.context.ApplicationScoped;

Expand Down Expand Up @@ -51,27 +51,27 @@ public void configure() {
.logStackTrace(false)
.logExhausted(false)
.log(LoggingLevel.ERROR, "Failed processing ${body}")
.to("microprofile-metrics:meter:camel-k-example-metrics-redelivery?mark=2")
.to("micrometer:counter:camel-k-example-metrics-redelivery?increment=2")
// The 'error' meter
.to("microprofile-metrics:meter:camel-k-example-metrics-error");
.to("micrometer:counter:camel-k-example-metrics-error");

from("timer:stream?period=1000")
.routeId("unreliable-service")
.setBody(header(Exchange.TIMER_COUNTER).prepend("event #"))
.log("Processing ${body}...")
// The 'generated' meter
.to("microprofile-metrics:meter:camel-k-example-metrics-generated")
.to("micrometer:counter:camel-k-example-metrics-generated")
// TODO: replace with lookup by type as soon as CAMEL-15217 gets fixed
// The 'attempt' meter via @Metered interceptor
// The 'attempt' meter via @Counted interceptor
.bean("service")
.filter(header(Exchange.REDELIVERED))
.log(LoggingLevel.WARN, "Processed ${body} after ${header.CamelRedeliveryCounter} retries")
.setHeader(MicroProfileMetricsConstants.HEADER_METER_MARK, header(Exchange.REDELIVERY_COUNTER))
.setHeader(MicrometerConstants.HEADER_COUNTER_INCREMENT, header(Exchange.REDELIVERY_COUNTER))
// The 'redelivery' meter
.to("microprofile-metrics:meter:camel-k-example-metrics-redelivery")
.to("micrometer:counter:camel-k-example-metrics-redelivery")
.end()
.log("Successfully processed ${body}")
// The 'success' meter
.to("microprofile-metrics:meter:camel-k-example-metrics-success");
.to("micrometer:counter:camel-k-example-metrics-success");
}
}
6 changes: 5 additions & 1 deletion e2e/yaks/openshift/monitoring/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-metrics</artifactId>
<artifactId>camel-quarkus-micrometer</artifactId>
<version>${version.camel.quarkus}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@

import java.util.Random;

import io.micrometer.core.annotation.Counted;

import org.apache.camel.Exchange;
import org.apache.camel.RuntimeExchangeException;

import org.eclipse.microprofile.metrics.Gauge;
import org.eclipse.microprofile.metrics.Meter;

import org.eclipse.microprofile.metrics.annotation.Metered;
import org.eclipse.microprofile.metrics.annotation.Metric;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;

Expand All @@ -39,7 +35,7 @@
@io.quarkus.arc.Unremovable
public class Service {

@Metered(name = "camel-k-example-metrics-attempt", absolute = true)
@Counted(value = "camel-k-example-metrics-attempt")
public void attempt(Exchange exchange) {
Random rand = new Random();
if (rand.nextDouble() < 0.5) {
Expand Down

0 comments on commit cbfc190

Please sign in to comment.