Skip to content

Commit

Permalink
enable parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samvaity committed Feb 23, 2021
1 parent d2f79ae commit 5040e68
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 12 additions & 0 deletions sdk/core/azure-core-tracing-opentelemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@
</compilerArgs>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version> <!-- {x-version-update;org.apache.maven.plugins:maven-surefire-plugin;external_dependency} -->
<configuration>
<systemPropertyVariables>
<!-- Parallel runs disabled due to concurrency issues when registering the global tracer. -->
<junit.jupiter.execution.parallel.enabled>false</junit.jupiter.execution.parallel.enabled>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.tracing.ProcessKind;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.api.trace.Span;
Expand All @@ -34,7 +33,7 @@
* requests.
*/
public class OpenTelemetryTracer implements com.azure.core.util.tracing.Tracer {
private static final Tracer TRACER = GlobalOpenTelemetry.getTracer("Azure-OpenTelemetry");
private final Tracer TRACER = GlobalOpenTelemetry.getTracer("Azure-OpenTelemetry");

// standard attributes with AMQP request
static final String AZ_NAMESPACE_KEY = "az.namespace";
Expand Down Expand Up @@ -285,7 +284,7 @@ private Context startScopedSpan(String spanName, Context context) {
* @param spanContext The remote parent context of the returned Span.
* @return A {@link Span} with parent being the remote {@link Span} designated by the {@link SpanContext}.
*/
private static Span startSpanWithRemoteParent(String spanName, SpanContext spanContext) {
private Span startSpanWithRemoteParent(String spanName, SpanContext spanContext) {
SpanBuilder spanBuilder = TRACER.spanBuilder(spanName)
.setParent(io.opentelemetry.context.Context.root().with(Span.wrap(spanContext)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ public class OpenTelemetryTracerTest {
TRACE_ID_OFFSET + TRACE_ID_HEX_SIZE + TRACEPARENT_DELIMITER_SIZE;
private static final int TRACE_OPTION_OFFSET =
SPAN_ID_OFFSET + SPAN_ID_HEX_SIZE + TRACEPARENT_DELIMITER_SIZE;
private static OpenTelemetrySdk openTelemetry;
private static OpenTelemetryTracer openTelemetryTracer;

private Tracer tracer;
private OpenTelemetryTracer openTelemetryTracer;
private Context tracingContext;
private Span parentSpan;
private Scope scope;
Expand All @@ -94,13 +93,13 @@ public static void setUpAll() {
// reset the global object before attempting to register
GlobalOpenTelemetry.resetForTest();
// Register the global tracer.
openTelemetry = OpenTelemetrySdk.builder().buildAndRegisterGlobal();
OpenTelemetrySdk.builder().buildAndRegisterGlobal();
}

@BeforeEach
public void setUp() {
// Get the global singleton Tracer object.
tracer = openTelemetry.getTracer("TracerSdkTest");
tracer = GlobalOpenTelemetry.getTracer("TracerSdkTest");
// Start user parent span.
parentSpan = tracer.spanBuilder(PARENT_SPAN_KEY).startSpan();
scope = parentSpan.makeCurrent();
Expand Down

0 comments on commit 5040e68

Please sign in to comment.