aws / aws-xray-sdk-java

The official AWS X-Ray Recorder SDK for Java.
Apache License 2.0
96 stars 99 forks source link

Using AWS X-ray without Servlet or Spring Boot #95

Open sachin-walia opened 5 years ago

sachin-walia commented 5 years ago

Our microservice stack is built atop Undertow without Spring or Servlet API. I am wondering how can we leverage AWS X-ray Java SDK. Last thing we want is to get Servlet API or Spring as a transitive dependencies. Are there any examples available?

chanchiem commented 5 years ago

Hey Sachin-walia,

It looks like if we want to add support for Undertow, we'd have to implement an additional middleware for that framework. Looking at their APIs, I think that writing an instrumentor for it would be similar to some of our existing instrumentors.

I can see that Undertow provides an API to add handlers, where you can extract information about a particular request/response.

Please refer to this source code to see the similarities. Namely, the HttpServerExchange object in Undertow's handler class contains HTTP information about the request. This could be added into a segment that's generated during the request processing stage done in Undertow. And in the response phase, the segment could be closed.

will-sargent-eero commented 5 years ago

Same issue, using Play Framework. If X-Ray supported Opentracing API then this would be straightforward, but https://github.com/opentracing-contrib/java-xray-tracer doesn't support cross process propagation.

ashleymercer commented 5 years ago

Hi @will-sargent-eero - just to be clear, the opentracing-contrib/java-xray-tracer is an unofficial (non-AWS) library designed to plug exactly this hole.

But yes, I'd love to see the official SDK natively support OpenTracing (or better yet, its successor OpenTelemetry removing the need to maintain a separate library at all :)

will-sargent-eero commented 5 years ago

@ashleymercer the issue is that java-xray-tracer doesn't support cross process propagation.

will-sargent-eero commented 5 years ago

Last thing we want is to get Servlet API or Spring as a transitive dependencies

This is also an issue, in that the Servlet API is included in AWS X-Ray core and so must be specifically excluded in the build system.

ss2305 commented 5 years ago

@will-sargent-eero We are actively working on a solution to support OpenTelemetry(starting with Java) so that you will have official support.