Upsonic instruments every agent run with OpenTelemetry spans following the GenAI semantic conventions. Every LLM call, pipeline step, tool execution, and agent run is traced automatically — giving you complete visibility into what your agent did, how long it took, and how much it cost.
from upsonic import Agent# Automatically instrumented — no instrument= parameter neededagent = Agent("anthropic/claude-sonnet-4-6")agent.print_do("What is 2 + 2?")
When Upsonic is imported, it detects UPSONIC_OTEL_ENABLED and calls Agent.instrument_all() with a DefaultTracingProvider under the hood. All agents created in the process are instrumented automatically.
UPSONIC_OTEL_ENDPOINT must point to a running OTLP collector (Jaeger, Grafana Tempo, etc.). If no collector is reachable, you’ll see a ConnectionError in stderr at process exit when the exporter tries to flush spans. This is harmless — the agent runs normally, spans are simply dropped. See Troubleshooting below.
from upsonic import Agentfrom upsonic.integrations.tracing import DefaultTracingProviderprovider = DefaultTracingProvider(endpoint="http://localhost:4317", include_content=False)agent = Agent("anthropic/claude-sonnet-4-6", instrument=provider)agent.print_do("Process SSN: 123-45-6789")# Prompts and responses will NOT appear in traces
All providers set flush_on_exit=True by default — pending spans are flushed automatically when the process exits. You do not need to call shutdown() manually in normal usage.Call shutdown() explicitly only if you need to flush spans mid-process (e.g., in tests or before a graceful restart).
This is harmless. It means the OTLP exporter tried to send spans but no collector is running at the configured endpoint. Your agent executed normally — only the trace export failed.To fix it, either:
Run a collector — start Jaeger, Grafana Tempo, or any OTLP-compatible backend:
docker run -d --name jaeger -p 4317:4317 -p 16686:16686 jaegertracing/all-in-one:latest
Use Langfuse instead — no local collector needed, traces go to the cloud:
from upsonic.integrations.langfuse import Langfuseagent = Agent("anthropic/claude-sonnet-4-6", instrument=Langfuse())
Don’t use tracing — simply don’t set instrument or UPSONIC_OTEL_ENABLED.
Langfuse Integration
Send traces to Langfuse for LLM-specific dashboards, cost tracking, and prompt management.
PromptLayer Integration
Log agent runs and evaluations to PromptLayer for prompt management, versioning, and observability.