forked from apache/camel-quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add traceProcessors option to OpenTelemetry extension
Fixes apache#6143
- Loading branch information
1 parent
4188a3a
commit 82139ea
Showing
9 changed files
with
190 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...est/java/org/apache/camel/quarkus/component/opentelemetry/it/OpenTelemetryTestHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.quarkus.component.opentelemetry.it; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import io.restassured.RestAssured; | ||
|
||
class OpenTelemetryTestHelper { | ||
private OpenTelemetryTestHelper() { | ||
// Utility class | ||
} | ||
|
||
static List<Map<String, String>> getSpans() { | ||
return RestAssured.given() | ||
.get("/opentelemetry/exporter/spans") | ||
.then() | ||
.statusCode(200) | ||
.extract() | ||
.body() | ||
.jsonPath() | ||
.get(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...a/org/apache/camel/quarkus/component/opentelemetry/it/OpenTelemetryTraceProcessorsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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.quarkus.component.opentelemetry.it; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
class OpenTelemetryTraceProcessorsIT extends OpenTelemetryTraceProcessorsTest { | ||
} |
57 changes: 57 additions & 0 deletions
57
...org/apache/camel/quarkus/component/opentelemetry/it/OpenTelemetryTraceProcessorsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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.quarkus.component.opentelemetry.it; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import io.opentelemetry.api.trace.SpanKind; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.apache.camel.quarkus.component.opentelemetry.it.OpenTelemetryTestHelper.getSpans; | ||
import static org.awaitility.Awaitility.await; | ||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@TestProfile(TraceProcessorsTestProfile.class) | ||
@QuarkusTest | ||
class OpenTelemetryTraceProcessorsTest { | ||
@Test | ||
void traceProcessors() { | ||
RestAssured.get("/opentelemetry/trace") | ||
.then() | ||
.statusCode(200) | ||
.body(equalTo("Traced direct:start")); | ||
|
||
// Verify the span hierarchy is JAX-RS Service -> Direct Endpoint -> SetBody | ||
await().atMost(30, TimeUnit.SECONDS).pollDelay(50, TimeUnit.MILLISECONDS).until(() -> getSpans().size() == 4); | ||
List<Map<String, String>> spans = getSpans(); | ||
assertEquals(4, spans.size()); | ||
assertEquals(SpanKind.INTERNAL.name(), spans.get(0).get("kind")); | ||
assertEquals("camel-setBody", spans.get(0).get("component")); | ||
assertEquals(spans.get(1).get("spanId"), spans.get(0).get("parentId")); | ||
assertEquals(SpanKind.INTERNAL.name(), spans.get(1).get("kind")); | ||
assertEquals(spans.get(2).get("spanId"), spans.get(1).get("parentId")); | ||
assertEquals(SpanKind.CLIENT.name(), spans.get(2).get("kind")); | ||
assertEquals(spans.get(3).get("spanId"), spans.get(2).get("parentId")); | ||
assertEquals(SpanKind.SERVER.name(), spans.get(3).get("kind")); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../java/org/apache/camel/quarkus/component/opentelemetry/it/TraceProcessorsTestProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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.quarkus.component.opentelemetry.it; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
|
||
public class TraceProcessorsTestProfile implements QuarkusTestProfile { | ||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Map.of("quarkus.camel.opentelemetry.trace-processors", "true"); | ||
} | ||
} |