From a023656428650986a0aa40ff355d3a6ee6720802 Mon Sep 17 00:00:00 2001 From: jiwen624 Date: Fri, 3 Dec 2021 15:13:39 -0800 Subject: [PATCH 1/2] fix NPE issue unboxing null --- build.gradle | 2 +- .../extensions/AppOpticsProfilingSpanProcessor.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 534782e2..8ac346a2 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ subprojects { opentelemetryJavaagent: "1.7.2", bytebuddy : "1.10.18", guava : "30.1-jre", - appopticsCore : "7.0.1", + appopticsCore : "7.0.2", appopticsMetrics : "7.0.0" ] versions.opentelemetryAlpha = "${versions.opentelemetry}-alpha" 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 fdab16b3..de8d7841 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java @@ -34,9 +34,10 @@ public void onStart(Context parentContext, ReadWriteSpan span) { SpanContext parentSpanContext = Span.fromContext(parentContext).getSpanContext(); if (!parentSpanContext.isValid() || parentSpanContext.isRemote()) { //then a root span of this service if (PROFILER_ENABLED) { - Metadata metadata = Util.buildMetadata(span.getSpanContext()); + SpanContext spanContext = span.getSpanContext(); + Metadata metadata = Util.buildMetadata(spanContext); if (metadata.isValid()) { - Profiler.addProfiledThread(Thread.currentThread(), metadata, metadata.getTraceId()); + Profiler.addProfiledThread(Thread.currentThread(), metadata, Metadata.bytesToHex(metadata.getTaskID())); span.setAttribute(SW_KEY_PREFIX + "ProfileSpans", 1); } } else { From 89f895452402f171875bb1b04d0b1cb1b72a2228 Mon Sep 17 00:00:00 2001 From: jiwen624 Date: Tue, 7 Dec 2021 10:40:49 -0800 Subject: [PATCH 2/2] remove profile by trace id in hex string --- .../extensions/AppOpticsProfilingSpanProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 de8d7841..b04a596b 100644 --- a/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java +++ b/custom/src/main/java/com/appoptics/opentelemetry/extensions/AppOpticsProfilingSpanProcessor.java @@ -57,7 +57,7 @@ public void onEnd(ReadableSpan span) { if (span.getSpanContext().isSampled()) { //only profile on sampled spans SpanContext parentSpanContext = span.toSpanData().getParentSpanContext(); if (!parentSpanContext.isValid() || parentSpanContext.isRemote()) { //then a root span of this service - Profiler.stopProfile(Util.toTraceId(span.getSpanContext().getTraceIdBytes())); + Profiler.stopProfile(span.getSpanContext().getTraceId()); } } }