Skip to main content
Version: 1.51

Tracing

Tracing can provide insights into what happens in complex flows (e.g. agentic LLM applications). Adding tracing to your application can help identify where issues occur. You can navigate traces seamlessly within the Deeploy UI, under Deployment -> Monitoring -> Tracing. Tracing is available for managed or external deployments.

Understanding OpenTelemetry concepts

Deeploy supports traces that adhere to the OpenTelemetry protocol (OTLP) over HTTP. When working with tracing in Deeploy, it helps to understand these key concepts:

  • Trace: Represents the complete journey of a request as it moves through your application.
  • Span: Segments of work within a trace, representing operations like API/function calls or database queries.
  • Attribute: Key-value pairs providing context about a span (e.g., user ID, request parameters).

Getting started

To use tracing, instrument your application using OpenTelemetry. You can do this automatically with a framework or manually using a base OpenTelemetry SDK (available for many languages). Authenticate using a Deployment token. See the example below.

note

gRPC endpoints aren't supported. Make sure to export over HTTP by importing from opentelemetry.exporter.otlp.proto.http.

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter


resource = Resource(attributes={
"service.name": "your_service_name",
"service.version": "1.0.0"
})

# Configure the tracer provider with resource
provider = TracerProvider(resource=resource)

workspace_id = "<workspaceId>"
deployment_id = "<deploymentId>"

# OTLP exporter for sending traces to endpoint
otlp_exporter = OTLPSpanExporter(
headers={
"Authorization": "Bearer <DPTexamppletoken>"},
endpoint="https://api.app.deeploy.ml/workspaces/{workspace_id}/deployments/{deployment_id}/traces",
)
otlp_processor = SimpleSpanProcessor(otlp_exporter)
provider.add_span_processor(otlp_processor)

trace.set_tracer_provider(provider)

# ... your application
limitations (beta)
  • Traces are kept for 90 days by default.
  • For private cloud installations on Azure, the only supported authenthication option is using clientId and clientSecret.

Advanced usage

Sampling strategies

For high-volume applications, you can configure sampling to reduce trace data volume:

from opentelemetry.sdk.trace.sampling import TraceIdRatioBased

# Sample 25% of traces
sampler = TraceIdRatioBased(0.25)
provider = TracerProvider(sampler=sampler, resource=resource)

Integrating with common libraries

OpenTelemetry provides auto-instrumentation for many popular libraries:

# Example for Flask instrumentation
from opentelemetry.instrumentation.flask import FlaskInstrumentor

app = Flask(__name__)
FlaskInstrumentor().instrument_app(app)

# Example for requests instrumentation
from opentelemetry.instrumentation.requests import RequestsInstrumentor
RequestsInstrumentor().instrument()