Does Elastic APM support Spring Cloud Stream?

Hi,

I am very new to Elastic APM and not sure how it can support different frameworks. I can see that from the documentation APM supports Spring Boot. I was wondering if it supports Spring Cloud Stream as well. Spring Cloud Stream provides Event Driven Architecture by using Spring Boot and messaging middleware. Middleware can be Kafka, RabbitMQ, etc.

Thanks,
Ali

Hi!

There is no out of the box support for that.

However, Elastic APM agents expose APIs that provide the ability to follow traces across multiple services programatically. If you have the ability to add a string property to your messages/events on the producer side and read them on the consumer side, this is all you need. Install Elastic APM agents on each of your services and let them instrument your applications. When producing a message to send, use our APIs to get a string representation of the trace context and attach it to the message. When receiving a message, use this trace context string to initiate a transaction related to the same trace.

Since our agents are OpenTracing compatible, you can take advantage of the OpenTracing Inject-Extract API for distributed tracing. Alternatively, if all services you want to instrument are Java, you can rely on the Java agent public API for achieving the same result (see injectTraceHeaders and startTransactionWithRemoteParent APIs specifically).

I hope this helps.
Eyal.

Hi,

Both injectTraceHeaders and startTransactionWithRemoteParent works based on request and response headers. Spring cloud stream does not use http, so we need to have some kind of interceptor to message producer and consumer and add trace details to message header right?
Please confirm.

Thanks
Tilak

Hi again, Tilak.

Yes, you are correct. The header in the name may be misleading, it is not restricted in any way to HTTP.

As you say, you need to find an interceptor on the producer side that provides a hook for adding a String property/header/attribute to the message and call the injectTraceHeaders API with an implementation of HeaderInjector that uses it. On the consumer side, you need to find an interceptor that provides a way for reading this String and call the startTransactionWithRemoteParent API with an implementation of either HeaderExtractor or HeadersExtractor that uses it.

I hope this helps. Please let us know how it worked out.

Good luck,
Eyal.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.