feat(users/Profpatsch): Implement initial otel-dbus proxy

For simplicity’s sake this puts everything into the
alacritty-change-color-scheme script for now.

This implements a simple dbus-opentelemetry proxy adapter, which
allows services to record otel traces without having to depend on the
quite complex otel libraries. Instead, they just send their traces to
the dbus tracing interface, and the service that binds against that
interface forwards the spans to the OTLP collector.

First you create a new Tracer for your service via the `TracerFactory`
interface:

```
> busctl --user call \
    de.profpatsch.otel.Tracer \
    /de/profpatsch/otel/TracerFactory \
    de.profpatsch.otel.TracerFactory CreateTracer \
    s hello
s "/de/profpatsch/otel/tracers/hello"
```

(this corresponds to setting up a tracer with properties in OTEL)

Then, you can use the returned object path to call the `Tracer`
interface proper:

```
< busctl --user call \
    de.profpatsch.otel.Tracer \
    /de/profpatsch/otel/tracers/hello \
    de.profpatsch.otel.Tracer \
    StartSpan \
    s '{"spanId": "111", "name": "111"}'
```

This will create the spans. You can also set their timestamps on the
sending side via `startTime`/`endTime`, but make sure it’s a hrtime
tuple.

Prefer batching multiple spans vie the `BatchSpans` call.

Change-Id: Ie6cfdcb0dc3e2398316a2c1763bc72c1118168b0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12885
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: benjaminedwardwebb <benjaminedwardwebb@gmail.com>
This commit is contained in:
Profpatsch 2024-12-09 21:10:01 +01:00
parent 821ff7ffe4
commit 4eeac3cb1d
3 changed files with 754 additions and 66 deletions

View file

@ -10,6 +10,11 @@
"license": "ISC",
"description": "",
"dependencies": {
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/context-async-hooks": "^1.29.0",
"@opentelemetry/core": "^1.29.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.56.0",
"@opentelemetry/sdk-trace-base": "^1.29.0",
"dbus-native": "^0.4.0"
}
}