diff --git a/opentracing-shim/src/main/java/io/opentelemetry/opentracingshim/TracerShim.java b/opentracing-shim/src/main/java/io/opentelemetry/opentracingshim/TracerShim.java index caec9b7c949..82b48410df1 100644 --- a/opentracing-shim/src/main/java/io/opentelemetry/opentracingshim/TracerShim.java +++ b/opentracing-shim/src/main/java/io/opentelemetry/opentracingshim/TracerShim.java @@ -80,12 +80,13 @@ public SpanBuilder buildSpan(String operationName) { @Override public void inject(SpanContext context, Format format, C carrier) { if (context == null) { - logger.log(Level.INFO, "Cannot inject a null span context."); + logger.log(Level.WARNING, "Cannot inject a null span context."); return; } SpanContextShim contextShim = ShimUtil.getContextShim(context); if (contextShim == null) { + logger.log(Level.WARNING, "Cannot inject a null span context shim."); return; } @@ -107,7 +108,7 @@ public SpanContext extract(Format format, C carrier) { } } catch (RuntimeException e) { logger.log( - Level.INFO, + Level.WARNING, "Exception caught while extracting span context; returning null. " + "Exception: [{0}] Message: [{1}]", new String[] {e.getClass().getName(), e.getMessage()}); @@ -127,7 +128,7 @@ public void close() { try { ((Closeable) provider).close(); } catch (RuntimeException | IOException e) { - logger.log(Level.INFO, "Exception caught while closing TracerProvider.", e); + logger.log(Level.WARNING, "Exception caught while closing TracerProvider.", e); } } } diff --git a/opentracing-shim/src/test/java/io/opentelemetry/opentracingshim/TracerShimTest.java b/opentracing-shim/src/test/java/io/opentelemetry/opentracingshim/TracerShimTest.java index 8a961288c23..769dba336b0 100644 --- a/opentracing-shim/src/test/java/io/opentelemetry/opentracingshim/TracerShimTest.java +++ b/opentracing-shim/src/test/java/io/opentelemetry/opentracingshim/TracerShimTest.java @@ -357,6 +357,12 @@ void extract_onlyBaggage() { assertThat(spanContextShim.getBaggage()).isEqualTo(baggage); } + @Test + void extract_null_spanctx() { + SpanContext spanContext = tracerShim.extract(Format.Builtin.TEXT_MAP, null); + assertThat(spanContext).isNull(); + } + @Test void close_OpenTelemetrySdk() { SdkTracerProvider sdkProvider = mock(SdkTracerProvider.class);