helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.49k stars 566 forks source link

Support Span links in Tracing #9247

Open boris-senapt opened 2 weeks ago

boris-senapt commented 2 weeks ago

OpenTelemetry supports the concept of Span links, this allows related to be linked - e.g. if a batch runs multiple requests together.

Could support for this be added to Helidon Tracing?

Environment Details


Problem Description

Could a method be provided on io.helidon.tracing.Span.Builder to allow linked of spans, which for OpenTelemetry would delegate to io.opentelemetry.api.trace.SpanBuilder#addLink(io.opentelemetry.api.trace.SpanContext).


Since 1.37 Opentelemetry supports adding links to active spans too - this would also be very helpful, but currently Helidon depends on 1.22.

https://javadoc.io/doc/io.opentelemetry/opentelemetry-api/latest/io/opentelemetry/api/trace/Span.html#addLink(io.opentelemetry.api.trace.SpanContext)

tjquinno commented 2 weeks ago

This could be tricky, because Helidon supports multiple implementations of tracing, not just OTel. Ideally additions to the Helidon neutral tracing API apply equally well to all providers, not just one.

That said, If you are willing to bind your own code to the OTel types, you can add links yourself today using the Span.builder#unwrap method to get access to the OTel SpanBuilder.