BareProxy OpenTelemetry Export Plugin: Request Records Sent to Your Tracing and Log Stores
Status: planned, number 15 of 21 in BareProxy’s build order. The plugins are built easiest first, and this one is two or three days of coding: records batched and sent in the OpenTelemetry format. It comes after the Uptime checks and status pages plugin. This post describes what it will do, and it will be updated as it is built.
BareProxy already writes one record for every request: what arrived, which rule handled it, which backend answered, how long each step took, and what every plugin did. It also passes on a W3C traceparent header, so a request’s trace in the app joins up with the proxy’s request ID. What’s missing is a way to get those records into the tools teams already use: Grafana, Honeycomb, Datadog, Jaeger, an Elastic stack, or any OpenTelemetry collector.
What It Will Do
- Send each request as a span. The proxy’s part of a trace, with the timing of the backend call inside it, under the same trace ID as the app’s spans. In the trace view, the proxy finally shows up as the first hop.
- Or as a log record. The full request record, with its fields named the OpenTelemetry way, for teams who search logs rather than traces.
- In batches. Records are collected and sent every second or so, over OTLP/HTTP, to a collector address the plugin’s config allows. A slow or missing collector never holds up a request; records are dropped and counted instead.
- Sample. Keep every error and every slow request, and a share of the rest, by rules in the config.
A config will look something like this:
plugin otel /etc/bareproxy/plugins/otel-export.wasm
config /etc/bareproxy/plugins/otel.json
allow-http 127.0.0.1:4318
on-error open
site example.com
use otel
route /* -> app
It reads records once the response has gone, in the last callback of a request, so it adds nothing to the time a visitor waits. status will show how many records were sent and dropped.
This plugin covers the “Export” module of BareProxy’s earlier plan. The whole program is on the plugins page.