This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 2dfe37b620 Start spans when inside a valid span (#2611) 2dfe37b620 is described below commit 2dfe37b620ca9163bccaf4f4caea96923d5ecc0d Author: Christopher Tubbs <ctubb...@apache.org> AuthorDate: Mon Apr 11 20:36:22 2022 -0400 Start spans when inside a valid span (#2611) Start a span, even if tracing is disabled on our end, if we find our code inside a valid span. This implies that we're running inside a user's span, started in user code. This prevents us from needing to expose Accumulo internal enabling/disabling utilities to client code. Users can enable client-side tracing merely by wrapping our code with their own valid spans. --- core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java b/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java index ff91f04dd0..383022993d 100644 --- a/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java +++ b/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java @@ -110,7 +110,7 @@ public class TraceUtil { private static Span startSpan(Class<?> caller, String spanName, SpanKind kind, Map<String,String> attributes, TInfo tinfo) { - if (!enabled) { + if (!enabled && !Span.current().getSpanContext().isValid()) { return Span.getInvalid(); } final String name = String.format(SPAN_FORMAT, caller.getSimpleName(), spanName); @@ -153,8 +153,7 @@ public class TraceUtil { */ public static TInfo traceInfo() { TInfo tinfo = new TInfo(); - W3CTraceContextPropagator.getInstance().inject(Context.current(), tinfo, - (carrier, key, value) -> carrier.putToHeaders(key, value)); + W3CTraceContextPropagator.getInstance().inject(Context.current(), tinfo, TInfo::putToHeaders); return tinfo; }