You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/10/13 12:59:19 UTC

[camel] branch main updated: Changes to micrometer-component.adoc (#2311) (#11715)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new b8620d83c3a Changes to micrometer-component.adoc (#2311) (#11715)
b8620d83c3a is described below

commit b8620d83c3a913e5062213782fb457b774716b3c
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Fri Oct 13 14:59:11 2023 +0200

    Changes to micrometer-component.adoc (#2311) (#11715)
    
    Co-authored-by: Andreas Jonsson <10...@users.noreply.github.com>
---
 .../src/main/docs/micrometer-component.adoc        | 89 +++++++---------------
 1 file changed, 26 insertions(+), 63 deletions(-)

diff --git a/components/camel-micrometer/src/main/docs/micrometer-component.adoc b/components/camel-micrometer/src/main/docs/micrometer-component.adoc
index ccc211b4303..70284236a27 100644
--- a/components/camel-micrometer/src/main/docs/micrometer-component.adoc
+++ b/components/camel-micrometer/src/main/docs/micrometer-component.adoc
@@ -73,62 +73,10 @@ You should define a dedicated registry by providing
 a `MeterRegistry` bean. Micrometer registries primarily determine the backend monitoring system
 to be used. A `CompositeMeterRegistry` can be used to address more than one monitoring target.
 
-For example using Spring Java Configuration:
 
-[source,java]
-----
-@Configuration
-public static class MyConfig extends SingleRouteCamelConfiguration {
-
-    @Bean
-    @Override
-    public RouteBuilder route() {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                // define Camel routes here
-            }
-        };
-    }
-
-    @Bean(name = MicrometerConstants.METRICS_REGISTRY_NAME)
-    public MeterRegistry getMeterRegistry() {
-        CompositeMeterRegistry registry = ...;
-        registry.add(...);
-        // ...
-        return registry;
-    }
-}
-----
-
-Or using CDI:
-
-[source,java]
-----
-class MyBean extends RouteBuilder {
-
-    @Override
-    public void configure() {
-      from("...")
-          // Register the 'my-meter' meter in the MetricRegistry below
-          .to("micrometer:meter:my-meter");
-    }
-
-    @Produces
-    // If multiple MetricRegistry beans
-    // @Named(MicrometerConstants.METRICS_REGISTRY_NAME)
-    MetricRegistry registry() {
-        CompositeMeterRegistry registry = ...;
-        registry.add(...);
-        // ...
-        return registry;
-    }
-}
-----
 
 == Default Camel Metrics
 
-
 Some Camel specific metrics are available out of the box.
 
 [width="100%",options="header"]
@@ -496,8 +444,7 @@ MicrometerMessageHistoryService service = context.hasService(MicrometerMessageHi
 String json = service.dumpStatisticsAsJson();
 ----
 
-If JMX is enabled in the CamelContext, the MBean is registered in the `type=services` tree
-with `name=MicrometerMessageHistory`.
+If JMX is enabled in the CamelContext, the MBean is registered in the `type=services` tree with `name=MicrometerMessageHistory`.
 
 
 == Micrometer event notification
@@ -537,9 +484,7 @@ See more details at Advanced configuration of CamelContext using Spring.
 
 == Exposing Micrometer statistics in JMX
 
-Micrometer uses `MeterRegistry` implementations in order to publish statistics. While in production scenarios
-it is advisable to select a dedicated backend like Prometheus or Graphite, it may be sufficient for
-test or local deployments to publish statistics to JMX.
+Micrometer uses `MeterRegistry` implementations in order to publish statistics. While in production scenarios it is advisable to select a dedicated backend like Prometheus or Graphite, it may be sufficient for test or local deployments to publish statistics to JMX.
 
 In order to achieve this, add the following dependency:
 
@@ -554,9 +499,12 @@ In order to achieve this, add the following dependency:
 
 and add a `JmxMeterRegistry` instance:
 
+[tabs]
+====
+Java::
++
 [source,java]
 ----
-
     @Bean(name = MicrometerConstants.METRICS_REGISTRY_NAME)
     public MeterRegistry getMeterRegistry() {
         CompositeMeterRegistry meterRegistry = new CompositeMeterRegistry();
@@ -567,17 +515,32 @@ and add a `JmxMeterRegistry` instance:
            HierarchicalNameMapper.DEFAULT));
         return meterRegistry;
     }
-}
 ----
 
-The `HierarchicalNameMapper` strategy determines how meter name and tags are assembled into
-an MBean name.
+CDI::
++
+[source,java]
+----
+    @Produces
+    @Named(MicrometerConstants.METRICS_REGISTRY_NAME))
+    public MeterRegistry getMeterRegistry() {
+        CompositeMeterRegistry meterRegistry = new CompositeMeterRegistry();
+        meterRegistry.add(...);
+        meterRegistry.add(new JmxMeterRegistry(
+           CamelJmxConfig.DEFAULT,
+           Clock.SYSTEM,
+           HierarchicalNameMapper.DEFAULT));
+        return meterRegistry;
+    }
+----
+
+====
 
+The `HierarchicalNameMapper` strategy determines how meter name and tags are assembled into an MBean name.
 
 == Using Camel Micrometer with Spring Boot
 
-When you use `camel-micrometer-starter` with Spring Boot, then Spring Boot auto configuration
-will automatically enable metrics capture if a `io.micrometer.core.instrument.MeterRegistry` is available.
+When you use `camel-micrometer-starter` with Spring Boot, then Spring Boot auto- configuration will automatically enable metrics capture if a `io.micrometer.core.instrument.MeterRegistry` is available.
 
 For example to capture data with Prometheus, you can add the following dependency: