get_tracer()

Signature

1get_tracer() -> Tracer

Returns the underlying OpenTelemetry Tracer instance for creating spans manually when decorators are not sufficient.

Example

1from respan import Respan, get_client
2
3respan = Respan(api_key="your-api-key")
4client = get_client()
5tracer = client.get_tracer()
6
7with tracer.start_as_current_span("custom_operation") as span:
8 span.set_attribute("custom.key", "value")
9 # Your logic here
10 result = 42
11 span.set_attribute("custom.result", result)

Manual spans are exported through the same processor pipeline as decorator-created spans. Prefer decorators for standard use cases and use get_tracer() only when you need fine-grained control over span lifecycle.