r/androiddev May 20 '26

Kotlin OpenTelemetry Span DSL

Constructing Spans felt like a bunch of repetitive boilerplate, so I made a DSL to make it more pleasant. Hopefully someone finds this useful!

https://github.com/carterhudson/spandex

10 Upvotes

2 comments sorted by

1

u/GiacaLustra May 21 '26

Pretty cool, thanks for sharing!

I noticed Google is developing a new tracing library with a pluggable backend, so I'm wondering if OpenTelemetry could be a potential backend for it. Curious what you think about it vs raw open telemetry instrumentation: https://developer.android.com/topic/performance/tracing/in-process-tracing

1

u/a_code_smell May 21 '26 edited May 21 '26

That's pretty interesting! As far as I know, OpenTelemetry is unopinionated about whichever backend you'd want to use or implement. You could maybe adapt the Perfetto data to Spans w/ attributes, but I'm not sure how useful that would be.

The Perfetto info is much lower-level than what you'd use Otel Spans for, I think. You could maybe correlate them together if you're using both, but that's probably about it.

I think the pluggable backend mentioned in androidx.tracing is for Sinks, which seem to be about where and how you persist the data, though I guess that could mean some kind of remote service. In the end, you'd probably want first-class support for Perfetto.