Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Specific values of span name is not checked, rather absence of high…
…-cardinality parts of requests (#96) * `net.host.name` and `net.host.port` are required for server Rest spans * `http.route` is required for server Rest spans * `net.peer.name` and `net.peer.host` are required for client Rest spans * error status of span is required for certain 4xx and 5xx requests Add TCK tests for telemetry tracing Co-authored-by: Patrik Dudits <patrik.dudits@payara.fish>
- Loading branch information
1 parent
22956d8
commit 12419b6
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...c/main/java/org/eclipse/microprofile/telemetry/tracing/tck/cdi/OpenTelemetryBeanTest.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,65 @@ | ||
/* | ||
* Copyright (c) 2016-2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* Licensed 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.eclipse.microprofile.telemetry.tracing.tck.cdi; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.testng.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.api.trace.Tracer; | ||
import jakarta.inject.Inject; | ||
|
||
class OpenTelemetryBeanTest extends Arquillian { | ||
|
||
private static final String SPAN_NAME = "MySpanName"; | ||
private static final String INVALID_SPAN_ID = "0000000000000000"; | ||
|
||
@Deployment | ||
public static WebArchive createDeployment() { | ||
return ShrinkWrap.create(WebArchive.class) | ||
.addAsResource(new StringAsset("otel.sdk.disabled=false"), | ||
"META-INF/microprofile-config.properties") | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
} | ||
|
||
@Inject | ||
OpenTelemetry openTelemetry; | ||
|
||
@Test | ||
void testOpenTelemetryBean() { | ||
Assert.assertNotNull(openTelemetry); | ||
} | ||
|
||
@Test | ||
void testSpanAndTracer() { | ||
Tracer tracer = openTelemetry.getTracer("instrumentation-test", "1.0.0"); | ||
Assert.assertNotNull(tracer); | ||
Span span = tracer.spanBuilder(SPAN_NAME).startSpan(); | ||
Assert.assertNotEquals(span.getSpanContext().getSpanId(), INVALID_SPAN_ID); | ||
} | ||
} |
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