// Do not edit directly!
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
[id="extensions-opentelemetry2"]
= Opentelemetry2
:linkattrs:
:cq-artifact-id: camel-quarkus-opentelemetry2
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Implementation of Camel Opentelemetry based on the Camel Telemetry spec
:cq-deprecated: false
:cq-jvm-since: 3.22.0
:cq-native-since: 3.22.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##3.22.0## [.badge-key]##Native since##[.badge-supported]##3.22.0##
endif::[]

Implementation of Camel Opentelemetry based on the Camel Telemetry spec

[id="extensions-opentelemetry2-whats-inside"]
== What's inside

* xref:{cq-camel-components}:others:opentelemetry2.adoc[Opentelemetry2]

Please refer to the above link for usage and configuration details.

[id="extensions-opentelemetry2-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-opentelemetry2[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-opentelemetry2</artifactId>
</dependency>
----
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-opentelemetry2-usage"]
== Usage
The extension automatically creates a Camel `OpenTelemetryTracer` and binds it to the Camel registry.

In order to send the captured traces to a tracing system, you need to configure some properties within `application.properties` like those below.

NOTE: This extension addresses inconsistencies found in the original `camel-quarkus-opentelemetry` extensions and offers a more robust implementation.

[source,properties]
----
# OTLP exporter endpoint
quarkus.otel.exporter.otlp.endpoint=http://localhost:4317
----

Refer to the https://quarkus.io/guides/opentelemetry[Quarkus OpenTelemetry guide] for a full list of configuration options.

Route endpoints can be excluded from tracing by configuring a property named `quarkus.camel.opentelemetry2.exclude-patterns` in `application.properties`. For example:

[source,properties]
----
# Exclude all direct & netty-http endpoints from tracing
quarkus.camel.opentelemetry2.exclude-patterns=direct:*,netty-http:*
----

NOTE: The use of the https://opentelemetry.io/docs/zero-code/java/agent/[OpenTelemetry Agent] *is not needed nor recommended*.
Quarkus Extensions and the libraries they provide, are directly instrumented.
Also, the agent does not work in native mode.

[id="extensions-opentelemetry2-usage-exporters"]
=== Exporters

Quarkus OpenTelemetry defaults to the standard OTLP exporter defined in OpenTelemetry.
Additional exporters will be available in the Quarkiverse https://github.com/quarkiverse/quarkus-opentelemetry-exporter/blob/main/README.md[quarkus-opentelemetry-exporter] project.

[id="extensions-opentelemetry2-usage-tracing-cdi-bean-method-execution"]
=== Tracing CDI bean method execution

When instrumenting the execution of CDI bean methods from Camel routes, you should annotate such methods with `io.opentelemetry.extension.annotations.WithSpan`. Methods annotated with `@WithSpan` will create a new Span and establish any required relationships with the current Trace context.

For example, to instrument a CDI bean from a Camel route, first ensure the appropriate methods are annotated with `@WithSpan`.

[source,java]
----
@ApplicationScoped
@Named("myBean")
public class MyBean {
    @WithSpan
    public String greet() {
        return "Hello World!";
    }
}
----

Next, use the bean in your Camel route.

IMPORTANT: To ensure that the sequence of recorded spans is correct, you must use the full `to("bean:")` endpoint URI and not the shortened `.bean()` EIP DSL method.

[source,java]
----
public class MyRoutes extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("direct:executeBean")
                .to("bean:myBean?method=greet");
    }
}
----

There is more information about CDI instrumentation in the https://quarkus.io/guides/opentelemetry#cdi[Quarkus OpenTelemetry guide].


[id="extensions-opentelemetry2-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

[width="100%",cols="80,5,15",options="header"]
|===
| Configuration property | Type | Default


a| [[quarkus-camel-opentelemetry2-exclude-patterns]]`link:#quarkus-camel-opentelemetry2-exclude-patterns[quarkus.camel.opentelemetry2.exclude-patterns]`

Sets whether to disable tracing for endpoint URIs or Processor ids that match the given comma separated patterns. The
pattern can take the following forms:

1. An exact match on the endpoint URI. E.g. platform-http:/some/path

2. A wildcard match. E.g. platform-http:++*++

3. A regular expression matching the endpoint URI. E.g. platform-http:/prefix/.++*++
| `string`
| 

a| [[quarkus-camel-opentelemetry2-include-patterns]]`link:#quarkus-camel-opentelemetry2-include-patterns[quarkus.camel.opentelemetry2.include-patterns]`

Sets include pattern(s) that will explicitly enable tracing for Camel processors that matches the pattern.
Multiple patterns can be separated by comma. All processors included by default if nothing is specified.
| `string`
| 

a| [[quarkus-camel-opentelemetry2-trace-processors]]`link:#quarkus-camel-opentelemetry2-trace-processors[quarkus.camel.opentelemetry2.trace-processors]`

Sets whether to create new telemetry spans for each Camel custom Processor. Use the excludePatterns property to
filter
out Processors.
| `boolean`
| `false`

a| [[quarkus-camel-opentelemetry2-disable-core-processors]]`link:#quarkus-camel-opentelemetry2-disable-core-processors[quarkus.camel.opentelemetry2.disable-core-processors]`

Disable any inner core processors (any core DSL processor provided in the route, for example `bean`, `log`, ...).
| `boolean`
| `false`

a| [[quarkus-camel-opentelemetry2-trace-headers-inclusion]]`link:#quarkus-camel-opentelemetry2-trace-headers-inclusion[quarkus.camel.opentelemetry2.trace-headers-inclusion]`

If set to `true`, adds the generated telemetry `CAMEL_TRACE_ID` and `CAMEL_SPAN_ID` Exchange headers.
| `boolean`
| `false`
|===

[.configuration-legend]
{doc-link-icon-lock}[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.

