Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micrometer Observation component #9389

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bom/camel-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,11 @@
<artifactId>camel-oaipmh</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-observation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ognl</artifactId>
Expand Down
95 changes: 48 additions & 47 deletions camel-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>25</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>25</version>
<relativePath />
</parent>

<groupId>org.apache.camel</groupId>
<artifactId>camel-dependencies</artifactId>
<version>3.21.0-SNAPSHOT</version>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dependencies</artifactId>
<version>3.21.0-SNAPSHOT</version>

<packaging>pom</packaging>
<name>Camel :: Dependencies</name>
<description>Camel Dependencies POM</description>
<packaging>pom</packaging>
<name>Camel :: Dependencies</name>
<description>Camel Dependencies POM</description>

<!-- sync properties here from parent/pom.xml -->
<properties>
Expand Down Expand Up @@ -397,7 +397,8 @@
<maven-wagon-version>3.5.2</maven-wagon-version>
<maven-war-plugin-version>3.3.1</maven-war-plugin-version>
<metrics-version>4.2.15</metrics-version>
<micrometer-version>1.10.2</micrometer-version>
<micrometer-tracing-version>1.0.2</micrometer-tracing-version>
<micrometer-version>1.10.4</micrometer-version>
<microprofile-config-version>2.0.1</microprofile-config-version>
<microprofile-metrics-version>3.0.1</microprofile-metrics-version>
<microprofile-fault-tolerance-version>3.0</microprofile-fault-tolerance-version>
Expand Down Expand Up @@ -569,38 +570,38 @@
<zookeeper-version>3.5.9</zookeeper-version>
<zxing-version>3.5.0</zxing-version>

<!-- OSGi bundles properties -->
<camel.osgi.import.camel.version>
version="[$(version;==;${camel.osgi.version.clean}),$(version;=+;${camel.osgi.version.clean}))"
</camel.osgi.import.camel.version>
<camel.osgi.import.strict.version>
version="[$(version;===;${camel.osgi.version.clean}),$(version;==+;${camel.osgi.version.clean}))"
</camel.osgi.import.strict.version>
<camel.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</camel.osgi.import.default.version>
<camel.osgi.import.defaults>
</camel.osgi.import.defaults>
<camel.osgi.import.before.defaults />
<camel.osgi.import.additional />
<camel.osgi.import.pkg>
org.apache.camel.*;${camel.osgi.import.camel.version},
${camel.osgi.import.before.defaults},
${camel.osgi.import.defaults},
${camel.osgi.import.additional},
*
</camel.osgi.import.pkg>
<camel.osgi.activator />
<camel.osgi.failok>false</camel.osgi.failok>
<camel.osgi.private.pkg>!*</camel.osgi.private.pkg>
<camel.osgi.export.pkg>$${replace;{local-packages};;;;}</camel.osgi.export.pkg>
<camel.osgi.export>${camel.osgi.export.pkg};-noimport:=true;${camel.osgi.version}</camel.osgi.export>
<camel.osgi.version>version=${project.version}</camel.osgi.version>
<camel.osgi.import>${camel.osgi.import.pkg}</camel.osgi.import>
<camel.osgi.dynamic />
<camel.osgi.symbolic.name>${project.groupId}.${project.artifactId}</camel.osgi.symbolic.name>
<camel.osgi.exclude.dependencies>false</camel.osgi.exclude.dependencies>
<camel.osgi.require.capability />
<camel.osgi.provide.capability />
<camel.osgi.manifest>${project.build.outputDirectory}/META-INF/MANIFEST.MF</camel.osgi.manifest>
</properties>
<!-- OSGi bundles properties -->
<camel.osgi.import.camel.version>
version="[$(version;==;${camel.osgi.version.clean}),$(version;=+;${camel.osgi.version.clean}))"
</camel.osgi.import.camel.version>
<camel.osgi.import.strict.version>
version="[$(version;===;${camel.osgi.version.clean}),$(version;==+;${camel.osgi.version.clean}))"
</camel.osgi.import.strict.version>
<camel.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</camel.osgi.import.default.version>
<camel.osgi.import.defaults>
</camel.osgi.import.defaults>
<camel.osgi.import.before.defaults />
<camel.osgi.import.additional />
<camel.osgi.import.pkg>
org.apache.camel.*;${camel.osgi.import.camel.version},
${camel.osgi.import.before.defaults},
${camel.osgi.import.defaults},
${camel.osgi.import.additional},
*
</camel.osgi.import.pkg>
<camel.osgi.activator />
<camel.osgi.failok>false</camel.osgi.failok>
<camel.osgi.private.pkg>!*</camel.osgi.private.pkg>
<camel.osgi.export.pkg>$${replace;{local-packages};;;;}</camel.osgi.export.pkg>
<camel.osgi.export>${camel.osgi.export.pkg};-noimport:=true;${camel.osgi.version}</camel.osgi.export>
<camel.osgi.version>version=${project.version}</camel.osgi.version>
<camel.osgi.import>${camel.osgi.import.pkg}</camel.osgi.import>
<camel.osgi.dynamic />
<camel.osgi.symbolic.name>${project.groupId}.${project.artifactId}</camel.osgi.symbolic.name>
<camel.osgi.exclude.dependencies>false</camel.osgi.exclude.dependencies>
<camel.osgi.require.capability />
<camel.osgi.provide.capability />
<camel.osgi.manifest>${project.build.outputDirectory}/META-INF/MANIFEST.MF</camel.osgi.manifest>
</properties>

</project>
5 changes: 5 additions & 0 deletions catalog/camel-allcomponents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,11 @@
<artifactId>camel-oaipmh</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-observation</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ognl</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ management
microprofile-config
microprofile-fault-tolerance
microprofile-health
observation
openapi-java
opentelemetry
opentracing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"other": {
"kind": "other",
"name": "observation",
"title": "Micrometer Observability",
"description": "Observability using Micrometer Observation",
"deprecated": false,
"firstVersion": "3.21.0",
"label": "monitoring,microservice",
"supportLevel": "Preview",
"groupId": "org.apache.camel",
"artifactId": "camel-observation",
"version": "3.20.3-SNAPSHOT"
}
}
88 changes: 88 additions & 0 deletions components/camel-observation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.camel</groupId>
<artifactId>components</artifactId>
<version>3.21.0-SNAPSHOT</version>
</parent>


<artifactId>camel-observation</artifactId>
<packaging>jar</packaging>
<name>Camel :: Micrometer Observation</name>
<description>Observability using Micrometer Observation</description>

<properties>
<firstVersion>3.21.0</firstVersion>
<label>monitoring,microservice</label>
<title>Micrometer Observability</title>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-tracing</artifactId>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>${micrometer-version}</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing</artifactId>
<version>${micrometer-tracing-version}</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-integration-test</artifactId>
<version>${micrometer-tracing-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-testing</artifactId>
<version>${opentelemetry-version}</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by camel build tools - do NOT edit this file!
name=observation
groupId=org.apache.camel
artifactId=camel-observation
version=3.21.0-SNAPSHOT
projectName=Camel :: Micrometer Observation
projectDescription=Observability using Micrometer Observation
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"other": {
"kind": "other",
"name": "observation",
"title": "Micrometer Observability",
"description": "Observability using Micrometer Observation",
"deprecated": false,
"firstVersion": "3.21.0",
"label": "monitoring,microservice",
"supportLevel": "Preview",
"groupId": "org.apache.camel",
"artifactId": "camel-observation",
"version": "3.21.0-SNAPSHOT"
}
}
88 changes: 88 additions & 0 deletions components/camel-observation/src/main/docs/observation.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
= Micrometer Observability Component
:doctitle: Micrometer Observability
:shortname: observation
:artifactid: camel-observation
:description: Observability using Micrometer Observation
:since: 3.21
:supportlevel: Preview
//Manually maintained attributes
:camel-spring-boot-name: observation

*Since Camel {since}*

The Micrometer Observation component is used for performing observability of incoming and
outgoing Camel messages using https://micrometer.io/docs/observation[Micrometer Observation].

By configuring the `ObservationRegistry` you can add behaviour to your observations such as metrics (e.g. via `Micrometer`) or tracing (e.g. via `OpenTelemetry` or `Brave`) or any custom behaviour.

Events are captured for incoming and outgoing messages being sent to/from Camel.

== Configuration

The configuration properties for the Micrometer Observations are:

[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|Option |Default |Description

|excludePatterns | | Sets exclude pattern(s) that will disable tracing for Camel
messages that matches the pattern. The content is a Set<String> where the key is a pattern. The pattern
uses the rules from Intercept.
|encoding |false| Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean.
Dashes need for instances to be encoded for JMS property keys.

|=======================================================================


=== Configuration

Include the `camel-opentelemetry` component in your POM, along with any specific dependencies associated with the
chosen OpenTelemetry compliant Tracer.

To explicitly configure OpenTelemetry support, instantiate the `OpenTelemetryTracer` and initialize the camel
context. You can optionally specify a `Tracer`, or alternatively it can be implicitly discovered using the
`Registry`

[source,java]
--------------------------------------------------------------------------------------------------
ObservationRegistry observationRegistry = ObservationRegistry.create();
MicrometerObservationTracer micrometerObservationTracer = new MicrometerObservationTracer();

// This component comes from Micrometer Core - it's used for creation of metrics
MeterRegistry meterRegistry = new SimpleMeterRegistry();

// This component comes from Micrometer Tracing - it's an abstraction over tracers
io.micrometer.tracing.Tracer otelTracer = otelTracer();
// This component comes from Micrometer Tracing - example of B3 header propagation via OpenTelemetry
OtelPropagator otelPropagator = new OtelPropagator(ContextPropagators.create(B3Propagator.injectingSingleHeader()), tracer);

// Configuration ObservationRegistry for metrics
observationRegistry.observationConfig().observationHandler(new DefaultMeterObservationHandler(meterRegistry));

// Configuration ObservationRegistry for tracing
observationRegistry.observationConfig().observationHandler(new ObservationHandler.FirstMatchingCompositeObservationHandler(new CamelPropagatingSenderTracingObservationHandler<>(otelTracer, otelPropagator), new CamelPropagatingReceiverTracingObservationHandler<>(otelTracer, otelPropagator), new CamelDefaultTracingObservationHandler(otelTracer)));

// Both components ObserationRegistry and MeterRegistry should be set manually or they will be resolved from CamelContext if present
micrometerObservationTracer.setObservationRegistry(observationRegistry);
micrometerObservationTracer.setTracer(otelTracer);

// Initialize the MicrometerObservationTracer
micrometerObservationTracer.init(context);
--------------------------------------------------------------------------------------------------

== Spring Boot

// TODO: Not done yet

If you are using Spring Boot then you can add
the `camel-observation-starter` dependency, and turn on OpenTracing by annotating
the main class with `@CamelObservation`.

The `MicrometerObservationTracer` will be implicitly obtained from the camel context's `Registry`, unless
a `MicrometerObservationTracer` bean has been defined by the application.

include::spring-boot:partial$starter.adoc[]

== MDC Logging

When MDC Logging is enabled for the active Camel context the Trace ID and Span ID will be added and removed from the MDC for each route, the keys are `trace_id` and `span_id`, respectively.
Loading