From 01aaed1ede1305902846b7b981b64230a810bd6f Mon Sep 17 00:00:00 2001 From: Luigi De Masi Date: Thu, 25 Jul 2024 16:14:13 +0200 Subject: [PATCH] Added rules for capturing Apache Camel metrics exposed by jmx MBean --- .../jmx-metrics/javaagent/README.md | 1 + .../jmx-metrics/javaagent/camel.md | 51 ++++ .../src/main/resources/jmx/rules/camel.yaml | 263 ++++++++++++++++++ .../jmx/JmxMetricInsightInstallerTest.java | 1 + 4 files changed, 316 insertions(+) create mode 100644 instrumentation/jmx-metrics/javaagent/camel.md create mode 100644 instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/camel.yaml diff --git a/instrumentation/jmx-metrics/javaagent/README.md b/instrumentation/jmx-metrics/javaagent/README.md index 8680e878814e..844137872f82 100644 --- a/instrumentation/jmx-metrics/javaagent/README.md +++ b/instrumentation/jmx-metrics/javaagent/README.md @@ -26,6 +26,7 @@ $ java -javaagent:path/to/opentelemetry-javaagent.jar \ No targets are enabled by default. The supported target environments are listed below. - [activemq](activemq.md) +- [camel](camel.md) - [jetty](jetty.md) - [kafka-broker](kafka-broker.md) - [tomcat](tomcat.md) diff --git a/instrumentation/jmx-metrics/javaagent/camel.md b/instrumentation/jmx-metrics/javaagent/camel.md new file mode 100644 index 000000000000..724fb488aa2c --- /dev/null +++ b/instrumentation/jmx-metrics/javaagent/camel.md @@ -0,0 +1,51 @@ +# Camel Metrics + +Here is the list of metrics based on MBeans exposed by Camel. + +| Metric Name | Type | Attributes | Description | +|------------------------------------------------|---------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| camel.context.exchange | Counter | context, camelVersion | Indicates the total number of exchanges, passed or failed, processed since context start-up or the last reset operation. | +| camel.context.exchange.completed | Counter | context, camelVersion | Indicates the total number of exchanges processed successfully since context start-up or the last reset operation. | +| camel.context.exchange.failed | Counter | context, camelVersion | Indicates the total number of exchanges that failed to process since context start-up or the last reset operation. | +| camel.context.exchange.failed_handled | Counter | context, camelVersion | Indicates the number of exchanges failed and handled by an ExceptionHandler in the context. | +| camel.context.exchange.inflight | UpDownCounter | context, camelVersion | Indicates the number of exchanges currently transiting the context. | +| camel.context.exchange.processing.delta_time | Gauge | context, camelVersion | Indicates the difference, in milliseconds, of the Processing Time of the last two exchanges transited the context. | +| camel.context.exchange.processing.last_time | Gauge | context, camelVersion | Indicates the time, in milliseconds, it took to process the last exchange. | +| camel.context.exchange.processing.max_time | Gauge | context, camelVersion | Indicates the longest time, in milliseconds, to process an exchange since context start-up or the last reset operation. | +| camel.context.exchange.processing.mean_time | Gauge | context, camelVersion | Indicates the mean processing time, in milliseconds, for all exchanges processed since context start-up or the last reset operation. | +| camel.context.exchange.processing.min_time | Gauge | context, camelVersion | Indicates the shortest time, in milliseconds, to process an exchange since context start-up or the last reset operation. | +| camel.context.exchange.processing.time | Counter | context, camelVersion | Indicates the total processing time, in milliseconds, to process all exchanges since context start-up or the last reset operation. | +| camel.context.exchange.redelivered | Counter | context, camelVersion | Number of exchanges redelivered (internal only) since context start-up or the last reset operation. | +| camel.context.exchange.redelivered_external | Counter | context, camelVersion | The total number of all external initiated redeliveries (such as from JMS broker) since context start-up or the last reset operation. | +| camel.route.exchange | Counter | context, route | Indicates the total number of exchanges, passed or failed, that the route has processed since route start-up or the last reset operation. | +| camel.route.exchange.completed | Counter | context, route | Indicates the total number of exchanges the route has processed successfully since route start-up or the last reset operation. | +| camel.route.exchange.failed | Counter | context, route | Indicates the total number of exchanges that the route has failed to process since route start-up or the last reset operation. | +| camel.route.exchange.failed_handled | Counter | context, route | Indicates the number of exchanges failed and handled by an ExceptionHandler in the route. | +| camel.route.exchange.inflight | UpDownCounter | context, route | Indicates the number of exchanges currently transiting the route. | +| camel.route.exchange.processing.delta_time | Gauge | context, route | Indicates the difference, in milliseconds, of the Processing Time of the last two exchanges transited the route. | +| camel.route.exchange.processing.last_time | Gauge | context, route | Indicates the time, in milliseconds, it took the route to process the last exchange. | +| camel.route.exchange.processing.max_time | Gauge | context, route | Indicates the longest time, in milliseconds, to process an exchange since the route start-up or the last reset operation. | +| camel.route.exchange.processing.mean_time | Gauge | context, route | Indicates the mean processing time, in milliseconds, for all exchanges processed since the route start-up or the last reset operation. | +| camel.route.exchange.processing.min_time | Gauge | context, route | Indicates the shortest time, in milliseconds, to process an exchange since the route start-up or the last reset operation. | +| camel.route.exchange.processing.time | Counter | context, route | Indicates the total processing time, in milliseconds, of all exchanges the selected processed since route start-up or the last reset operation. | +| camel.route.exchange.redelivered | Counter | context, route | Number of exchanges redelivered (internal only) since route start-up or the last reset operation. | +| camel.route.exchange.redelivered_external | Counter | context, route | The total number of all external initiated redeliveries (such as from JMS broker) since the route start-up or the last reset operation. | +| camel.processor.exchange | Counter | context, route, processor, destination | Indicates the total number of exchanges, passed or failed, that the selected processor has processed since processor start-up or the last reset operation. | +| camel.processor.exchange.completed | Counter | context, route, processor, destination | Indicates the total number of exchanges the selected processor has processed successfully since processor start-up or the last reset operation. | +| camel.processor.exchange.failed | Counter | context, route, processor, destination | Indicates the total number of exchanges that the selected processor has failed to process since processor start-up or the last reset operation. | +| camel.processor.exchange.inflight | UpDownCounter | context, route, processor, destination | Indicates the number of exchanges currently transiting the processor. | +| camel.processor.exchange.failed_handled | Counter | context, route, processor, destination | Indicates the number of exchanges failed and handled by an ExceptionHandler in the context. | +| camel.processor.exchange.processing.delta_time | Gauge | context, route, processor, destination | Indicates the difference, in milliseconds, of the Processing Time of the last two exchanges transited the selected processor. | +| camel.processor.exchange.processing.last_time | Gauge | context, route, processor, destination | Indicates the time, in milliseconds, it took the selected processor to process the last exchange. | +| camel.processor.exchange.processing.max_time | Gauge | context, route, processor, destination | Indicates the longest time, in milliseconds, to process an exchange since processor start-up or the last reset operation. | +| camel.processor.exchange.processing.mean_time | Gauge | context, route, processor, destination | Indicates the mean processing time, in milliseconds, for all exchanges processed since processor start-up or the last reset operation. | +| camel.processor.exchange.processing.min_time | Gauge | context, route, processor, destination | Indicates the shortest time, in milliseconds, to process an exchange since processor start-up or the last reset operation. | +| camel.processor.exchange.processing.time | Counter | context, route, processor, destination | Indicates the total processing time, in milliseconds, to process all exchanges since start-up or the last reset operation. | +| camel.processor.exchange.redelivered | Counter | context, route, processor, destination | Number of exchanges redelivered (internal only) since selected processor start-up or the last reset operation. | +| camel.processor.exchange.redelivered_external | Counter | context, route, processor, destination | The total number of all external initiated redeliveries (such as from JMS broker) since processor start-up or the last reset operation. | +| camel.threadpool.active | UpDownCounter | context, route | The approximate number of threads that are actively executing tasks. | +| camel.threadpool.pool.size | UpDownCounter | context, route | The current number of threads in the pool. | +| camel.threadpool.pool.largest_size | Gauge | context, route | The largest number of threads that have ever simultaneously been in the pool. | +| camel.threadpool.task | Counter | context, route | The approximate total number of tasks that have ever been scheduled for execution. | +| camel.threadpool.task.completed | Counter | context, route | The approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls. | +| camel.threadpool.task.queue_size | UpDownCounter | context, route | The number of Tasks in the Task Queue. | diff --git a/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/camel.yaml b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/camel.yaml new file mode 100644 index 000000000000..a34fa04a437f --- /dev/null +++ b/instrumentation/jmx-metrics/javaagent/src/main/resources/jmx/rules/camel.yaml @@ -0,0 +1,263 @@ +--- +rules: + - bean: org.apache.camel:context=*,type=context,name=* + prefix: camel.context. + metricAttribute: + context: param(context) + camelVersion: beanattr(CamelVersion) + mapping: + ExchangesCompleted: + metric: exchange.completed + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges processed successfully since context start-up or the last reset operation. + ExchangesFailed: + metric: exchange.failed + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges that failed to process since context start-up or the last reset operation. + ExchangesInflight: + metric: exchange.inflight + type: updowncounter + unit: "{exchanges}" + desc: Indicates the number of exchanges currently transiting the context. + ExchangesTotal: + metric: exchange + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges, passed or failed, processed context start-up or the last reset operation. + FailuresHandled: + metric: exchange.failed_handled + unit: "{exchanges}" + type: counter + desc: Indicates the number of exchanges failed and handled by an ExceptionHandler in the context. + Redeliveries: + metric: exchange.redelivered + type: counter + unit: "{exchanges}" + desc: Number of exchanges redelivered (internal only) since context start-up or the last reset operation. + ExternalRedeliveries: + metric: exchange.redelivered_external + type: counter + unit: "{exchanges}" + desc: The total number of all external initiated redeliveries (such as from JMS broker) since context start-up or the last reset operation. + MaxProcessingTime: + metric: exchange.processing.max_time + unit: ms + type: gauge + desc: Indicates the longest time, in milliseconds, to process an exchange since context start-up or the last reset operation. + MeanProcessingTime: + metric: exchange.processing.mean_time + type: gauge + unit: ms + desc: Indicates the mean processing time, in milliseconds, for all exchanges processed since context start-up or the last reset operation. + MinProcessingTime: + metric: exchange.processing.min_time + unit: ms + type: gauge + desc: Indicates the shortest time, in milliseconds, to process an exchange since context start-up or the last reset operation. + LastProcessingTime: + metric: exchange.processing.last_time + unit: ms + type: gauge + desc: Indicates the time, in milliseconds, it took to process the last exchange. + DeltaProcessingTime: + metric: exchange.processing.delta_time + type: gauge + unit: ms + desc: Indicates the difference, in milliseconds, of the Processing Time of the last two exchanges transited the context. + TotalProcessingTime: + metric: exchange.processing.time + type: counter + unit: ms + desc: Indicates the total processing time, in milliseconds, to process all exchanges since context start-up or the last reset operation. + +# Route Level metrics + + - bean: org.apache.camel:context=*,type=routes,name=* + prefix: camel.route. + metricAttribute: + route: beanattr(RouteId) + context: param(context) + mapping: + ExchangesCompleted: + metric: exchange.completed + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges the route has processed successfully since route start-up or the last reset operation. + ExchangesFailed: + metric: exchange.failed + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges that the route has failed to process since route start-up or the last reset operation. + ExchangesInflight: + metric: exchange.inflight + type: updowncounter + unit: "{exchanges}" + desc: Indicates the number of exchanges currently transiting the route. + ExchangesTotal: + metric: exchange + unit: "{exchanges}" + type: counter + desc: Indicates the total number of exchanges, passed or failed, that the route has processed since route start-up or the last reset operation. + FailuresHandled: + metric: exchange.failed_handled + unit: "{exchanges}" + type: counter + desc: Indicates the number of exchanges failed and handled by an ExceptionHandler in the route. + ExternalRedeliveries: + metric: exchange.redelivered_external + unit: "{exchanges}" + type: counter + desc: The total number of all external initiated redeliveries (such as from JMS broker) since the route start-up or the last reset operation. + Redeliveries: + metric: exchange.redelivered + type: counter + unit: "{exchanges}" + desc: Number of exchanges redelivered (internal only) since route start-up or the last reset operation. + MaxProcessingTime: + metric: exchange.processing.max_time + unit: ms + type: gauge + desc: Indicates the longest time, in milliseconds, to process an exchange since the route start-up or the last reset operation. + MeanProcessingTime: + metric: exchange.processing.mean_time + unit: ms + type: gauge + desc: Indicates the mean processing time, in milliseconds, for all exchanges processed since the route start-up or the last reset operation. + MinProcessingTime: + metric: exchange.processing.min_time + type: gauge + unit: ms + desc: Indicates the shortest time, in milliseconds, to process an exchange since the route start-up or the last reset operation. + LastProcessingTime: + metric: exchange.processing.last_time + type: gauge + unit: ms + desc: Indicates the time, in milliseconds, it took the route to process the last exchange. + DeltaProcessingTime: + metric: exchange.processing.delta_time + type: gauge + unit: ms + desc: Indicates the difference, in milliseconds, of the Processing Time of the last two exchanges transited the route. + TotalProcessingTime: + metric: exchange.processing.time + type: counter + unit: ms + desc: Indicates the total processing time, in milliseconds, of all exchanges the selected processed since route start-up or the last reset operation. + + +# Processor level Metrics + + - bean: org.apache.camel:context=*,type=processors,name=* + prefix: camel.processor. + metricAttribute: + processor: beanattr(ProcessorId) + route: beanattr(RouteId) + context: param(context) + destination: beanattr(Destination) + mapping: + ExchangesCompleted: + metric: exchange.completed + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges the selected processor has processed successfully since processor start-up or the last reset operation. + ExchangesFailed: + metric: exchange.failed + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges that the selected processor has failed to process since processor start-up or the last reset operation. + ExchangesInflight: + metric: exchange.inflight + type: updowncounter + unit: "{exchanges}" + desc: Indicates the number of exchanges currently transiting the processor. + ExchangesTotal: + metric: exchange + type: counter + unit: "{exchanges}" + desc: Indicates the total number of exchanges, passed or failed, that the selected processor has processed since processor start-up or the last reset operation. + FailuresHandled: + metric: exchange.failed_handled + unit: "{exchanges}" + type: counter + desc: Indicates the number of exchanges failed and handled by an ExceptionHandler in the context. + ExternalRedeliveries: + metric: exchange.redelivered_external + type: counter + unit: "{exchanges}" + desc: The total number of all external initiated redeliveries (such as from JMS broker) since processor start-up or the last reset operation. + Redeliveries: + metric: exchange.redelivered + type: counter + unit: "{exchanges}" + desc: Number of exchanges redelivered (internal only) since selected processor start-up or the last reset operation. + MaxProcessingTime: + metric: exchange.processing.max_time + unit: ms + type: gauge + desc: Indicates the longest time, in milliseconds, to process an exchange since processor start-up or the last reset operation. + MeanProcessingTime: + metric: exchange.processing.mean_time + type: gauge + unit: ms + desc: Indicates the mean processing time, in milliseconds, for all exchanges processed since processor start-up or the last reset operation. + MinProcessingTime: + metric: exchange.processing.min_time + type: gauge + unit: ms + desc: Indicates the shortest time, in milliseconds, to process an exchange since processor start-up or the last reset operation. + LastProcessingTime: + metric: exchange.processing.last_time + type: gauge + unit: ms + desc: Indicates the time, in milliseconds, it took the selected processor to process the last exchange. + DeltaProcessingTime: + metric: exchange.processing.delta_time + type: gauge + unit: ms + desc: Indicates the difference, in milliseconds, of the Processing Time of the last two exchanges transited the selected processor. + TotalProcessingTime: + metric: exchange.processing.time + type: counter + unit: ms + desc: Indicates the total processing time, in milliseconds, to process all exchanges since start-up or the last reset operation. + + + + - bean: org.apache.camel:context=*,type=threadpools,name=* + prefix: camel.threadpool. + metricAttribute: + route: beanattr(RouteId) + context: param(context) + mapping: + ActiveCount: + metric: active + type: updowncounter + unit: "{threads}" + desc: The approximate number of threads that are actively executing tasks. + CompletedTaskCount: + metric: task.completed + type: counter + unit: "{tasks}" + desc: The approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls. + PoolSize: + metric: pool.size + type: updowncounter + unit: "{threads}" + desc: The current number of threads in the pool. + LargestPoolSize: + metric: pool.largest_size + type: gauge + unit: "{threads}" + desc: The largest number of threads that have ever simultaneously been in the pool. + TaskCount: + metric: task + type: counter + unit: "{tasks}" + desc: The approximate total number of tasks that have ever been scheduled for execution. + TaskQueueSize: + metric: task.queue_size + type: updowncounter + unit: "{threads}" + desc: The number of Tasks in the Task Queue. diff --git a/instrumentation/jmx-metrics/javaagent/src/test/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstallerTest.java b/instrumentation/jmx-metrics/javaagent/src/test/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstallerTest.java index 0853505ae98b..253583660ddd 100644 --- a/instrumentation/jmx-metrics/javaagent/src/test/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstallerTest.java +++ b/instrumentation/jmx-metrics/javaagent/src/test/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstallerTest.java @@ -28,6 +28,7 @@ class JmxMetricInsightInstallerTest { new HashSet<>( Arrays.asList( "activemq.yaml", + "camel.yaml", "hadoop.yaml", "jetty.yaml", "kafka-broker.yaml",