Skip to content
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

Create producer span from spring integration instrumentation #4932

Merged
merged 5 commits into from
Jan 5, 2022

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Dec 17, 2021

Currently we create producer span only from rabbitmq, kafka, jms and rocketmq instrumentations. Due to this producer spans are not created when an unsupported messaging library or a homegrown solution is used. This pr adds a flag that allows creating producer span in spring integration instrumentation which would create the span regardless of the underlying messaging library. The downside of this is that in spring instrumentation channel interceptor we have very little info available and can't fill many of the messaging semantic attributes. Also we can't enable this flag by default as it would suppress the producer span created by the messaging library that would have access to more semantic attributes. Another surprising issue with creating producer span in spring integration channel interceptor is that it is hard to tell whether the current channel is an input or output channel, thus we don't generally know whether we should be creating consumer or producer span. Luckily spring cloud stream adds a type attribute to its channels which describes the direction of the channel. We only create the producer span when the current channel is from spring cloud stream and we know that it is an output channel. If needed we could extend this to support more channel types by using a similar logic to what spring cloud sleuth uses, if channel is a DirectChannel then treat it as consume, otherwise producer.

laurit and others added 3 commits January 4, 2022 16:53
…/java/io/opentelemetry/instrumentation/spring/integration/TracingChannelInterceptor.java

Co-authored-by: Mateusz Rzeszutek <[email protected]>
@laurit laurit force-pushed the spring-integration-producer branch from 57c56f7 to b540e29 Compare January 4, 2022 14:53
@@ -17,8 +17,9 @@ In this guide we will be using a running example. In section one and two, we wil
| System property | Type | Default | Description |
|---|---|---|---|
| `otel.instrumentation.spring-integration.global-channel-interceptor-patterns` | List | `*` | An array of Spring channel name patterns that will be intercepted. See [Spring Integration docs](https://docs.spring.io/spring-integration/reference/html/channel.html#global-channel-configuration-interceptors) for more details. |
| `otel.instrumentation.spring-integration.producer.enabled` | Boolean | `false` | Create producer span in spring integration instrumentation when message is written into an output channel. Detecting output channels works only for [Spring Cloud Stream](https://spring.io/projects/spring-cloud-stream) `DirectWithAttributesChannel`. Use this flag only when you are using a messaging library that does not have instrumentation to create producer spans. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]>
@laurit laurit requested a review from a team January 5, 2022 09:22
Comment on lines +54 to +56
jvmArgs("-Dotel.instrumentation.rabbitmq.enabled=false")
jvmArgs("-Dotel.instrumentation.spring-rabbit.enabled=false")
jvmArgs("-Dotel.instrumentation.spring-integration.producer.enabled=true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@trask trask merged commit 175d1bf into open-telemetry:main Jan 5, 2022
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
…lemetry#4932)

* Add an option to create producer span from spring integration instrumentation

* Update instrumentation/spring/spring-integration-4.1/library/src/main/java/io/opentelemetry/instrumentation/spring/integration/TracingChannelInterceptor.java

Co-authored-by: Mateusz Rzeszutek <[email protected]>

* add null check

* add doc

* Update instrumentation/spring/README.md

Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]>

Co-authored-by: Mateusz Rzeszutek <[email protected]>
Co-authored-by: Fabrizio Ferri-Benedetti <[email protected]>
@laurit laurit deleted the spring-integration-producer branch July 6, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants