opentracing-contrib / java-spring-messaging

OpenTracing Spring Messaging instrumentation
Apache License 2.0
3 stars 11 forks source link

Failed to extract Jaeger context #24

Closed pavolloffay closed 5 years ago

pavolloffay commented 5 years ago

From https://github.com/opentracing-contrib/java-spring-messaging/issues/18#issuecomment-451171922

Error when extracting SpanContext from carrier. Handling gracefully.

io.jaegertracing.exceptions.MalformedTracerStateStringException: String does not match tracer state format: [B@6ef3781d
    at io.jaegertracing.SpanContext.contextFromString(SpanContext.java:117)
    at io.jaegertracing.propagation.TextMapCodec.extract(TextMapCodec.java:73)
    at io.jaegertracing.propagation.TextMapCodec.extract(TextMapCodec.java:27)
    at io.jaegertracing.PropagationRegistry$ExceptionCatchingExtractorDecorator.extract(PropagationRegistry.java:57)
    at io.jaegertracing.Tracer.extract(Tracer.java:193)
    at io.opentracing.contrib.spring.integration.messaging.OpenTracingChannelInterceptor.preSend(OpenTracingChannelInterceptor.java:60)
    at org.springframework.integration.channel.AbstractMessageChannel$ChannelInterceptorList.preSend(AbstractMessageChannel.java:611)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:453)
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:407)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:181)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:160)
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:47)
    at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:108)
    at org.springframework.integration.endpoint.MessageProducerSupport.sendMessage(MessageProducerSupport.java:203)
    at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter.access$300(KafkaMessageDrivenChannelAdapter.java:70)
    at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter$IntegrationRecordMessageListener.onMessage(KafkaMessageDrivenChannelAdapter.java:387)
    at org.springframework.integration.kafka.inbound.KafkaMessageDrivenChannelAdapter$IntegrationRecordMessageListener.onMessage(KafkaMessageDrivenChannelAdapter.java:364)
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeRecordListener(KafkaMessageListenerContainer.java:1001)
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.doInvokeWithRecords(KafkaMessageListenerContainer.java:981)
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeRecordListener(KafkaMessageListenerContainer.java:932)
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.invokeListener(KafkaMessageListenerContainer.java:801)
    at org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer.run(KafkaMessageListenerContainer.java:689)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)

"[B@6ef3781d" in this case is byte[] which is converted by String.valueOf(..) in MessageTextMap

pavolloffay commented 5 years ago

cc @dreaderxxx @geoand @gytis.

Could somebody try to run a simple app with Jaeger tracer?

gytis commented 5 years ago

@dreaderxxx could you share a reproducer to your issue?

dreaderxxx commented 5 years ago

It might be tedious to reproduce it from scratch because you need to put all stuff (kafka, spring integration, opentracing, jaeger, ..) together.

dreaderxxx commented 5 years ago

As I understand traceId coming in kafka header as byte[] and then converted to String using valueOf in MessageTextMap. I'm not sure how it is supposed to work. -Maybe headers should be converted to String before with help of KafkaHeaderMapper from spring-kafka -Or maybe to use something like HeadersMapExtractAdapter in opentracing-kafka-client instead of MessageTextMap

gytis commented 5 years ago

I'm not familiar with the Jaeger implementation. @pavolloffay do you have a suggestion how to work around an issue when tracerId comes as byte[] and another component expects it as string? Is that a normal scenario?

pavolloffay commented 5 years ago

The tracer should have registered encodings for different types - text_map, binary for byte array.