opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

No `links` are exported when using `InMemorySpanExporter`

Open millsp opened this issue 3 years ago • 9 comments
trafficstars

We want to use the InMemorySpanExporter to run our tests and snapshot the emitted spans. However, I am not seeing links array being filled with SpanContexts, while that works when exporting with OTLPTraceExporter (then seeing it in jaeger). It also works with ConsoleSpanExporter. I believe this is a bug, but I'd like to discuss it first (maybe it was a conscious decision?).

opentelemetry-js/packages/opentelemetry-sdk-trace-base/src/export/InMemorySpanExporter.ts

  • [x] This only affects the JavaScript OpenTelemetry library
  • [x] This may affect other libraries, but I would like to get opinions here first

millsp avatar Aug 03 '22 16:08 millsp

Maybe it's worth mentioning that the spans whose links aren't being exported are spans that are created via new Span (@opentelemetry/sdk-trace-base).

millsp avatar Aug 03 '22 17:08 millsp

creating new spans directly is not supported. Spans should be created using tracer.startSpan

dyladan avatar Aug 03 '22 19:08 dyladan

Thanks @dyladan, it looks like it does work now after resolving some other internal issue. We are using new Span and giving it the tracer. If that is not the intended way, how can I use tracer.startSpan to manually set its start time? (that's the reason why we use new Span). Thanks

millsp avatar Aug 03 '22 20:08 millsp

There is an optional span options object

dyladan avatar Aug 04 '22 12:08 dyladan

The span information is being transfered to the client from another service which is not allowed to emit traces. The client then is in charge of rebuilding those from traceId and spanId, while also setting the startTime, endTime and links (and name of course). For that reason, we are using new Span instead.

Is there a way to set a specific custom spanId via tracer.startSpan? I believe that was the only missing piece.

millsp avatar Aug 04 '22 20:08 millsp

No there is not, but this isn't a usecase we have really thought about. I would have not assumed someone trying to solve that usecase would have used the full SDK but rather just some of the components like the otlp-transformer and maybe an exporter

dyladan avatar Aug 05 '22 12:08 dyladan

solve that usecase would have used the full SDK

We are really only using the import { Span } from '@opentelemetry/sdk-trace-base' All the rest comes only from the standard api import { ... } from '@opentelemetry/api'

just some of the components like the otlp-transformer and maybe an exporter

In our case, we are releasing tracing for Prisma Client. Would that work given that it is a library? In other words, could we make it seamless for users, not to need custom exporters/transformers?

No there is not, but this isn't a usecase we have really thought about.

Should we transform this issue into a feature request instead?

Any other suggestions welcome :)

millsp avatar Aug 05 '22 17:08 millsp

Hey @dyladan, should I open a feature request?

millsp avatar Sep 02 '22 21:09 millsp

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.

github-actions[bot] avatar Nov 07 '22 06:11 github-actions[bot]

This issue was closed because it has been stale for 14 days with no activity.

github-actions[bot] avatar Jan 16 '23 06:01 github-actions[bot]