line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.79k stars 907 forks source link

Support for Micrometer Tracing #4570

Open ikhoon opened 1 year ago

ikhoon commented 1 year ago

Micrometer Tracing is a facade library for popular tracer libraries. Armeria pursues an opinionated framework. If we support Micrometer Tracing, users are able to use their favorite tracing library easily.

jrhee17 commented 1 year ago

A couple of observations while working on the client-side integration while working on https://github.com/line/armeria/pull/4883

Basically, our current brave module implementation provides the following:

  1. A context propagation mechanism that relies on RequestContext via RequestContextCurrentTraceContext.
  2. A way to annotate/tag http related events which are specific to armeria
  3. A BraveClient which lets users decorate requests. The decorator adds client-related annotations/tags to a span for each request, and produces/completes the span.

I think 2,3 are relatively easy to handle, but I think context propagation isn't possible to handle with a micrometer-tracing-only solution. (I'll also try opening an issue on micrometer-tracing side, but honestly the implementations are so different between brave and otel that I don't have a good idea on what they could do either)

Basically, I think realistically we'll also have to add integration for opentelemetry as well before proceeding.

The downside of this approach is that the solution isn't generic (since in addition to micrometer-tracing, we still need to keep implementing CurrentTraceContexts for each implementation).

There are also some issues for each integration. For instance, the CurrentTraceContext passed into each tracer isn't actually used, which may cause some confusion for users:

Let me also talk to the micrometer-tracing people to make sure I'm not misusing any APIs or concepts, and check if there's a better way to handle this issue.

jrhee17 commented 1 year ago

Started discussions on the behavior of Tracer#currentTraceContext https://github.com/micrometer-metrics/tracing/issues/268

Let me think more if there's a generic way to provide RequestContext based trace propagation before raising an issue as well 😅

anuraaga commented 1 year ago

/cc @trask @jkwatson

trask commented 1 year ago

@jkwatson and I would of course recommend instrumenting with OpenTelemetry API

jrhee17 commented 1 year ago

Using the OpenTelemetry API directly there weren't any issues I could find 😄 (actually I found the OpenTelemetry API very well defined and the integration experience very smooth when working on the POC)