File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
main/java/co/elastic/otel/common
test/java/co/elastic/otel/common Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -103,10 +103,14 @@ public static ReadableSpan getFor(ReadableSpan span) {
103103 * parents
104104 * <li>The provided span or one if its parents is a delayed inferred span where the parent was
105105 * provided as a remote span
106+ * <li>The provided span is a remote span
106107 * </ul>
107108 */
108109 @ Nullable
109110 public static ReadableSpan getFor (Span span ) {
111+ if (span .getSpanContext ().isRemote ()) {
112+ return null ;
113+ }
110114 return getFor ((ReadableSpan ) span );
111115 }
112116
Original file line number Diff line number Diff line change @@ -97,6 +97,18 @@ public void checkRemoteParent() {
9797 assertThat (LocalRootSpan .getFor ((ReadableSpan ) span )).isSameAs (span );
9898 }
9999
100+ @ Test
101+ public void checkRemoteSpan () {
102+ Map <String , String > headers = new HashMap <>();
103+ headers .put ("traceparent" , "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01" );
104+ Context remoteParent =
105+ sdk .getPropagators ()
106+ .getTextMapPropagator ()
107+ .extract (Context .root (), headers , new MapGetter ());
108+
109+ assertThat (LocalRootSpan .getFor (Span .fromContext (remoteParent ))).isNull ();
110+ }
111+
100112 @ Test
101113 public void checkInferredSpanDetected () {
102114 Map <String , String > headers = new HashMap <>();
You can’t perform that action at this time.
0 commit comments