Skip to main content

Telemetry & Observability

The Telemetry module provides observability utilities built on OpenTelemetry. It auto-instruments SDK HTTP clients and common Python frameworks (httpx, requests, starlette, fastapi, django, flask, sqlalchemy, grpcio), exporting traces, metrics, and logs to any OTLP-compatible backend such as SAP Cloud Logging.

Auto-Instrumentation and Agent Spans

Call auto_instrument() once before importing AI libraries, then wrap LLM calls with a parent span that carries your business context:

from sap_cloud_sdk.core.telemetry import auto_instrument, invoke_agent_span

auto_instrument()

from litellm import completion # imported after — now automatically traced

with invoke_agent_span(
provider="openai", agent_name="SupportBot", conversation_id="conv-123"
):
response = completion(model="gpt-4o", messages=[...])

For span functions, extension context propagation, middleware, and configuration details, see the Telemetry user guide in the cloud-sdk-python repository.