Search code examples
goopentracingjaeger

Why go-jaeger-client requires wrappers for metrics and logs?


I’ve started with instrumenting my gRPC service using go-gRPC-middleware. I’ve got logs working using zap and metrics exposed for Prometheus.

Now that I’m trying to configure tracing using jaeger go client it requires me to add wrapper around metrics storage and logger. I’m not sure I understand why those wrappers are required

https://github.com/jaegertracing/jaeger/blob/bf64373d1e690594fd8c279720faf32722cf1494/examples/hotrod/pkg/tracing/init.go#L46


Solution

  • Jaeger clients are designed to have a minimum set of dependencies. We don't know if your application is using Prometheus metrics or Zap logger. This is why jaeger-client-go (as well as many other Jaeger clients in other languages) provide two lightweight interfaces for a Logger and MetricsFactory that can be implemented for a specific logs/metrics backend that your application is using. Of course, the bindings for Prometheus and Zap are already implemented in the jaeger-lib and can be included optionally.