open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.68k stars 772 forks source link

How to determine Parent Span from a ReadableSpan, check if Parent Span is Remote? #4850

Open jj22ee opened 2 months ago

jj22ee commented 2 months ago

I would like to determine if the parent span (if it exists) is Remote, given a ReadableSpan. This information is needed in my implementation of a SpanExporter's export function.

In Python and Java, this is easy. We can get the parent span from the current span, then check the contex's isRemote value.

However, in JS, the ReadableSpan span only provides the parent's Id: https://github.com/open-telemetry/opentelemetry-js/blob/0f6363ae357491430c4e0afdc6672e9dae57f2bd/packages/opentelemetry-sdk-trace-base/src/export/ReadableSpan.ts#L33

If we are able to get a span given an Id, this would help, but I haven't found a way to get a span given a span Id in the OTel JavaScript APIs.

Is there a workaround, or can OTel JS be updated to be able to get the parent span context given a ReadableSpan?

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.