Zero Code Instrumentation with eBPF and Logfire
Blog post from Pydantic
eBPF and Logfire offer a solution for applications where traditional code-based instrumentation is not feasible, such as with legacy services, compiled binaries, or third-party containers, by providing observability at the kernel level without modifying application code. The OpenTelemetry eBPF Instrumentation captures network-level data, like HTTP request methods, paths, status codes, and latencies, and exports compatible traces and metrics to Logfire or other OTLP backends, although it cannot access application-specific contexts such as user IDs or custom attributes. Configuration involves setting up eBPF instrumentation using docker-compose, allowing for service discovery through ports or executable names, and exporting data to Logfire with endpoint filtering to manage data volume and noise. While eBPF is useful for immediate infrastructure-level visibility and incident response, it runs in a privileged container, requiring careful security measures, and is best suited for Linux environments. The tool is compatible with Kubernetes and supports traffic over standard protocols like HTTP/HTTPS and gRPC, providing an alternative to SDK-based instrumentation until more detailed application context is needed.