0

I have 3 microservices that are communicating over JMS (ActiveMQ Artemis). I am looking to implement Open Telemetry across these flows. I have tried the automated WithSpan approach but obviously the tracecontext is not propagated between services as it's async/JMS. I have tried to follow the manual context propagation approach outlined here, but then I am getting 2 errors while doing this.

  1. java.lang.IllegalArgumentException: Identifier contains invalid JMS identifier character '-': 'uber-trace-id'
  2. I can't seem to implement the setter and set the properties on the message object as i get an exception saying the properties are read-only.

Any idea how I can do this where i want to be able to trace the end-to-end flow?

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
sg1973
  • 91
  • 6
  • What do you mean by "implement the setter"? Are you trying to _implement_ `javax.jms.Message` or are you simply trying to _invoke_ a method to set a property? Please clarify. Thanks! – Justin Bertram Jul 20 '23 at 13:17

1 Answers1

0

The question does not state what instrumentation library you're using, but it sounds like https://github.com/open-telemetry/opentelemetry-java-instrumentation

Identifier contains invalid JMS identifier character '-': 'uber-trace-id'

I looks like you're using message properties to send the tracecontext, which looks good. In this case, the allowed characters don't seem to match, so I'd suggest to transcode the values to a Java identifier.

i can't seem to implement the setter and set the properties on the message object as i get an exception saying the properties are read-only.

I haven't used Artemis JMS, but it looks like you have to set the properties in the client message before you create the ActiveMQMessage.

  • Thank you. I am trying to implement what's on this link https://github.com/brunobat/quarkus-observability-demo/tree/main/quarkus-observability-demo-activemq but having issues doing so. I am using JMS Message and so not sure how to use the client message to set the properties. – sg1973 Jul 20 '23 at 11:49
  • I think i found the issue. The context when it comes into the service B correctly shows the traceid but then the message is then translated to another type of message and at this point, the context loses the tracing information. Is there anyway i can set the incoming context globally so it stays available for all threads? – sg1973 Jul 20 '23 at 22:17
  • no, the context is bound to a single thread. – Gregor Zeitlinger Jul 21 '23 at 13:30
  • Yes. Realized it. Do we need to explicitly pass it around between threads or is it possible to set it at the top level so all threads get it? – sg1973 Jul 24 '23 at 18:29
  • No, threads never share a context. If you're using the javaagent, the context gets propagated to the next thread correctly in many situations, e.g. when using an executor using [this instrumentation moddule](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/executors/README.md). – Gregor Zeitlinger Jul 26 '23 at 08:50