Skip to main content

Logging & Tracing

Logging

When using DBOS, we recommend you do all logging via Python's built-in logger. This allows DBOS Cloud to collect and display your logs.

For convenience, DBOS provides a pre-configured logger for you to use available at DBOS.logger. For example:

DBOS.logger.info("Welcome to DBOS!")

You can configure the log level of this built-in logger in your dbos-config.yaml file

telemetry:
logs:
logLevel: 'INFO'

Tracing

DBOS automatically constructs OpenTelemetry traces of all workflows and their steps. If you are using FastAPI or Flask, it also automatically traces each HTTP request.

DBOS constructs hierarchical spans for workflows and each of their steps. For example, if a FastAPI HTTP endpoint calls a workflow that calls a transaction, DBOS constructs a trace encompassing the entire request, with spans for the HTTP endpoint, the workflow, and the transaction. The transaction span is a child of the workflow span, which is a child of the HTTP endpoint span. You can access your current span via DBOS.span

OpenTelemetry Export

You can export DBOS logs and traces to any OpenTelemetry Protocol (OTLP)-compliant receiver. In DBOS Cloud, this is done automatically, and you can view your logs and traces in your cloud console and monitoring dashboard.

Locally, you can configure exporters in your dbos-config.yaml:

telemetry:
OTLPExporter:
logsEndpoint: http://localhost:4318/v1/logs
tracesEndpoint: http://localhost:4318/v1/traces

For example, try using Jaeger to visualize the traces of your local application.