Logging & Tracing
Logging
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 through the DBOS constructor. This also configures the log level of the DBOS library.
config: DBOSConfig = {
"name": "my-app"
"log_level": "INFO"
}
DBOS(config=config)
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 traces to any OpenTelemetry Protocol (OTLP)-compliant receiver.
You can configure exporters through the DBOS constructor. For example:
config: DBOSConfig = {
"name": "my-app"
"otlp_traces_endpoints": ["http://localhost:4318/v1/traces"]
}
DBOS(config=config)
For example, try using Jaeger to visualize the traces of your local application.