-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helper methods for manual spans in mutiny pipelines #45478
base: main
Are you sure you want to change the base?
Conversation
In a traditional blocking and synchronous framework the opentelemetry context is attached to ThreadLocal. In reactive programming, where multiple processings share the same event-loop thread, one has to use Vert.x duplicated contexts instead (see https://quarkus.io/guides/duplicated-context). wrapWithSpan ensures that the pipeline is executed on a duplicated context (If the current context already is duplicated, it will stay the same. Therefore, nested calls to wrapWithSpan will all run on the same vert.x context). Another difficulty of mutiny pipelines is, that usually only one parameter flows through the pipeline. In oder to end spans and to close the current scope at the end of the pipeline, span and scope must be stored in the mutiny-context. They are stored in a stack datastructure so that multiple nested spans/scopes are closed in the correct order. inspired by Jan Peremsky (https://github.com/jan-peremsky/quarkus-reactive-otel/blob/c74043d388ec4df155f466f1d6938931c3389b70/src/main/java/com/fng/ewallet/pex/Tracer.java) and edeandrea (https://github.com/quarkusio/quarkus-super-heroes/blob/main/event-statistics/src/main/java/io/quarkus/sample/superheroes/statistics/listener/SuperStats.java)
Thanks for your pull request! Your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
/cc @brunobat (opentelemetry), @radcortez (opentelemetry) |
|
||
@BeforeEach | ||
public void setup() { | ||
GlobalOpenTelemetry.resetForTest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, Please use the injected OpenTelemetry instance. No need for any of this setup.
You can also inject the tracer and span.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to do that, I would have to use QuarkusUnitTest-Extension, right?
Unfortunately QuarkusUnitTest together with ParameterizedTests does not seem to work. I think I would then do only one of the tests on all three contexts, and the rest of the tests on root-context only.
What do you think @brunobat? Or do I overlook a simpler solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have pushed an update with the altered tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few examples that work with parameterised tests:
quarkus/extensions/funqy/funqy-http/deployment/src/test/java/io/quarkus/funqy/test/SimpleTest.java
Line 17 in 01bee69
public class SimpleTest { |
and
Line 21 in 5180a5a
public class ExposedCloudEventTest { |
This comment has been minimized.
This comment has been minimized.
🎊 PR Preview f010b20 has been successfully built and deployed to https://quarkus-pr-main-45478-preview.surge.sh/version/main/guides/
|
This comment has been minimized.
This comment has been minimized.
I will squash with the previous commit once everything is approved
Status for workflow
|
Status | Name | Step | Failures | Logs | Raw logs | Build scan |
---|---|---|---|---|---|---|
✖ | Initial JDK 17 Build | Build |
Failures | Logs | Raw logs | 🔍 |
You can consult the Develocity build scans.
Failures
⚙️ Initial JDK 17 Build #
- Failing: extensions/opentelemetry/deployment
! Skipped: devtools/bom-descriptor-json docs extensions/liquibase-mongodb/deployment and 62 more
📦 extensions/opentelemetry/deployment
✖ Failed to execute goal net.revelc.code:impsort-maven-plugin:1.12.0:check (check-imports) on project quarkus-opentelemetry-deployment: Imports are not sorted in /home/runner/work/quarkus/quarkus/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/traces/MutinyTracingHelperTest.java
Status for workflow
|
I need to read the motivation behind the A helper method like this doesn't need to be redundant, but I don't see why it wouldn't be implemented the same way. As for what has been done in |
@ozangunalp My usecase looks roughly like this
it might be possible to solve it like this
however, I have 2 problems with that
|
Fix #44411
In a traditional blocking and synchronous framework the opentelemetry context is attached to ThreadLocal. In reactive programming, where multiple processings share the same event-loop thread, one has to use Vert.x duplicated contexts instead (see https://quarkus.io/guides/duplicated-context). wrapWithSpan ensures that the pipeline is executed on a duplicated context (If the current context already is duplicated, it will stay the same. Therefore, nested calls to wrapWithSpan will all run on the same vert.x context).
Another difficulty of mutiny pipelines is, that usually only one parameter flows through the pipeline. In oder to end spans and to close the current scope at the end of the pipeline, span and scope must be stored in the mutiny-context. They are stored in a stack datastructure so that multiple nested spans/scopes are closed in the correct order.
inspired by Jan Peremsky (https://github.com/jan-peremsky/quarkus-reactive-otel/blob/c74043d388ec4df155f466f1d6938931c3389b70/src/main/java/com/fng/ewallet/pex/Tracer.java) and edeandrea (https://github.com/quarkusio/quarkus-super-heroes/blob/main/event-statistics/src/main/java/io/quarkus/sample/superheroes/statistics/listener/SuperStats.java)