getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.15k stars 434 forks source link

Spring Boot Queue Integration #3458

Open adinauer opened 4 months ago

adinauer commented 4 months ago

Problem Statement

Automatically instrument Spring Boot queues. Might require different implementation for JMS, AMQP and other integrations.

Solution Brainstorm

One major problems seems to be supported characters for headers / properties. Specifically dash/hyphen/- is not supported by Java JMS API (setStringProperty). We need it to support tracing using sentry-trace. While it'd be possible to replace the character in the Java SDK, we'd have to then support this way of naming the header/property in all other SDKs.

OpenTelemetry seems to deal with this by replacing the - with a special String (__dash__). However they only seem to be doing this for their Java SDK, so they'll likely run into problems with different SDKs for producer vs. consumer.

The easiest way forward is to not fully support tracing when using JMS until we have a different set of headers that can be used instead.

lbloder commented 3 months ago

Tested with org.springframework.boot:spring-boot-starter-artemis. Writing to the queue will enforce the jms specification and throw an exception: AMQ139012: The property name 'sentry-trace' is not a valid java identifier When reading from the queue this is not enforced, i.e. a stringProperty with key sentry-trace can be successfully read.

The JMS specification can be downloaded here: https://jcp.org/aboutJava/communityprocess/final/jsr343/index.html

The relevant section is 3.8.1.1, which is referenced by Section 3.5.1