Skip to content

[Feat]: Propagate open telemetry context to agent execution for consolidated tracing #698

Description

@vietk

Is your feature request related to a problem? Please describe.

Hello,

A2A Java SDK supports server OpenTelemetry thanks to OpenTelemetryRequestHandlerDecorator.
So far I managed to see sendMessage span in the traces in Tempo when I use sendMessage to my a2a application which is nice.
However, if I had my own custom span in an agent execution of my AgentExecutor, the whole trace is not consolidated with server span, it's 2 independent traces.
The main reason is that the server handling is executed inside a Vert.x router but the agent execution is done using a specific ExecutorService backed by A2A Internal executor.
Then, when the server handoff the execution to the agent executor, the opentelemetry context is not propagated and then is lost.
It results of having two different traces with their own spans and they are not linked at all.

  • The server span in a trace (provided by a2a)
  • My custom span in a trace

I would expect a single trace formed of two spans

Describe the solution you'd like

Opentelemetry context MUST be propagated between threads to ensure well formed traces with a valid parent span and the whole trace.
Since opentelemetry feature is not part of the server common modules, it's possible to define a SPI to implement for context propagation and implement it from the opentelemetry extra modules.

Describe alternatives you've considered

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added theissue type on Mar 4, 2026
  2. vietk commented on Mar 4, 2026

    @vietk
    Author

    I was wondering if it's a bug or a feature, I opt for a feature :D

    Would you agree if I contribute to this issue, I already have some code implementing the solution I described.

  3. salaboy commented on Mar 4, 2026

    @salaboy

    @vietk I am really interested in this.. do you have something working? I am trying to achieve the same thing here.

  4. vietk commented on Mar 4, 2026

    @vietk
    Author

    Actually I think yes, I will open a Pull Request for sharing the implementation

  5. vietk commented on Mar 4, 2026

    @vietk
    Author
  6. salaboy commented on Mar 4, 2026

    @salaboy

    @vietk this is great.. checkout the gemini code comments.. I think if you add those improvements, I can take that code and test on my side too.

  7. ehsavoie commented on Mar 4, 2026

    @ehsavoie
    Collaborator

    I'm wondering if the proper way would be to use a ManagedExecutorService instead so that context propagation would be managed by Quarkus itself

  8. vietk commented on Mar 4, 2026

    @vietk
    Author

    I thought about the same, but I don't know exactly at which point the project should be tied to the Quarkus ecosystem and if you need portability (ex: spring boot?) even if CDI + Vertx Routes is already a big signal.
    So yes, if I was sure of the orientation, I would have use ManagedExecutorService

  9. ehsavoie commented on Mar 4, 2026

    @ehsavoie
    Collaborator

    We rely on CDI for the injection of the executorservice so in my opinion we could have that in the otel extra

  10. vietk commented on Mar 5, 2026

    @vietk
    Author

    That would be a possibility.
    But why limiting that to the OTEL extra module? that would make the module opinionated towards Quarkus and not usable for another framework like spring or helidon.
    What you consider will be backed by a quarkus extension described in #370 and the proposal quarkiverse/quarkus-langchain4j#1994, but I think you are aware.
    That would bring the best solution to support your idea and the framework isolation but many more (like a non-blocking agent execution 😉)

    That being said, I need this fix/feature for a couple of internal demos so for a short term solution I think the SPI solution is good 😉, WDYT?

  11. salaboy commented on Mar 5, 2026

    @salaboy

    That would be a possibility. But why limiting that to the OTEL extra module? that would make the module opinionated towards Quarkus and not usable for another framework like spring or helidon. What you consider will be backed by a quarkus extension described in #370 and the proposal quarkiverse/quarkus-langchain4j#1994, but I think you are aware. That would bring the best solution to support your idea and the framework isolation but many more (like a non-blocking agent execution 😉)

    That being said, I need this fix/feature for a couple of internal demos so for a short term solution I think the SPI solution is good 😉, WDYT?

    I am in a similar situation here, I think this solution is good enough and framework agnostic.

  12. ehsavoie commented on Mar 5, 2026

    @ehsavoie
    Collaborator

    I tend to disagree, the ManagedExecutorService is not Quarkus specific but MP-Context-propagation or JakartaEE Concurrency (since JakartaEE11).
    For Spring it is not clear but since it is not using CDI it would have to provide its own ExecutorService wrapper that would pass on the context.

  13. salaboy commented on Mar 5, 2026

    @salaboy

    @ehsavoie it would be awesome to have this included in Alpha4, I am using this with Quarkus, I am not sure @vietk , are you using this with Spring?

  14. vietk commented on Mar 5, 2026

    @vietk
    Author

    I am using Quarkus as well

  15. vietk commented on Mar 5, 2026

    @vietk
    Author

    I tend to disagree, the ManagedExecutorService is not Quarkus specific but MP-Context-propagation or JakartaEE Concurrency (since JakartaEE11). For Spring it is not clear but since it is not using CDI it would have to provide its own ExecutorService wrapper that would pass on the context.

    Ah nice ! I thought it was a Quarkus feature, so I could revise my assessment.
    But when I dig in MP context propagation I saw the spec was deprecated I haven't followed the JakartaEE concurrency track because it started to takes a bit of time on my side and decided another approach.

    In this case I will try to find some time to revise my proposal

  16. added a commit that references this issue on Mar 9, 2026
    5e13341
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions