natchez icon indicating copy to clipboard operation
natchez copied to clipboard

Add an `opentelemetry` module

Open andimiller opened this issue 4 years ago • 3 comments

This adds a natchez-opentelemetry module which allows span reporting via the opentelemetry-java project.

The Utils object contains a helper to turn the OpenTelemetry CompletableResultCode class into an F[Unit] given Async[F], this is useful for implementing Resources for clean shutdown logic.

Shutdownable is a little abstraction to unify all the interfaces that have a shutdown(): CompletableResultCode method in OpenTelemetry, since they have no common interface.

OpenTelemetrySpan and OpenTelemetryEntryPoint are heavily based on the natchez-jaeger versions, with tweaks to make them work with OpenTelemetry.

The OpenTelemetry object which end users should interact with has these methods:

  • lift can be used to lift any F[T] where T is an OpenTelemetry class with a shutdown method into a Resource[F, T], it asks for a name to provide a nice error message
  • entryPoint is the main way to make an EntryPoint and has a boolean flag to allow the user to globally register the OpenTelemetry if that's helpful, this defaults to false.
  • globalEntryPoint will use the globally registered OpenTelemetry to create an EntryPoint

Note that this is currently using OpenTelemetry libraries at 1.4.0-SNAPSHOT because I found a bug while developing this this broke the shutdown logic. The issue is here https://github.com/open-telemetry/opentelemetry-java/issues/3306 and it was closed by this PR https://github.com/open-telemetry/opentelemetry-java/pull/3307 so it should make it into the next release.

andimiller avatar Jun 11 '21 14:06 andimiller

I can also port this over to the 0.1 branch pretty easily, we just needed it for 0.0

andimiller avatar Jun 11 '21 14:06 andimiller

I was just looking for this today!

zmccoy avatar Nov 18 '21 23:11 zmccoy

Can we expect this to be merged any time soon? It would be great!

leo-bogastry avatar Jan 12 '22 18:01 leo-bogastry

I merged #539. Please take a look and see if there's anything from this PR we should incorporate.

mpilquist avatar Oct 02 '22 13:10 mpilquist