This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch ot-main in repository https://gitbox.apache.org/repos/asf/camel.git
commit e73e17708fabe009a8b4d5bd3e288070edc85bdb Author: Claus Ibsen <[email protected]> AuthorDate: Fri May 31 13:36:18 2024 +0200 CAMEL-20821: camel-opentelemetry - Add traceProcessors boolean option --- .../main/camel-main-configuration-metadata.json | 3 +- .../OpenTelemetryTracerConfigurer.java | 6 + .../src/main/docs/opentelemetry.adoc | 5 +- .../camel/opentelemetry/OpenTelemetryTracer.java | 21 +++- .../CamelOpenTelemetryTestSupport.java | 22 ++-- .../OpenTelemetryPropagateContextTest.java | 138 +++++++++++++++++++++ .../OtelConfigurationPropertiesConfigurer.java | 6 + .../camel-main-configuration-metadata.json | 3 +- core/camel-main/src/main/docs/main.adoc | 5 +- .../camel/main/OtelConfigurationProperties.java | 22 ++++ .../maven/packaging/PrepareCamelMainMojo.java | 2 +- 11 files changed, 216 insertions(+), 17 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json index 964dbe9396f..73d756eee1e 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json @@ -12,7 +12,7 @@ { "name": "camel.vault.aws", "description": "Camel AWS Vault configurations", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration" }, { "name": "camel.vault.gcp", "description": "Camel GCP Vault configurations", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration" }, { "name": "camel.vault.azure", "description": "Camel Azure Key Vault configurations", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration" }, - { "name": "camel.opentelemetry", "description": "Camel OpenTelemtry configurations", "sourceType": "org.apache.camel.main.OtelConfigurationProperties" }, + { "name": "camel.opentelemetry", "description": "Camel OpenTelemetry configurations", "sourceType": "org.apache.camel.main.OtelConfigurationProperties" }, { "name": "camel.metrics", "description": "Camel Micrometer Metrics configurations", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties" }, { "name": "camel.faulttolerance", "description": "Fault Tolerance EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.FaultToleranceConfigurationProperties" }, { "name": "camel.resilience4j", "description": "Resilience4j EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties" }, @@ -191,6 +191,7 @@ { "name": "camel.opentelemetry.encoding", "description": "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.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.opentelemetry.instrumentationName", "description": "A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "camel" }, + { "name": "camel.opentelemetry.traceProcessors", "description": "Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern property to filter out Processors.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.resilience4j.automaticTransitionFromOpenToHalfOpenEnabled", "description": "Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed.", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties", "type": "boolean", "javaType": "java.lang.Boolean", "defaultValue": "false" }, { "name": "camel.resilience4j.bulkheadEnabled", "description": "Whether bulkhead is enabled or not on the circuit breaker.", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties", "type": "boolean", "javaType": "java.lang.Boolean", "defaultValue": false }, { "name": "camel.resilience4j.bulkheadMaxConcurrentCalls", "description": "Configures the max amount of concurrent calls the bulkhead will support.", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties", "type": "integer", "javaType": "java.lang.Integer" }, diff --git a/components/camel-opentelemetry/src/generated/java/org/apache/camel/opentelemetry/OpenTelemetryTracerConfigurer.java b/components/camel-opentelemetry/src/generated/java/org/apache/camel/opentelemetry/OpenTelemetryTracerConfigurer.java index e70b4d68c4c..c78f23d0d79 100644 --- a/components/camel-opentelemetry/src/generated/java/org/apache/camel/opentelemetry/OpenTelemetryTracerConfigurer.java +++ b/components/camel-opentelemetry/src/generated/java/org/apache/camel/opentelemetry/OpenTelemetryTracerConfigurer.java @@ -32,6 +32,8 @@ public class OpenTelemetryTracerConfigurer extends org.apache.camel.support.comp case "excludePatterns": target.setExcludePatterns(property(camelContext, java.lang.String.class, value)); return true; case "instrumentationname": case "instrumentationName": target.setInstrumentationName(property(camelContext, java.lang.String.class, value)); return true; + case "traceprocessors": + case "traceProcessors": target.setTraceProcessors(property(camelContext, boolean.class, value)); return true; case "tracer": target.setTracer(property(camelContext, io.opentelemetry.api.trace.Tracer.class, value)); return true; case "tracingstrategy": case "tracingStrategy": target.setTracingStrategy(property(camelContext, org.apache.camel.spi.InterceptStrategy.class, value)); return true; @@ -51,6 +53,8 @@ public class OpenTelemetryTracerConfigurer extends org.apache.camel.support.comp case "excludePatterns": return java.lang.String.class; case "instrumentationname": case "instrumentationName": return java.lang.String.class; + case "traceprocessors": + case "traceProcessors": return boolean.class; case "tracer": return io.opentelemetry.api.trace.Tracer.class; case "tracingstrategy": case "tracingStrategy": return org.apache.camel.spi.InterceptStrategy.class; @@ -71,6 +75,8 @@ public class OpenTelemetryTracerConfigurer extends org.apache.camel.support.comp case "excludePatterns": return target.getExcludePatterns(); case "instrumentationname": case "instrumentationName": return target.getInstrumentationName(); + case "traceprocessors": + case "traceProcessors": return target.isTraceProcessors(); case "tracer": return target.getTracer(); case "tracingstrategy": case "tracingStrategy": return target.getTracingStrategy(); diff --git a/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc b/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc index c027f07886a..30d8fd322de 100644 --- a/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc +++ b/components/camel-opentelemetry/src/main/docs/opentelemetry.adoc @@ -28,9 +28,10 @@ The configuration properties for the OpenTelemetry tracer are: |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. +|encoding | false | Sets whether the header keys need to be encoded (connector specific) or not. The value is a boolean. Dashes are required for instances to be encoded for JMS property keys. - +|traceProcessors | false | Setting this to true will create new OpenTelemetry Spans for each Camel Processors. +Use the excludePattern property to filter out Processors |======================================================================= diff --git a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracer.java b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracer.java index 6858d20e819..86cfaa56cc2 100644 --- a/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracer.java +++ b/components/camel-opentelemetry/src/main/java/org/apache/camel/opentelemetry/OpenTelemetryTracer.java @@ -50,6 +50,7 @@ public class OpenTelemetryTracer extends org.apache.camel.tracing.Tracer { private Tracer tracer; private String instrumentationName = "camel"; private ContextPropagators contextPropagators; + private boolean traceProcessors; public Tracer getTracer() { return tracer; @@ -59,7 +60,7 @@ public class OpenTelemetryTracer extends org.apache.camel.tracing.Tracer { this.tracer = tracer; } - @ManagedAttribute + @ManagedAttribute(description = "A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name") public String getInstrumentationName() { return instrumentationName; } @@ -72,6 +73,19 @@ public class OpenTelemetryTracer extends org.apache.camel.tracing.Tracer { this.instrumentationName = instrumentationName; } + @ManagedAttribute(description = "Setting this to true will create new OpenTelemetry Spans for each Camel Processors") + public boolean isTraceProcessors() { + return traceProcessors; + } + + /** + * Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern + * property to filter out Processors. + */ + public void setTraceProcessors(boolean traceProcessors) { + this.traceProcessors = traceProcessors; + } + public ContextPropagators getContextPropagators() { return contextPropagators; } @@ -104,6 +118,11 @@ public class OpenTelemetryTracer extends org.apache.camel.tracing.Tracer { // GlobalOpenTelemetry.get() is always NotNull, falls back to OpenTelemetry.noop() tracer = GlobalOpenTelemetry.get().getTracer(instrumentationName); } + if (traceProcessors && (getTracingStrategy() == null || getTracingStrategy().getClass().isAssignableFrom(NoopTracingStrategy.class))) { + OpenTelemetryTracingStrategy tracingStrategy = new OpenTelemetryTracingStrategy(this); + tracingStrategy.setPropagateContext(true); + setTracingStrategy(tracingStrategy); + } } @Override diff --git a/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CamelOpenTelemetryTestSupport.java b/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CamelOpenTelemetryTestSupport.java index 05d369a2584..572f67c8f0f 100644 --- a/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CamelOpenTelemetryTestSupport.java +++ b/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/CamelOpenTelemetryTestSupport.java @@ -57,11 +57,11 @@ class CamelOpenTelemetryTestSupport extends CamelTestSupport { private static final Logger LOG = LoggerFactory.getLogger(CamelOpenTelemetryTestSupport.class); - private InMemorySpanExporter inMemorySpanExporter = InMemorySpanExporter.create(); - private SpanTestData[] expected; - private Tracer tracer; - private OpenTelemetryTracer ottracer; - private SdkTracerProvider tracerFactory; + InMemorySpanExporter inMemorySpanExporter = InMemorySpanExporter.create(); + SpanTestData[] expected; + Tracer tracer; + OpenTelemetryTracer ottracer; + SdkTracerProvider tracerFactory; CamelOpenTelemetryTestSupport(SpanTestData[] expected) { this.expected = expected; @@ -72,9 +72,7 @@ class CamelOpenTelemetryTestSupport extends CamelTestSupport { Assertions.assertSame(Context.root(), Context.current(), "There must be no leaking span after test"); } - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext context = super.createCamelContext(); + protected void initTracer(CamelContext context) { ottracer = new OpenTelemetryTracer(); tracerFactory = SdkTracerProvider.builder() @@ -87,6 +85,12 @@ class CamelOpenTelemetryTestSupport extends CamelTestSupport { ottracer.addDecorator(new TestSEDASpanDecorator()); ottracer.setTracingStrategy(getTracingStrategy().apply(ottracer)); ottracer.init(context); + } + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + initTracer(context); return context; } @@ -219,7 +223,7 @@ class CamelOpenTelemetryTestSupport extends CamelTestSupport { return ottracer -> new NoopTracingStrategy(); } - private static class LoggingSpanProcessor implements SpanProcessor { + static class LoggingSpanProcessor implements SpanProcessor { private static final Logger LOG = LoggerFactory.getLogger(LoggingSpanProcessor.class); @Override diff --git a/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/OpenTelemetryPropagateContextTest.java b/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/OpenTelemetryPropagateContextTest.java new file mode 100644 index 00000000000..557117d9d04 --- /dev/null +++ b/components/camel-opentelemetry/src/test/java/org/apache/camel/opentelemetry/OpenTelemetryPropagateContextTest.java @@ -0,0 +1,138 @@ +/* + * 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. + */ +package org.apache.camel.opentelemetry; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.concurrent.TimeUnit; + +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; +import org.apache.camel.CamelContext; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.NotifyBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import static org.apache.camel.test.junit5.TestSupport.fileUri; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class OpenTelemetryPropagateContextTest extends CamelOpenTelemetryTestSupport { + + @TempDir + private static Path tempDirectory; + + private final static SpanTestData[] testdata = { + new SpanTestData().setLabel("camel-process").setOperation("delayed") + .setParentId(2), + new SpanTestData().setLabel("camel-process").setOperation("WithSpan.secondMethod") + .setParentId(2), + new SpanTestData().setLabel("camel-process").setOperation("file").setKind(SpanKind.SERVER) + }; + + OpenTelemetryPropagateContextTest() { + super(testdata); + } + + @Override + protected void initTracer(CamelContext context) { + ottracer = new OpenTelemetryTracer(); + + tracerFactory = SdkTracerProvider.builder() + .addSpanProcessor(new LoggingSpanProcessor()) + .addSpanProcessor(SimpleSpanProcessor.create(inMemorySpanExporter)).build(); + + tracer = tracerFactory.get("tracerTest"); + ottracer.setTracer(tracer); + ottracer.setExcludePatterns(getExcludePatterns()); + ottracer.addDecorator(new TestSEDASpanDecorator()); + ottracer.setTraceProcessors(true); + ottracer.initTracer(); + ottracer.init(context); + } + + @BeforeAll + public static void createFile() throws IOException { + Files.createFile(tempDirectory.resolve("file.txt")); + } + + @Test + void testTracingOfProcessors() throws IOException, InterruptedException { + NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create(); + assertTrue(notify.matches(30, TimeUnit.SECONDS)); + verify(true); + } + + @Override + protected String getExcludePatterns() { + return "longRunningProcess"; + } + + @Override + protected RoutesBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from(fileUri(tempDirectory)).routeId("serviceA") + .process(exchange -> { + longRunningProcess(); + }).id("longRunningProcess") + .delay(simple("${random(0,500)}")).id("delayed"); + } + + private void longRunningProcess() { + firstMethod(); + secondMethod(); + } + + private void firstMethod() { + // no Span created by Camel + } + + // Simulate io.opentelemetry.instrumentation.annotations.@WithSpan + // in order to avoid having to start an HTTP sever just to collect the Spans + // see https://github.com/open-telemetry/opentelemetry-java-examples/tree/main/telemetry-testing + //@WithSpan + public void secondMethod() { + // The Context should be propagated + Assertions.assertNotSame(Context.root(), Context.current(), "OpenTelemetry was not propagated !"); + // build and start a custom Span similar to what @WithSpan would do + SpanBuilder builder = getOttracer().getTracer().spanBuilder("WithSpan.secondMethod"); + Span span = builder.setParent(Context.current()) + .setAttribute(COMPONENT_KEY, "custom") + .startSpan(); + //noinspection EmptyTryBlock + try (Scope ignored = span.makeCurrent()) { + // do work + } finally { + span.end(); + } + + } + }; + } + +} diff --git a/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java b/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java index 172245c1385..0c19a619add 100644 --- a/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java +++ b/core/camel-main/src/generated/java/org/apache/camel/main/OtelConfigurationPropertiesConfigurer.java @@ -29,6 +29,8 @@ public class OtelConfigurationPropertiesConfigurer extends org.apache.camel.supp case "excludePatterns": target.setExcludePatterns(property(camelContext, java.lang.String.class, value)); return true; case "instrumentationname": case "instrumentationName": target.setInstrumentationName(property(camelContext, java.lang.String.class, value)); return true; + case "traceprocessors": + case "traceProcessors": target.setTraceProcessors(property(camelContext, boolean.class, value)); return true; default: return false; } } @@ -42,6 +44,8 @@ public class OtelConfigurationPropertiesConfigurer extends org.apache.camel.supp case "excludePatterns": return java.lang.String.class; case "instrumentationname": case "instrumentationName": return java.lang.String.class; + case "traceprocessors": + case "traceProcessors": return boolean.class; default: return null; } } @@ -56,6 +60,8 @@ public class OtelConfigurationPropertiesConfigurer extends org.apache.camel.supp case "excludePatterns": return target.getExcludePatterns(); case "instrumentationname": case "instrumentationName": return target.getInstrumentationName(); + case "traceprocessors": + case "traceProcessors": return target.isTraceProcessors(); default: return null; } } diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json index 964dbe9396f..73d756eee1e 100644 --- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json +++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json @@ -12,7 +12,7 @@ { "name": "camel.vault.aws", "description": "Camel AWS Vault configurations", "sourceType": "org.apache.camel.vault.AwsVaultConfiguration" }, { "name": "camel.vault.gcp", "description": "Camel GCP Vault configurations", "sourceType": "org.apache.camel.vault.GcpVaultConfiguration" }, { "name": "camel.vault.azure", "description": "Camel Azure Key Vault configurations", "sourceType": "org.apache.camel.vault.AzureVaultConfiguration" }, - { "name": "camel.opentelemetry", "description": "Camel OpenTelemtry configurations", "sourceType": "org.apache.camel.main.OtelConfigurationProperties" }, + { "name": "camel.opentelemetry", "description": "Camel OpenTelemetry configurations", "sourceType": "org.apache.camel.main.OtelConfigurationProperties" }, { "name": "camel.metrics", "description": "Camel Micrometer Metrics configurations", "sourceType": "org.apache.camel.main.MetricsConfigurationProperties" }, { "name": "camel.faulttolerance", "description": "Fault Tolerance EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.FaultToleranceConfigurationProperties" }, { "name": "camel.resilience4j", "description": "Resilience4j EIP Circuit Breaker configurations", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties" }, @@ -191,6 +191,7 @@ { "name": "camel.opentelemetry.encoding", "description": "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.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.opentelemetry.excludePatterns", "description": "Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String" }, { "name": "camel.opentelemetry.instrumentationName", "description": "A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "string", "javaType": "java.lang.String", "defaultValue": "camel" }, + { "name": "camel.opentelemetry.traceProcessors", "description": "Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern property to filter out Processors.", "sourceType": "org.apache.camel.main.OtelConfigurationProperties", "type": "boolean", "javaType": "boolean", "defaultValue": "false" }, { "name": "camel.resilience4j.automaticTransitionFromOpenToHalfOpenEnabled", "description": "Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed.", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties", "type": "boolean", "javaType": "java.lang.Boolean", "defaultValue": "false" }, { "name": "camel.resilience4j.bulkheadEnabled", "description": "Whether bulkhead is enabled or not on the circuit breaker.", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties", "type": "boolean", "javaType": "java.lang.Boolean", "defaultValue": false }, { "name": "camel.resilience4j.bulkheadMaxConcurrentCalls", "description": "Configures the max amount of concurrent calls the bulkhead will support.", "sourceType": "org.apache.camel.main.Resilience4jConfigurationProperties", "type": "integer", "javaType": "java.lang.Integer" }, diff --git a/core/camel-main/src/main/docs/main.adoc b/core/camel-main/src/main/docs/main.adoc index 18de5cf72e7..47828c66429 100644 --- a/core/camel-main/src/main/docs/main.adoc +++ b/core/camel-main/src/main/docs/main.adoc @@ -376,8 +376,8 @@ The camel.vault.azure supports 12 options, which are listed below. |=== -=== Camel OpenTelemtry configurations -The camel.opentelemetry supports 4 options, which are listed below. +=== Camel OpenTelemetry configurations +The camel.opentelemetry supports 5 options, which are listed below. [width="100%",cols="2,5,^1,2",options="header"] |=== @@ -386,6 +386,7 @@ The camel.opentelemetry supports 4 options, which are listed below. | *camel.opentelemetry.encoding* | 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. | false | boolean | *camel.opentelemetry.exclude{zwsp}Patterns* | Adds an exclude pattern that will disable tracing for Camel messages that matches the pattern. Multiple patterns can be separated by comma. | | String | *{zwsp}camel.opentelemetry.instrumentation{zwsp}Name* | A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null. | camel | String +| *camel.opentelemetry.trace{zwsp}Processors* | Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern property to filter out Processors. | false | boolean |=== diff --git a/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java index 567356d5d02..7848d9f9d5d 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/OtelConfigurationProperties.java @@ -33,6 +33,7 @@ public class OtelConfigurationProperties implements BootstrapCloseable { private String instrumentationName = "camel"; private boolean encoding; private String excludePatterns; + private boolean traceProcessors; public OtelConfigurationProperties(MainConfigurationProperties parent) { this.parent = parent; @@ -94,6 +95,18 @@ public class OtelConfigurationProperties implements BootstrapCloseable { this.excludePatterns = excludePatterns; } + public boolean isTraceProcessors() { + return traceProcessors; + } + + /** + * Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern + * property to filter out Processors. + */ + public void setTraceProcessors(boolean traceProcessors) { + this.traceProcessors = traceProcessors; + } + /** * A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully * qualified class name. Must not be null. @@ -129,4 +142,13 @@ public class OtelConfigurationProperties implements BootstrapCloseable { return this; } + /** + * Setting this to true will create new OpenTelemetry Spans for each Camel Processors. Use the excludePattern + * property to filter out Processors. + */ + public OtelConfigurationProperties withTraceProcessors(boolean traceProcessors) { + this.traceProcessors = traceProcessors; + return this; + } + } diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java index 715af3e6ae8..3565e44fc3d 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCamelMainMojo.java @@ -333,7 +333,7 @@ public class PrepareCamelMainMojo extends AbstractGeneratorMojo { "org.apache.camel.vault.AzureVaultConfiguration")); // TODO: add more vault providers here model.getGroups().add(new MainGroupModel( - "camel.opentelemetry", "Camel OpenTelemtry configurations", + "camel.opentelemetry", "Camel OpenTelemetry configurations", "org.apache.camel.main.OtelConfigurationProperties")); model.getGroups().add(new MainGroupModel( "camel.metrics", "Camel Micrometer Metrics configurations",
