TracerProvider. Otherwise, it creates its own. Spans created within a captured request using the standard OpenTelemetry API or instrumentation libraries will be captured.
Instrument libraries
The SDK provides helper functions inapitally.otel to instrument popular libraries. These are thin wrappers around the official OpenTelemetry instrumentation packages, which need to be installed separately.
To get started, first install the required packages for the libraries you want to instrument. For example, to instrument
httpx and sqlalchemy:
Create custom spans
For custom operations that aren’t covered by library instrumentation, you can create spans manually using the helpers provided by the SDK. These are thin wrappers around the standard OpenTelemetry API, which you can also use directly.@instrument decorator
Use the @instrument decorator to automatically create a span for a function. It works with both sync and async functions:
span() context manager
Use the span() context manager to trace code blocks within a function:
Capture handled exceptions
Apitally includes exceptions in request traces to help you diagnose server errors. Exceptions that propagate through your web framework are captured automatically. If your application catches an exception and handles it without re-raising it, callapitally.capture_exception() to include it in the current request trace.