Skip to main content
When tracing is enabled, the Apitally SDK captures OpenTelemetry spans during request handling and attaches them to request logs. This allows you to see exactly what happened during each request, including database queries, HTTP calls to external services, and custom operations. If you have an existing OpenTelemetry setup, the SDK automatically registers itself as a span processor with the global TracerProvider. Otherwise, it creates its own. Any spans created using the standard OpenTelemetry API or by instrumentation libraries will be captured.

Enable tracing

To enable tracing, set CaptureTraces to true in your middleware configuration:

Instrument libraries

To capture spans from HTTP clients, database drivers, and other libraries, use the corresponding OpenTelemetry instrumentation libraries. For example, to instrument outgoing HTTP requests using otelhttp:
See the OpenTelemetry registry for a complete list of available instrumentation libraries.

Create custom spans

For custom operations that aren’t covered by library instrumentation, you can create spans manually using the standard OpenTelemetry API:
Make sure to pass the ctx returned by tracer.Start() to any child operations to maintain the span hierarchy.