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

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


The following commit(s) were added to refs/heads/main by this push:
     new 195291092a Add tracing_opentelemetry_camel to samples
195291092a is described below

commit 195291092a2c1dca795949f351e49f07a623087b
Author: Andriy Redko <[email protected]>
AuthorDate: Fri Sep 8 17:10:59 2023 -0400

    Add tracing_opentelemetry_camel to samples
---
 .../jax_rs/tracing_opentelemetry_camel/README.txt  |  51 +++++
 .../jax_rs/tracing_opentelemetry_camel/pom.xml     | 228 +++++++++++++++++++++
 .../demo/jaxrs/tracing/OpenTelemetrySetup.java     |  49 +++++
 .../java/demo/jaxrs/tracing/client/Client.java     |  53 +++++
 .../jaxrs/tracing/server/camel/CatalogRoute.java   |  38 ++++
 .../demo/jaxrs/tracing/server/camel/Server.java    |  56 +++++
 .../java/demo/jaxrs/tracing/server/cxf/Book.java   |  48 +++++
 .../demo/jaxrs/tracing/server/cxf/Catalog.java     |  53 +++++
 .../java/demo/jaxrs/tracing/server/cxf/Server.java |  62 ++++++
 .../src/main/resources/application.yml             |   2 +
 .../src/main/resources/logback.xml                 |  12 ++
 distribution/src/main/release/samples/pom.xml      |   1 +
 12 files changed, 653 insertions(+)

diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/README.txt
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/README.txt
new file mode 100644
index 0000000000..20b06b1507
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/README.txt
@@ -0,0 +1,51 @@
+JAX-RS OpenTelemetry/Apache Camel OpenTelemetry Demo
+=================
+
+The demo shows a basic usage of OpenTelemetry API across multiple distributed 
+REST-based components. It consists of HTTP route defined using Apache Camel, 
which 
+forwards the request to JAX-RS 2.0 (JSR-339) service, backed by Apache CXF. 
The demo 
+also contains a JAX-RS 2.0 (JSR-339) client which initiates the connection to 
the 
+Apache Camel HTTP route. The following REST(ful) endpoints are available:
+
+  - GET to http://0.0.0.0:8084/catalog
+  - GET to http://localhost:8080/services/books
+
+To collect the traces, please run Jaeger distributed tracer components, the
+simplest way would be using Docker:
+
+  docker run --rm --network=host --name jaeger \
+      -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
+      -p 6831:6831/udp \
+      -p 6832:6832/udp \
+      -p 5778:5778 \
+      -p 16686:16686 \
+      -p 4317:4317 \
+      -p 4318:4318 \
+      -p 14250:14250 \
+      -p 14268:14268 \
+      -p 14269:14269 \
+      -p 9411:9411 \
+      jaegertracing/all-in-one:1.49
+
+The following sample traces should be available in Jaeger UI (available
+be default at http://localhost:16686/search):
+
+  +- cxf-client GET http://localhost:8084/catalog
+     +- camel-server GET
+        +- camel-server GET
+           +- cxf-service GET /services/books
+
+Building and running the demo using Maven
+---------------------------------------
+
+From the base directory of this sample (i.e., where this README file is
+located), the Maven pom.xml file can be used to build and run the demo.
+
+Using either UNIX or Windows:
+
+  mvn install
+  mvn -Pcamel-server  (from one command line window)
+  mvn -Pcxf-server  (from one command line window)
+  mvn -Pclient  (from a third command line window)
+
+To remove the target dir, run mvn clean".
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/pom.xml
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/pom.xml
new file mode 100644
index 0000000000..3a7df011d5
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/pom.xml
@@ -0,0 +1,228 @@
+<?xml version="1.0"?>
+<!--
+  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/maven-v4_0_0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>jax_rs_tracing_opentelemetry_camel</artifactId>
+    <name>JAX-RS Demo Using Distributed Tracing with OpenTelemetry API, Apache 
Camel and Jaeger</name>
+    <description>JAX-RS Demo Using Distributed Tracing with OpenTelemetry API, 
Apache Camel and Jaeger</description>
+    <parent>
+        <groupId>org.apache.cxf.samples</groupId>
+        <artifactId>cxf-samples</artifactId>
+        <version>4.0.3-SNAPSHOT</version>
+        <relativePath>../..</relativePath>
+    </parent>
+    
+    <properties>
+        <cxf.version>${project.version}</cxf.version>
+        <cxf.camel.version>4.0.0</cxf.camel.version>
+    </properties>
+    
+    <profiles>
+        <profile>
+            <id>cxf-server</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    
<mainClass>demo.jaxrs.tracing.server.cxf.Server</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>camel-server</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    
<mainClass>demo.jaxrs.tracing.server.camel.Server</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>client</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    
<mainClass>demo.jaxrs.tracing.client.Client</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+    
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.camel.springboot</groupId>
+                <artifactId>camel-spring-boot-dependencies</artifactId>
+                <version>${cxf.camel.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    
+    <dependencies>
+       <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+        </dependency>
+        <!-- This dependency is needed if you're using the Jetty container -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-integration-tracing-opentelemetry</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-extension-providers</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-spring-boot-starter-jaxrs</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.ws.rs</groupId>
+            <artifactId>jakarta.ws.rs-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+
+        <!-- spring-boot -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-classic</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+    
+        <!-- camel -->
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-opentelemetry-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-jetty-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-http-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-core-starter</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>com.fasterxml.jackson.jakarta.rs</groupId>
+            <artifactId>jackson-jakarta-rs-json-provider</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>io.opentelemetry</groupId>
+            <artifactId>opentelemetry-sdk</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.opentelemetry</groupId>
+            <artifactId>opentelemetry-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.opentelemetry</groupId>
+            <artifactId>opentelemetry-exporter-otlp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.opentelemetry</groupId>
+            <artifactId>opentelemetry-semconv</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.opentelemetry</groupId>
+            <artifactId>opentelemetry-exporter-sender-okhttp</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/OpenTelemetrySetup.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/OpenTelemetrySetup.java
new file mode 100644
index 0000000000..6813a51f33
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/OpenTelemetrySetup.java
@@ -0,0 +1,49 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 demo.jaxrs.tracing;
+
+import io.opentelemetry.api.common.Attributes;
+import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator;
+import io.opentelemetry.context.propagation.ContextPropagators;
+import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import io.opentelemetry.sdk.resources.Resource;
+import io.opentelemetry.sdk.trace.SdkTracerProvider;
+import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
+import io.opentelemetry.sdk.trace.samplers.Sampler;
+import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
+
+public class OpenTelemetrySetup {
+
+    public static OpenTelemetrySdk setup(String serviceName) {
+        Resource resource = Resource.getDefault()
+            
.merge(Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, 
serviceName)));
+
+        final SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
+            
.addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder().build()).build())
+            .setSampler(Sampler.alwaysOn())
+            .setResource(resource).build();
+
+        final OpenTelemetrySdk openTelemetrySdk = 
OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider)
+            
.setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance()))
+            .buildAndRegisterGlobal();
+
+        return openTelemetrySdk;
+    }
+}
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/client/Client.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/client/Client.java
new file mode 100644
index 0000000000..3cde3744f4
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/client/Client.java
@@ -0,0 +1,53 @@
+/**
+ * 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 demo.jaxrs.tracing.client;
+
+import org.apache.cxf.tracing.opentelemetry.jaxrs.OpenTelemetryClientProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import demo.jaxrs.tracing.OpenTelemetrySetup;
+import io.opentelemetry.sdk.OpenTelemetrySdk;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+
+public final class Client {
+    private static final Logger LOG = LoggerFactory.getLogger(Client.class); 
+    
+    private Client() {
+    }
+
+    public static void main(final String[] args) throws Exception {
+        try (final OpenTelemetrySdk otel = 
OpenTelemetrySetup.setup("cxf-client")) {
+            final OpenTelemetryClientProvider provider = new 
OpenTelemetryClientProvider(otel, "cxf-client");
+            final jakarta.ws.rs.client.Client client = 
ClientBuilder.newClient().register(provider);
+            
+            final Response response = client
+                .target("http://localhost:8084/catalog";)
+                .request()
+                .accept(MediaType.APPLICATION_JSON)
+                .get();
+          
+            LOG.info("Response: {}", response.readEntity(String.class));
+            response.close();
+        }
+    }
+}
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/camel/CatalogRoute.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/camel/CatalogRoute.java
new file mode 100644
index 0000000000..913f6d03df
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/camel/CatalogRoute.java
@@ -0,0 +1,38 @@
+/**
+ * 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 demo.jaxrs.tracing.server.camel;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CatalogRoute extends RouteBuilder {
+    @Override
+    public void configure() throws Exception {
+        from("jetty:http://0.0.0.0:8084/catalog";)
+            .routeId("catalog")
+            .streamCaching()
+            .log("Catalog request: ${body}")
+            .delay(simple("${random(1000,2000)}"))
+            .transform(simple("catalog-${body}"))
+            .to("http://localhost:8080/services/books?bridgeEndpoint=true";)
+            .log("Books response: ${body}");
+    }
+}
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/camel/Server.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/camel/Server.java
new file mode 100644
index 0000000000..4151c1096d
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/camel/Server.java
@@ -0,0 +1,56 @@
+/**
+ * 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 demo.jaxrs.tracing.server.camel;
+
+import org.apache.camel.opentelemetry.starter.CamelOpenTelemetry;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.annotation.Bean;
+
+import demo.jaxrs.tracing.OpenTelemetrySetup;
+import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.context.propagation.ContextPropagators;
+import io.opentelemetry.context.propagation.TextMapPropagator;
+
+@EnableAutoConfiguration
+@SpringBootApplication
+@CamelOpenTelemetry
+public class Server {
+    public static void main(String[] args) {
+        new SpringApplicationBuilder(Server.class)
+            .web(WebApplicationType.NONE)
+            .build()
+            .run(args);
+    }
+    
+    @Bean
+    Tracer tracer() {
+        return 
OpenTelemetrySetup.setup("camel-server").getTracer("camel-server");
+    }
+    
+    @Bean
+    ContextPropagators contextPropagators() {
+        return 
ContextPropagators.create(TextMapPropagator.composite(W3CBaggagePropagator.getInstance()));
+    }
+}
+
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Book.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Book.java
new file mode 100644
index 0000000000..1d322d3a69
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Book.java
@@ -0,0 +1,48 @@
+/**
+ * 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 demo.jaxrs.tracing.server.cxf;
+
+public class Book {
+    private String id;
+    private String title;
+
+    public Book() {
+    }
+
+    public Book(String id, String title) {
+        this.id = id;
+        this.title = title;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+}
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Catalog.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Catalog.java
new file mode 100644
index 0000000000..789f9bc016
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Catalog.java
@@ -0,0 +1,53 @@
+/**
+ * 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 demo.jaxrs.tracing.server.cxf;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.apache.cxf.tracing.TracerContext;
+
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.MediaType;
+
+@Path("/books")
+public class Catalog {
+    public Catalog() {
+    }
+
+    
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Collection<Book> getBooks(@Context final TracerContext tracing) {
+        
+        final Collection<Book> books = 
+            Arrays.asList(
+                new Book("Apache CXF Web Service Development", "Naveen Balani, 
Rajeev Hathi")
+            );
+        
+        tracing.annotate("# of books", Integer.toString(books.size()));
+        return books;
+    }
+}
+
+
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Server.java
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Server.java
new file mode 100644
index 0000000000..4f81d95150
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/java/demo/jaxrs/tracing/server/cxf/Server.java
@@ -0,0 +1,62 @@
+/**
+ * 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 demo.jaxrs.tracing.server.cxf;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.tracing.opentelemetry.jaxrs.OpenTelemetryFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import demo.jaxrs.tracing.OpenTelemetrySetup;
+import io.opentelemetry.api.OpenTelemetry;
+
+@EnableAutoConfiguration
+@SpringBootApplication
+public class Server {
+    @Autowired private Bus bus;
+    
+    public static void main(String[] args) {
+        SpringApplication.run(Server.class, args);
+    }
+    
+    @Bean
+    org.apache.cxf.endpoint.Server cxfServer(@Qualifier("cxf") final 
OpenTelemetry otel) {
+        final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
+        endpoint.setBus(bus);
+        endpoint.setAddress("/");
+        endpoint.setServiceBean(new Catalog());
+        endpoint.setProvider(new OpenTelemetryFeature(otel, "cxf-service"));
+        endpoint.setProvider(new JacksonJsonProvider());
+        return endpoint.create();
+    }
+    
+    @Bean @Qualifier("cxf")
+    OpenTelemetry cxfOpenTelemetry() {
+        return OpenTelemetrySetup.setup("cxf-service");
+    }
+}
+
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/resources/application.yml
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/resources/application.yml
new file mode 100644
index 0000000000..a7afc92b75
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/resources/application.yml
@@ -0,0 +1,2 @@
+server:
+  port: 8080
diff --git 
a/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/resources/logback.xml
 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/resources/logback.xml
new file mode 100644
index 0000000000..9b9f901e0f
--- /dev/null
+++ 
b/distribution/src/main/release/samples/jax_rs/tracing_opentelemetry_camel/src/main/resources/logback.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="5 seconds">
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>[%level] %d{yyyy-MM-dd HH:mm:ss.SSS} %logger{36} - [%X] 
%msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
\ No newline at end of file
diff --git a/distribution/src/main/release/samples/pom.xml 
b/distribution/src/main/release/samples/pom.xml
index 471dd3ea13..1c95d80f19 100644
--- a/distribution/src/main/release/samples/pom.xml
+++ b/distribution/src/main/release/samples/pom.xml
@@ -102,6 +102,7 @@
         <module>jax_rs/tracing_brave</module>
         <module>jax_rs/tracing_opentracing</module>
         <module>jax_rs/tracing_opentelemetry</module>
+        <module>jax_rs/tracing_opentelemetry_camel</module>
         <module>jax_rs/websocket</module>
         <module>jax_rs/websocket_web</module>
         <module>jax_server_aegis_client</module>

Reply via email to