After trying to implement the spec for eclipse/microprofile-opentracing I have come up with some flaws in the proposal, mostly based on my inadequate understanding of how CDI works.
The proposal still needs to meet the same requirements:
Make it easy for developers to have their apps participate in a distributed tracing env.
Make it easy for developers to add explicit tracing instrumentation into their apps.
The proposal defined the following:
Annotations:
@Trace - applied to classes or methods; causes a Span to be started when the method starts, and the Span is finished when the method ends.
@NoTrace - applied to methods; turns off tracing for methods inside a class that is annotated with @Trace
@TraceDecorate - Decorates a Span with tags, logs or baggage
@Tracer - provides access to the configure Tracer in the environment for direct access to the opentracing APIs
Behaviors:
Methods annotated with @GET, @PUT, @POST, @DELETE, or @PATCH will start a new Span for the request. If a Span can be extracted from the request, the new Span will be a child of the extracted Span.
Requests sent with javax.ws.rs.client.Client will have Span created for the sent request, and the Span info will be propagated downstream.
Changes to the proposal for discussion:
Having an @Tracer implementation doesn't really work. You can inject an @Tracer class, but that won't give the instance of the configured Tracer.
Right now, to get access to the configured Tracer, the
opentracing.io java API provides
GlobalTracer.register(Tracer)
and
GlobalTracer.get()
I propose the specification say that the
microprofile.io implementation will support GlobalTracer.get() to provide developer access to the configured Tracer.
The @TraceDecorate annotation doesn't really work either. I was thinking of it more as a macro, which is not how annotations work. There is no element it can really be applied to.
So, to decorate a Span, the developer would have to use:
GlobalTracer.get.activeSpan().setTag(...)
GlobalTracer.get.activeSpan().log(...)
GlobalTracer.get.activeSpan().setBaggage(...)
I will update eclipse/microprofile-opentracing repository with this new info, and wait for comments here or there.
https://github.com/eclipse/microprofile-opentracing/pull/2 Steve Fontes