From 732466c0a94ecc3c52d2f9d6655a1b7c56a6440a Mon Sep 17 00:00:00 2001 From: jiwen624 Date: Fri, 26 Nov 2021 10:53:46 -0800 Subject: [PATCH 1/3] print stacktrace for OboeException --- .../src/main/java/com/appoptics/opentelemetry/core/Util.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java b/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java index b62301ee..ebbb7fc1 100644 --- a/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java +++ b/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java @@ -60,7 +60,8 @@ public static Metadata buildMetadata(SpanContext context) { try { return new Metadata(W3CContextToHexString(context)); } catch (OboeException e) { - return null; + logger.warn("Failed to get AO metadata from span context: " + W3CContextToHexString(context), e); + return new Metadata(); } } From e273938e1257d2a5e5a10d413fd085270f0f35cf Mon Sep 17 00:00:00 2001 From: jiwen624 Date: Tue, 30 Nov 2021 10:37:03 -0800 Subject: [PATCH 2/3] check metadata before adding it to profiler --- .../extensions/AppOpticsProfilingSpanProcessor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java index 9c7d956f..fdab16b3 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java @@ -35,8 +35,10 @@ public void onStart(Context parentContext, ReadWriteSpan span) { if (!parentSpanContext.isValid() || parentSpanContext.isRemote()) { //then a root span of this service if (PROFILER_ENABLED) { Metadata metadata = Util.buildMetadata(span.getSpanContext()); - Profiler.addProfiledThread(Thread.currentThread(), metadata, metadata.getTraceId()); - span.setAttribute(SW_KEY_PREFIX + "ProfileSpans", 1); + if (metadata.isValid()) { + Profiler.addProfiledThread(Thread.currentThread(), metadata, metadata.getTraceId()); + span.setAttribute(SW_KEY_PREFIX + "ProfileSpans", 1); + } } else { span.setAttribute(SW_KEY_PREFIX + "ProfileSpans", -1); //profiler disabled } From 5bfeda8d8b6946c770bef065473ff4231ca4e650 Mon Sep 17 00:00:00 2001 From: jiwen624 Date: Tue, 30 Nov 2021 10:42:05 -0800 Subject: [PATCH 3/3] lower debug level to info --- .../src/main/java/com/appoptics/opentelemetry/core/Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java b/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java index ebbb7fc1..5fe1ba7b 100644 --- a/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java +++ b/core-bootstrap/src/main/java/com/appoptics/opentelemetry/core/Util.java @@ -60,7 +60,7 @@ public static Metadata buildMetadata(SpanContext context) { try { return new Metadata(W3CContextToHexString(context)); } catch (OboeException e) { - logger.warn("Failed to get AO metadata from span context: " + W3CContextToHexString(context), e); + logger.info("Failed to get AO metadata from span context: " + W3CContextToHexString(context), e); return new Metadata(); } }