File tree Expand file tree Collapse file tree
docs/apidiffs/current_vs_latest
main/java/io/opentelemetry/sdk/trace
test/java/io/opentelemetry/sdk/trace Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11Comparing source compatibility of against
2+ **** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.trace.ReadableSpan (not serializable)
3+ === CLASS FILE FORMAT VERSION: 52.0 <- 52.0
4+ +++* NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.trace.SpanContext getParentSpanContext()
25***! MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.trace.samplers.SamplingResult (not serializable)
36 === CLASS FILE FORMAT VERSION: 52.0 <- 52.0
47 +++! NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.samplers.SamplingResult drop()
Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ public interface ReadableSpan {
2323 */
2424 SpanContext getSpanContext ();
2525
26+ /**
27+ * Returns the parent {@link SpanContext} of the {@link Span}, or {@link SpanContext#getInvalid()}
28+ * if this is a root span.
29+ *
30+ * @return the parent {@link SpanContext} of the {@link Span}
31+ */
32+ SpanContext getParentSpanContext ();
33+
2634 /**
2735 * Returns the name of the {@code Span}.
2836 *
Original file line number Diff line number Diff line change @@ -202,6 +202,11 @@ public SpanContext getSpanContext() {
202202 return context ;
203203 }
204204
205+ @ Override
206+ public SpanContext getParentSpanContext () {
207+ return parentSpanContext ;
208+ }
209+
205210 /**
206211 * Returns the name of the {@code Span}.
207212 *
@@ -451,10 +456,6 @@ private StatusData getSpanDataStatus() {
451456 }
452457 }
453458
454- SpanContext getParentSpanContext () {
455- return parentSpanContext ;
456- }
457-
458459 Resource getResource () {
459460 return resource ;
460461 }
Original file line number Diff line number Diff line change @@ -214,10 +214,26 @@ void toSpanData_RootSpan() {
214214 } finally {
215215 span .end ();
216216 }
217+ assertThat (span .getParentSpanContext ().isValid ()).isFalse ();
217218 SpanData spanData = span .toSpanData ();
218219 assertThat (SpanId .isValid (spanData .getParentSpanId ())).isFalse ();
219220 }
220221
222+ @ Test
223+ void toSpanData_ChildSpan () {
224+ RecordEventsReadableSpan span = createTestSpan (SpanKind .INTERNAL );
225+ try {
226+ spanDoWork (span , null , null );
227+ } finally {
228+ span .end ();
229+ }
230+ assertThat (span .getParentSpanContext ().isValid ()).isTrue ();
231+ assertThat (span .getParentSpanContext ().getTraceId ()).isEqualTo (traceId );
232+ assertThat (span .getParentSpanContext ().getSpanId ()).isEqualTo (parentSpanId );
233+ SpanData spanData = span .toSpanData ();
234+ assertThat (spanData .getParentSpanId ()).isEqualTo (parentSpanId );
235+ }
236+
221237 @ Test
222238 void toSpanData_WithInitialAttributes () {
223239 RecordEventsReadableSpan span = createTestSpanWithAttributes (attributes );
You can’t perform that action at this time.
0 commit comments