2

I have an application landscape where we use Instana agents to monitor and trace the applications. To be able to correlate an application log to a trace I'd like to add the traceId from Instana into our logs. Now I've tried to add spring-cloud-sleuth and I see some traceId and spanIds in the logs, but these aren't the Instana ones. The trace and span are included in the headers of the request with x-instana-t and x-instana-s. But I don't see a way to inject these headers into spring-cloud-sleuth.

I've read and tried as described in the docs, but apparently the headers can be empty, resulting in NPEs while trying to use the HexCodec.

Question in short: How can I make sleuth use the instana trace headers?

tomhier
  • 570
  • 1
  • 5
  • 15

1 Answers1

1
  1. Instana Java tracer will add instana.trace.id to logs for the supported frameworks. Please refer: https://www.ibm.com/docs/en/instana-observability/current?topic=technologies-monitoring-java-virtual-machine#logging

  2. To get the current spanId and traceId from the monitored application, you can use Instana Trace SDK. Refer: https://www.ibm.com/docs/en/instana-observability/current?topic=references-java-trace-sdk

  3. Use this guide for configuring sdk - https://www.ibm.com/docs/en/instana-observability/current?topic=references-java-trace-sdk#using-the-instana-java-sdk

  4. After configuring sdk, you can use the below two APIs to get the Ids String traceId = SpanSupport.traceId(); String spanId = SpanSupport.spanId();

  5. You will get the ids if there is an active request getting processed.