Skip to content

Commit 9fe76ec

Browse files
Add integration tests for aws2-translate #2403
1 parent 4dbcf34 commit 9fe76ec

13 files changed

Lines changed: 4231 additions & 1 deletion

File tree

build.log

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
[INFO] Scanning for projects...
2+
[INFO]
3+
[INFO] --< org.apache.camel.quarkus:camel-quarkus-integration-test-opentelemetry2 >--
4+
[INFO] Building Camel Quarkus :: Integration Tests :: Opentelemetry2 3.32.0-SNAPSHOT
5+
[INFO] from pom.xml
6+
[INFO] --------------------------------[ jar ]---------------------------------
7+
[INFO]
8+
[INFO] --- clean:3.5.0:clean (default-clean) @ camel-quarkus-integration-test-opentelemetry2 ---
9+
[INFO] Deleting /Users/sanjana./camel-quarkus/integration-tests/opentelemetry2/target
10+
[INFO]
11+
[INFO] --- resources:3.4.0:copy-resources (copy-camel-quarkus-enforcer-rules-xslt) @ camel-quarkus-integration-test-opentelemetry2 ---
12+
[INFO] Copying 1 resource from ../../tooling/enforcer-rules to target/enforcer-rules
13+
[INFO]
14+
[INFO] --- enforcer:3.5.0:enforce (enforce-java-version) @ camel-quarkus-integration-test-opentelemetry2 ---
15+
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
16+
[INFO]
17+
[INFO] --- enforcer:3.5.0:enforce (camel-quarkus-enforcer-rules) @ camel-quarkus-integration-test-opentelemetry2 ---
18+
[INFO] Rule Config Provider org.l2x6.cq.enforcer.ext.rules.FilteredExternalRules executed
19+
[INFO] Rule Config Provider org.l2x6.cq.enforcer.ext.rules.FilteredExternalRules executed
20+
[INFO] Rule Config Provider org.l2x6.cq.enforcer.ext.rules.FilteredExternalRules executed
21+
[INFO] Rule Config Provider org.l2x6.cq.enforcer.ext.rules.FilteredExternalRules executed
22+
[INFO] Rule 0: org.apache.maven.enforcer.rules.version.RequireJavaVersion passed
23+
[INFO] Rule 1: org.apache.maven.enforcer.rules.dependency.DependencyConvergence passed
24+
[INFO] Rule 2: org.apache.maven.enforcer.rules.version.RequireMavenVersion passed
25+
[INFO] Rule 3: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
26+
[INFO] Rule 4: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
27+
[INFO] Rule 5: org.apache.maven.enforcer.rules.dependency.BannedDependencies passed
28+
[INFO]
29+
[INFO] --- gplus:3.0.0:execute (sanity-checks) @ camel-quarkus-integration-test-opentelemetry2 ---
30+
[INFO] Using plugin classloader, includes GMavenPlus and project classpath.
31+
[INFO] Using Groovy 4.0.29 to perform execute.
32+
[INFO] Running Groovy script from file:/Users/sanjana./camel-quarkus/tooling/scripts/sanity-checks.groovy.
33+
[INFO]
34+
[INFO] --- formatter:2.29.0:format (format) @ camel-quarkus-integration-test-opentelemetry2 ---
35+
[INFO] Processed 12 files in 624ms (Formatted: 0, Skipped: 0, Unchanged: 12, Failed: 0, Readonly: 0)
36+
[INFO]
37+
[INFO] --- impsort:1.13.0:sort (sort-imports) @ camel-quarkus-integration-test-opentelemetry2 ---
38+
[INFO] Processed 12 files in 00:00.091 (Already Sorted: 12, Needed Sorting: 0)
39+
[INFO]
40+
[INFO] --- resources:3.4.0:resources (default-resources) @ camel-quarkus-integration-test-opentelemetry2 ---
41+
[INFO] Copying 1 resource from src/main/resources to target/classes
42+
[INFO] The encoding used to copy filtered properties files has not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
43+
[INFO]
44+
[INFO] --- resources:3.4.0:copy-resources (legal-resources) @ camel-quarkus-integration-test-opentelemetry2 ---
45+
[INFO] Copying 2 resources from ../../tooling/legal to target/classes
46+
[INFO]
47+
[INFO] --- compiler:3.15.0:compile (default-compile) @ camel-quarkus-integration-test-opentelemetry2 ---
48+
[INFO] Recompiling the module because of changed source code.
49+
[INFO] Compiling 6 source files with javac [debug deprecation release 17] to target/classes
50+
[INFO] ------------------------------------------------------------------------
51+
[INFO] BUILD SUCCESS
52+
[INFO] ------------------------------------------------------------------------
53+
[INFO] Total time: 4.119 s
54+
[INFO] Finished at: 2026-02-17T11:06:06+05:30
55+
[INFO] ------------------------------------------------------------------------
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.opentelemetry2;
18+
19+
import io.opentelemetry.api.baggage.Baggage;
20+
import io.opentelemetry.api.trace.SpanBuilder;
21+
import io.opentelemetry.api.trace.SpanKind;
22+
import io.opentelemetry.api.trace.Tracer;
23+
import io.opentelemetry.context.Context;
24+
import io.opentelemetry.context.propagation.ContextPropagators;
25+
import io.opentelemetry.context.propagation.TextMapGetter;
26+
import org.apache.camel.Endpoint;
27+
import org.apache.camel.Exchange;
28+
import org.apache.camel.telemetry.Op;
29+
import org.apache.camel.telemetry.SpanContextPropagationExtractor;
30+
import org.apache.camel.telemetry.SpanContextPropagationInjector;
31+
import org.apache.camel.telemetry.SpanLifecycleManager;
32+
import org.apache.camel.telemetry.decorators.PlatformHttpSpanDecorator;
33+
import org.apache.camel.telemetry.decorators.ServletSpanDecorator;
34+
35+
public class CamelQuarkusOpenTelemetry2Tracer extends OpenTelemetryTracer {
36+
37+
private final ThreadLocal<Op> currentOp = new ThreadLocal<>();
38+
private final ThreadLocal<Endpoint> currentEndpoint = new ThreadLocal<>();
39+
40+
private Tracer otelTracer;
41+
private ContextPropagators contextPropagators;
42+
private org.apache.camel.telemetry.SpanDecoratorManager spanDecoratorManager;
43+
44+
@Override
45+
public void setTracer(Tracer tracer) {
46+
super.setTracer(tracer);
47+
this.otelTracer = tracer;
48+
}
49+
50+
@Override
51+
public void setContextPropagators(ContextPropagators contextPropagators) {
52+
super.setContextPropagators(contextPropagators);
53+
this.contextPropagators = contextPropagators;
54+
}
55+
56+
@Override
57+
protected void beginEventSpan(Exchange exchange, Endpoint endpoint, Op op) throws Exception {
58+
currentOp.set(op);
59+
currentEndpoint.set(endpoint);
60+
try {
61+
super.beginEventSpan(exchange, endpoint, op);
62+
} finally {
63+
currentOp.remove();
64+
currentEndpoint.remove();
65+
}
66+
}
67+
68+
@Override
69+
protected void initTracer() {
70+
super.initTracer();
71+
setSpanLifecycleManager(new QuarkusSpanLifecycleManager());
72+
// Use reflection to get the private spanDecoratorManager from Tracer
73+
try {
74+
java.lang.reflect.Field field = org.apache.camel.telemetry.Tracer.class.getDeclaredField("spanDecoratorManager");
75+
field.setAccessible(true);
76+
this.spanDecoratorManager = (org.apache.camel.telemetry.SpanDecoratorManager) field.get(this);
77+
} catch (Exception e) {
78+
throw new RuntimeException("Failed to access spanDecoratorManager from Tracer", e);
79+
}
80+
}
81+
82+
private org.apache.camel.telemetry.SpanDecoratorManager getSpanDecoratorManager() {
83+
return spanDecoratorManager;
84+
}
85+
86+
private class QuarkusSpanLifecycleManager implements SpanLifecycleManager {
87+
88+
@Override
89+
public org.apache.camel.telemetry.Span create(String spanName, org.apache.camel.telemetry.Span parent,
90+
SpanContextPropagationExtractor extractor) {
91+
Endpoint endpoint = currentEndpoint.get();
92+
if (endpoint != null) {
93+
org.apache.camel.telemetry.SpanDecorator sd = CamelQuarkusOpenTelemetry2Tracer.this.getSpanDecoratorManager()
94+
.get(endpoint);
95+
if (sd instanceof PlatformHttpSpanDecorator || sd instanceof ServletSpanDecorator) {
96+
io.opentelemetry.api.trace.Span span = io.opentelemetry.api.trace.Span.fromContext(Context.current());
97+
Baggage baggage = Baggage.fromContext(Context.current());
98+
if (span != null && span.getSpanContext().isValid()) {
99+
return new OpenTelemetrySpanAdapter(span, baggage);
100+
}
101+
}
102+
}
103+
104+
SpanBuilder builder = otelTracer.spanBuilder(spanName);
105+
Baggage baggage = null;
106+
if (parent != null) {
107+
OpenTelemetrySpanAdapter otelParent = (OpenTelemetrySpanAdapter) parent;
108+
builder.setParent(Context.current().with(otelParent.getSpan()));
109+
baggage = otelParent.getBaggage();
110+
} else {
111+
Context extractedContext = contextPropagators.getTextMapPropagator().extract(Context.root(), extractor,
112+
new TextMapGetter<SpanContextPropagationExtractor>() {
113+
@Override
114+
public Iterable<String> keys(SpanContextPropagationExtractor carrier) {
115+
return carrier.keys();
116+
}
117+
118+
@Override
119+
public String get(SpanContextPropagationExtractor carrier, String key) {
120+
return (String) carrier.get(key);
121+
}
122+
});
123+
builder.setParent(extractedContext);
124+
baggage = Baggage.fromContext(extractedContext);
125+
}
126+
127+
Op op = currentOp.get();
128+
if (op != null) {
129+
builder.setSpanKind(mapOpToKind(op));
130+
}
131+
132+
return new OpenTelemetrySpanAdapter(builder.startSpan(), baggage);
133+
}
134+
135+
private SpanKind mapOpToKind(Op op) {
136+
if (op == null) {
137+
return SpanKind.INTERNAL;
138+
}
139+
switch (op) {
140+
case EVENT_SENT:
141+
return SpanKind.CLIENT;
142+
case EVENT_RECEIVED:
143+
return SpanKind.SERVER;
144+
default:
145+
return SpanKind.INTERNAL;
146+
}
147+
}
148+
149+
@Override
150+
public void activate(org.apache.camel.telemetry.Span span) {
151+
((OpenTelemetrySpanAdapter) span).makeCurrent();
152+
}
153+
154+
@Override
155+
public void deactivate(org.apache.camel.telemetry.Span span) {
156+
((OpenTelemetrySpanAdapter) span).end();
157+
}
158+
159+
@Override
160+
public void close(org.apache.camel.telemetry.Span span) {
161+
((OpenTelemetrySpanAdapter) span).close();
162+
}
163+
164+
@Override
165+
public void inject(org.apache.camel.telemetry.Span span, SpanContextPropagationInjector injector,
166+
boolean includeTracing) {
167+
OpenTelemetrySpanAdapter otelSpan = (OpenTelemetrySpanAdapter) span;
168+
Context ctx = Context.current().with(otelSpan.getSpan());
169+
if (otelSpan.getBaggage() != null) {
170+
ctx = ctx.with(otelSpan.getBaggage());
171+
}
172+
contextPropagators.getTextMapPropagator().inject(ctx, injector, (carrier, key, value) -> carrier.put(key, value));
173+
174+
if (includeTracing) {
175+
injector.put("CAMEL_TRACE_ID", otelSpan.getSpan().getSpanContext().getTraceId());
176+
injector.put("CAMEL_SPAN_ID", otelSpan.getSpan().getSpanContext().getSpanId());
177+
}
178+
}
179+
}
180+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<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">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.camel.quarkus</groupId>
24+
<artifactId>camel-quarkus-build-parent-it</artifactId>
25+
<version>3.32.0-SNAPSHOT</version>
26+
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
27+
</parent>
28+
29+
<artifactId>camel-quarkus-integration-test-aws2-translate</artifactId>
30+
<name>Camel Quarkus :: Integration Tests :: AWS2 Translate</name>
31+
<description>The camel integration tests</description>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.apache.camel.quarkus</groupId>
36+
<artifactId>camel-quarkus-aws2-translate</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.quarkus</groupId>
40+
<artifactId>quarkus-resteasy</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.quarkus</groupId>
44+
<artifactId>quarkus-resteasy-jackson</artifactId>
45+
</dependency>
46+
47+
<!-- test dependencies -->
48+
<dependency>
49+
<groupId>io.quarkus</groupId>
50+
<artifactId>quarkus-junit</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>io.rest-assured</groupId>
55+
<artifactId>rest-assured</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.apache.camel.quarkus</groupId>
60+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.apache.camel.quarkus</groupId>
64+
<artifactId>camel-quarkus-integration-tests-support-aws2</artifactId>
65+
<type>test-jar</type>
66+
<scope>test</scope>
67+
</dependency>
68+
</dependencies>
69+
70+
<profiles>
71+
<profile>
72+
<id>native</id>
73+
<activation>
74+
<property>
75+
<name>native</name>
76+
</property>
77+
</activation>
78+
<properties>
79+
<quarkus.native.enabled>true</quarkus.native.enabled>
80+
</properties>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.apache.maven.plugins</groupId>
85+
<artifactId>maven-failsafe-plugin</artifactId>
86+
<executions>
87+
<execution>
88+
<goals>
89+
<goal>integration-test</goal>
90+
<goal>verify</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
</profile>
98+
<profile>
99+
<id>virtualDependencies</id>
100+
<activation>
101+
<property>
102+
<name>!noVirtualDependencies</name>
103+
</property>
104+
</activation>
105+
<dependencies>
106+
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
107+
<dependency>
108+
<groupId>org.apache.camel.quarkus</groupId>
109+
<artifactId>camel-quarkus-aws2-translate-deployment</artifactId>
110+
<version>${project.version}</version>
111+
<type>pom</type>
112+
<scope>test</scope>
113+
<exclusions>
114+
<exclusion>
115+
<groupId>*</groupId>
116+
<artifactId>*</artifactId>
117+
</exclusion>
118+
</exclusions>
119+
</dependency>
120+
</dependencies>
121+
</profile>
122+
<profile>
123+
<id>skip-testcontainers-tests</id>
124+
<activation>
125+
<property>
126+
<name>skip-testcontainers-tests</name>
127+
</property>
128+
</activation>
129+
<properties>
130+
<skipTests>true</skipTests>
131+
</properties>
132+
</profile>
133+
</profiles>
134+
135+
</project>

0 commit comments

Comments
 (0)