Search code examples
springspring-cloudspring-jmsspring-cloud-sleuth

Sleuth Brave headers are not compatible with JMS spec


I am using Sleuth in Spring Integration project to pass along tracing headers across JMS messages. IBM MQ is used for Queue Manager. This configuration is working all fine functionally. However, all the Brave header X-B3-* are not compatible with JMS spec? As IBM MQ client lib throws a warning about this -

Warning Message: JMSCC0049: The property name 'X-B3-Sampled' is not a valid Java(tm) identifier.

JMS Payload: 2018-03-13 11:54:42.919 INFO [domain-batch,d5a9e59728d0846a,954264c0e98a448b,false] 141252 --- [ask-scheduler-2] c.l.p.module.biz.BackendServiceClient : Message: GenericMessage [payload=2018-03-13T11:54:42.856, headers={JMS_IBM_Character_Set=UTF-8, jms_destination=queue:///DEV.QUEUE.1, JMS_IBM_Encoding=273, jms_timestamp=1520956482869, JMS_IBM_PutApplType=28, spanId=9a20699cdc50f7e9, JMS_IBM_Format=MQSTR , JMSXDeliveryCount=1, X-B3-Sampled=0, JMS_IBM_PutTime=15544287, X-B3-TraceId=d5a9e59728d0846a, id=d40cfbec-5dce-a8cd-0d96-da0e3d761459, jms_messageId=ID:414d5120514d3120202020202020202035a3a35aae92fa20, JMS_IBM_MsgType=8, JMSXUserID=app , X-B3-ParentSpanId=385f47b14a627448, priority=4, JMSXAppID=BackendServiceApplication , spanTraceId=d5a9e59728d0846a, spanParentSpanId=385f47b14a627448, nativeHeaders={spanTraceId=[d5a9e59728d0846a], spanId=[9a20699cdc50f7e9], spanParentSpanId=[385f47b14a627448], spanSampled=[0]}, jms_redelivered=false, JMS_IBM_PutDate=20180313, X-B3-SpanId=9a20699cdc50f7e9, spanSampled=0}]

Is there an option in sleuth to change the header naming convention for JMS? Similar to the baggage naming convention ? Hopefully I am not missing something from the documentation.

EDIT: Add the following log level config to suppress the warning exception

logging:
  level:
    org.springframework.integration.jms.DefaultJmsHeaderMapper: ERROR

Solution

  • I think those warnings can be ignored. We're setting both the X-B3-Sampled and the spanSampled headers (check this out https://github.com/spring-cloud/spring-cloud-sleuth/blob/master/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/instrument/messaging/MessageHeaderPropagation.java). The first ones are not compatible the second ones are JMS compatible