= Telemetry Trait

// Start of autogenerated code - DO NOT EDIT! (badges)
[.badges]
[.badge-key]##Deprecated since##[.badge-unsupported]##2.9.0##
// End of autogenerated code - DO NOT EDIT! (badges)

[WARNING]
====
The Telemetry trait is *deprecated* as of version 2.9.0 and will be removed in a future release.

The same behavior can be achieved via properties and dependencies configuration. See the <<migration-guide>> section below for details.
====

// Start of autogenerated code - DO NOT EDIT! (description)
The Telemetry trait can be used to automatically publish tracing information to an OTLP compatible collector.

The trait is able to automatically discover the telemetry OTLP endpoint available in the namespace (supports **Jaerger** in version 1.35+).

The Telemetry trait is disabled by default.

WARNING: The Telemetry trait is **deprecated** and will be removed in future release versions.
The same behavior can be achieved via properties and dependencies configuration.

Migration example:

	Before: --trait telemetry.endpoint=http://jaeger:4317
	After:  -p quarkus.otel.exporter.otlp.traces.endpoint=http://jaeger:4317

WARNING: The Telemetry trait can't be enabled at the same time as the Tracing trait.


This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.

// End of autogenerated code - DO NOT EDIT! (description)
// Start of autogenerated code - DO NOT EDIT! (configuration)
== Configuration

Trait properties can be specified when running any integration with the CLI:
[source,console]
----
$ kamel run --trait telemetry.[key]=[value] --trait telemetry.[key2]=[value2] integration.yaml
----
The following configuration options are available:

[cols="2m,1m,5a"]
|===
|Property | Type | Description

| telemetry.enabled
| bool
| Can be used to enable or disable a trait. All traits share this common property.

| telemetry.auto
| bool
| Enables automatic configuration of the trait, including automatic discovery of the telemetry endpoint.

| telemetry.service-name
| string
| The name of the service that publishes telemetry data (defaults to the integration name)

| telemetry.endpoint
| string
| The target endpoint of the Telemetry service (automatically discovered by default)

| telemetry.sampler
| string
| The sampler of the telemetry used for tracing (default "on")

| telemetry.sampler-ratio
| string
| The sampler ratio of the telemetry used for tracing

| telemetry.sampler-parent-based
| bool
| The sampler of the telemetry used for tracing is parent based (default "true")

|===

// End of autogenerated code - DO NOT EDIT! (configuration)

== Examples

* To activate tracing to a deployed OTLP API Jaeger through discovery: 
+
[source,console]
$ kamel run -t telemetry.enable=true ...

* To define a specific deployed OTLP gRPC reciever: 
+
[source,console]
$ kamel run -t telemetry.enable=true -t telemetry.endpoint=http://instance-collector:4317 ...

* To define another sampler service name: 
+
[source,console]
$ kamel run -t telemetry.enable=true -t telemetry.service-name=tracer_myintegration ...

* To use a ratio sampler with a sampling ratio of 1 to every 1,000 : 
+
[source,console]
$ kamel run -t telemetry.enable=true -t telemetry.sampler=ratio -t telemetry.sampler-ratio=0.001 ...

[[migration-guide]]
== Migration Guide

The Telemetry trait is deprecated. The same behavior can be achieved via properties and dependencies configuration.

=== Property Mapping

The following table shows how to map Telemetry trait properties to application properties:

[cols="2m,2m,3a"]
|===
|Telemetry Trait | Application Property | Example

| telemetry.endpoint=http://jaeger:4317
| quarkus.otel.exporter.otlp.traces.endpoint=http://jaeger:4317
| `kamel run -p quarkus.otel.exporter.otlp.traces.endpoint=http://jaeger:4317 MyRoute.java`

| telemetry.service-name=my-service
| quarkus.otel.resource.attributes=service.name=my-service
| `kamel run -p quarkus.otel.resource.attributes=service.name=my-service MyRoute.java`

| telemetry.sampler=ratio
| quarkus.otel.traces.sampler=ratio
| `kamel run -p quarkus.otel.traces.sampler=ratio MyRoute.java`

| telemetry.sampler-ratio=0.001
| quarkus.otel.traces.sampler.ratio=0.001
| `kamel run -p quarkus.otel.traces.sampler.ratio=0.001 MyRoute.java`

| telemetry.sampler-parent-based=true
| quarkus.otel.traces.sampler.parent-based=true
| `kamel run -p quarkus.otel.traces.sampler.parent-based=true MyRoute.java`

|===

=== Migration Examples

**Before (deprecated):**

[source,console]
----
$ kamel run -t telemetry.enabled=true \
  -t telemetry.endpoint=http://jaeger:4317 \
  -t telemetry.service-name=my-integration \
  MyRoute.java
----

**After (recommended):**

[source,console]
----
$ kamel run \
  --dependency camel:opentelemetry \
  -p quarkus.otel.exporter.otlp.traces.endpoint=http://jaeger:4317 \
  -p quarkus.otel.resource.attributes=service.name=my-integration \
  MyRoute.java
----

NOTE: The `--dependency camel:opentelemetry` is required. Previously, the telemetry trait automatically added this dependency via the `camel-k:telemetry` capability. With direct configuration, you must explicitly include the OpenTelemetry dependency.

=== Benefits of Direct Configuration

Using properties and dependencies configuration directly provides more flexibility, including:

* Full access to all Quarkus OpenTelemetry options: https://quarkus.io/guides/opentelemetry
* Custom telemetry dependencies can be added as needed
