opentelemetry-js
opentelemetry-js copied to clipboard
No `links` are exported when using `InMemorySpanExporter`
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
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).
creating new spans directly is not supported. Spans should be created using tracer.startSpan
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
There is an optional span options object
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.
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
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 :)
Hey @dyladan, should I open a feature request?
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.
This issue was closed because it has been stale for 14 days with no activity.