-
Notifications
You must be signed in to change notification settings - Fork 999
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
JMS Context properties 'X-B3-TraceId' is not a valid java identifier. #4202
Comments
https://issues.apache.org/jira/browse/ARTEMIS-2700 some issue from 2020 where someone stumbled upon this. |
Prior to this commit, both `JmsPublishObservationContext` and `JmsProcessObservationContext` would set propagation headers as String properties on the JMS `Message`. This would cause issues with JMS implementations, as the JMS specification only allows valid Java identifiers as keys. Typically, a `X-B3-TraceId` header fails this requirement as it contains "-" characters. This commit ensures that the following characters are escaped when publishing messages, and unescaped when receiving messages: * "-" becomes "_HYPHEN_" * "." becomes "_DOT_" Closes micrometer-metricsgh-4202
Prior to this commit, both `JmsPublishObservationContext` and `JmsProcessObservationContext` would set propagation headers as String properties on the JMS `Message`. This would cause issues with JMS implementations, as the JMS specification only allows valid Java identifiers as keys. Typically, a `X-B3-TraceId` header fails this requirement as it contains "-" characters. This commit ensures that the following characters are escaped when publishing messages, and unescaped when receiving messages: * "-" becomes "_HYPHEN_" * "." becomes "_DOT_" Closes micrometer-metricsgh-4202
It would if it were standardized what escaping/unescaping should be used. Since it is not, whatever escaping we apply would assume the other side of the messaging is instrumented with something that applies the same escaping. I don't think that's a reasonable assumption unless the entire JMS ecosystem has adopted what Camel does. There is a long history of this issue, and I think the only robust way around it is to avoid it entirely by using a propagation format that doesn't have hyphens in the header name. For some history, see openzipkin/brave#584, openzipkin/brave#1019. |
Our current infrastructure used the old headers. Im not sure what happend if we switch from B3-* to b3 single header. Any experiences with migration? |
Otherwise I would be happy if the escaping would just work within the SB3 world.. as thats the only place we use JMS |
You should ensure that all the components in your system can read B3 multi and b3 single headers, regardless of which they are configured to write. That way tracing still works during the transition phase from multi to single. You mentioned Spring Boot 3. If all of your traced components are SB3 applications, you may be interested in the properties mentioned in spring-projects/spring-boot#35611, which should allow for relatively easy migration.
I appreciate your concern is that the issue you're facing gets resolved for your use case. At the low level of libraries like Micrometer, we have to consider all supported use cases. Micrometer is used outside of Spring Boot. It would also be a valid use case for a Spring Boot app using Micrometer to produce a message on a JMS broker that then gets consumed by an application written in a different language. Tracing wouldn't work with the proposed changes unless that application applied the same logic, despite not using Micrometer. Something we could look into is overriding the configured propagation format when writing to or reading from message brokers, knowing the limitations of headers on some of them. I believe Brave did and/or does this. We'd need to look into this more. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open. |
This is a problem because without escaping we cannot use I don't know which project can fix it correctly because it can be fixed in Brave, Micrometer or Spring Boot. From my point of view some escaping (or catching the So we have to use this configuration in Spring Boot: management.tracing.propagation.consume=W3C |
B3-single should also work, see this: #4202 (comment) and https://github.com/openzipkin/b3-propagation?tab=readme-ov-file#single-header |
It works if you send the b3 header but if there is not any tracing header then it reach this: |
|
But the problem is there is no tracing header. So you send a message without any tracing and a processing service with observation tries to extract B3 headers and also tries to extract |
Describe the bug
Exception when publising a JMS message. Not all characters are allowed according to JMS naming standard, i.e hyphen.
Environment
Micrometer version [e.g. 1.7.1] 1.12.0-M3
Micrometer registry [e.g. prometheus] prometheus
OS: [e.g. macOS] macOS
Java version: [e.g. output of
java -version
]openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)
To Reproduce
How to reproduce the bug:
Use Spring Boot 3.2.0-M3 with artemis-starter and tracing enabled. Publish a message.
Expected behavior
Escape / Unescape Property Names to comply with JMS Java Identifier Rules
https://camel.apache.org/components/4.0.x/jms-component.html#_message_header_mapping
Additional context
The text was updated successfully, but these errors were encountered: