otel4s instrumentation for fs2-grpc.
Warning
It's experimental software. Use at your own risk.
- Integrates otel4s tracing with fs2-grpc ClientAspect and ServiceAspect
- Propagates context through gRPC metadata
libraryDependencies += "io.github.irevive" %% "fs2-grpc-otel4s-trace" % "0.0.1"The example wires the trace aspects into a generated fs2-grpc service. TestService denotes your service implementation.
import org.typelevel.fs2grpc.trace.*
def tracedService(using TracerProvider[IO]): Resource[IO, ServerServiceDefinition] =
for {
serviceAspect <- Resource.eval(TraceServiceAspect.create[IO])
dispatcher <- Dispatcher.parallel[IO]
} yield TestServiceFs2Grpc.serviceFull(dispatcher, new TestService, serviceAspect, ServerOptions.default)
def tracedClient(channel: Channel)(using TracerProvider[IO]): Resource[IO, TestServiceFs2Grpc[IO, Metadata]] =
for {
clientAspect <- Resource.eval(TraceClientAspect.create[IO])
dispatcher <- Dispatcher.parallel[IO]
} yield TestServiceFs2Grpc.mkClientFull(dispatcher, channel, clientAspect, ClientOptions.default)TraceClientAspect and TraceServiceAspect expose a Config that can be refined before creation.
withTracerNameselects the tracer acquired from the provided TracerProvider.withTextMapUpdater/withTextMapGetteradjust metadata injection - default ASCII key.withSpanNameandwithAttributesoverride naming and attributes - defaults use the gRPC method descriptor and RPC semantic conventions.withFinalizationStrategysets theSpanFinalizer.Strategy- defaults toreportAbnormal.