reactor / reactor-core

Non-Blocking Reactive Foundation for the JVM

Home Page:http://projectreactor.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenTelemetry Agent and Reactor Core explanations

almogtavor opened this issue · comments

Documentation Issue

I would like to inquire about the use of the OpenTelemetry agent for automatic instrumentation in conjunction with Reactor Core. Specifically, I have the following questions:

  1. Do you recommend or support using the OpenTelemetry agent for automatic instrumentation with Reactor Core? If not, could you please provide insights into the reasons behind this recommendation, considering that the OpenTelemetry agent can instrument and capture data that Reactor alone may not be able to, such as the underlying database queries?

  2. When using the OpenTelemetry agent with Reactor, I have encountered issues related to the Reactor context. Could you provide guidance on how to manually address and resolve such issues? Any best practices or tips for ensuring compatibility between the agent and Reactor's context management?

  3. I faced problems when combining the OpenTelemetry agent with the publishOn operator in Reactor (specifically .parallel().runOn(Schedulers.parallel())). Could you shed light on any specific challenges or considerations in this scenario? Additionally, I implemented a workaround by passing an object containing the Context and SpanContext from OpenTelemetry and invoking .makeCurrent() after using the publishOn operator to restore the original context. Are there alternative approaches or suggestions to handle this situation more effectively?

Improvement Suggestion

It would be beneficial to provide guidance or recommendations in the Reactor Core documentation regarding the integration of the OpenTelemetry agent and how to address potential issues related to Reactor context management and operators like publishOn when using the agent.

Additional context

Any additional insights, examples, or documentation references related to this issue would be greatly appreciated. Thank you for your assistance.

Thanks for reaching out. I think your questions are best suited for the OpenTelemetry maintainers. Project Reactor and the Spring ecosystem integrate natively with Micrometer and Micrometer Tracing. The latter also has an integration for OpenTelemetry instrumentation. What we recommend is using the Micrometer portfolio, which brought us the context-propagation library for interacting with ThreadLocal state, on top of which tracing libraries are usually built.

When it comes to discussing ideas that you explore with .makeCurrent(), I can recommend our blog post series on this subject and the risks that are involved (the link contains links to the second and third blog post).

The OpenTelemetry agent seems to have coverage of reactor-core 3.1, which is outdated. We currently support versions from the 3.4.x line, with the recent release being 3.6.1. Please do reach out to the maintainers of the OpenTelemetry agent and feel free to mention myself or @OlegDokuka if we can provide more insight on the context propagation in Project Reactor.

Having that said, I'm closing this issue, as it's not within our scope to document the various integrations.