OpenTelemetry instrumentation for Tower-compatible web frameworks

Posted on

Lately, I was working on a new axum-powered web service that ought to emit conventional OpenTelemetry: HTTP spans and metrics conforming to the OpenTelemetry semantic conventions. A quick search for existing solutions yielded some more or less popular crates but I was unable to make a choice based on the rather sparse documentation. That’s why I started to implement my own middleware along the way – to better understand the problem. As I learned more about OpenTelemetry’s terminology and SDK, I found that none of the available crates was a good fit for me. That’s quite possibly just me.

Anyway, my little middleware has grown into a full-fledged Tower Layer to instrument HTTP clients and servers with conventional OpenTelemetry spans and metrics – complete with documentation, integration tests, and example applications. I think it’s good enough, and distinct enough, to be shared.

It’s called tower-http-opentelemetry and the source is available on Codeberg.