Opentelemetry instrumentation support for ttRPC
Go to file
Fu Wei 20107527e8
Merge pull request #22 from containerd/dependabot/github_actions/containerd/project-checks-1.2.2
2025-04-08 09:40:34 -04:00
.github build(deps): bump containerd/project-checks from 1.1.0 to 1.2.2 2025-03-10 17:33:58 +00:00
example upgrade golang, deps, CI versions 2025-01-09 16:25:19 +00:00
internal '*.go': ditch import path checks. 2024-03-04 17:01:46 +02:00
.gitignore .gitignore: add .gitignore. 2024-01-11 20:13:36 +02:00
LICENSE docs: add doc.go, README.md and LICENSE. 2024-01-15 08:54:05 +02:00
Makefile otelttrpc: implement opentelemetry instrumentation. 2024-01-13 17:42:46 +02:00
README.md docs: add doc.go, README.md and LICENSE. 2024-01-15 08:54:05 +02:00
config.go '*.go': ditch import path checks. 2024-03-04 17:01:46 +02:00
doc.go docs: add doc.go, README.md and LICENSE. 2024-01-15 08:54:05 +02:00
example_interceptor_test.go otelttrpc: add minimal instrumentation tests. 2024-01-13 19:55:03 +02:00
go.mod upgrade golang, deps, CI versions 2025-01-09 16:25:19 +00:00
go.sum upgrade golang, deps, CI versions 2025-01-09 16:25:19 +00:00
interceptor.go '*.go': ditch import path checks. 2024-03-04 17:01:46 +02:00
interceptor_test.go Fix concurrent map panic on inject metadata 2025-01-02 16:59:04 +00:00
metadata_supplier.go Fix concurrent map panic on inject metadata 2025-01-02 16:59:04 +00:00
semconv.go '*.go': ditch import path checks. 2024-03-04 17:01:46 +02:00
version.go '*.go': ditch import path checks. 2024-03-04 17:01:46 +02:00

README.md

ttrpc OpenTelemetry Instrumentation

This golang package implements OpenTelemetry instrumentation support for ttrpc. It can be used to automatically generate OpenTelemetry trace spans for RPC methods called on the ttrpc client side and served on the ttrpc server side.

Usage

Instrumentation is provided by two interceptors, one to enable instrumentation for unary clients and another for enabling instrumentation for unary servers. These interceptors can be passed as ttrpc.ClientOpts and ttrpc.ServerOpt to ttrpc during client and server creation with code like this:


   import (
       "github.com/containerd/ttrpc"
       "github.com/containerd/otelttrpc"
   )

   // on the client side
   ...
   client := ttrpc.NewClient(
       conn,
       ttrpc.UnaryClientInterceptor(
           otelttrpc.UnaryClientInterceptor(),
       ),
   )

   // and on the server side
   ...
   server, err := ttrpc.NewServer(
       ttrpc.WithUnaryServerInterceptor(
           otelttrpc.UnaryServerInterceptor(),
       ),
   )

Once enabled, the interceptors generate trace Spans for all called and served unary method calls. If the rest of the code is properly set up to collect and export tracing data to opentelemetry, these spans should show up as part of the collected traces.

For a more complete example see the sample client and the sample server code.

Limitations

Currently only unary client and unary server methods can be instrumented. Support for streaming interfaces is yet to be implemented.

Project details

otelttrpc is a containerd sub-project, licensed under the Apache 2.0 license. As a containerd sub-project, you will find the:

information in our containerd/project repository.