Observability
Observability is a measure of how well internal states of a system can be inferred from knowledge of its external outputs. In the context of a software system, observability is the ability to understand the internal state of the system by examining its outputs. This is important for debugging, monitoring, and maintaining the system.
Observability In DB-GPT
DB-GPT provides observability through the following mechanisms:
- Logging: DB-GPT logs various events and metrics to help you understand the internal state of the system.
- Tracing: DB-GPT provides tracing capabilities to help you understand the flow of requests through the system.
Logging
You can configure the logging level and storage location for DB-GPT logs. By default,
logs are stored in the logs
directory in the DB-GPT root directory. You can change
the log level and storage location by setting the DBGPT_LOG_LEVEL
and DBGPT_LOG_DIR
environment.
Tracing
DB-GPT has built-in tracing capabilities that allow you to trace the flow of requests through the system.
Trace Storage
Local Storage
DB-GPT will store traces in the traces
directory in the DB-GPT logs directory, by default,
they are located in logs/dbgpt*.jsonl
.
If you want to know more about the local storage of traces and how to use them, you can refer to the Debugging documentation.
OpenTelemetry Support
DB-GPT also supports OpenTelemetry for distributed tracing. Now, you can export traces to open-telemetry compatible backends like Jaeger, Zipkin, and others with OpenTelemetry Protocol (OTLP).
To enable OpenTelemetry support, you need install following packages:
pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp
Then, modify your .env
file to enable OpenTelemetry tracing:
## Whether to enable DB-GPT send trace to OpenTelemetry
TRACER_TO_OPEN_TELEMETRY=True
## More details see https://opentelemetry-python.readthedocs.io/en/latest/exporter/otlp/otlp.html
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4317
In the above configuration, you can change the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
to
your OTLP collector or backend, we use gRPC endpoint by default.
Here, we use Jaeger as an example to show how to use OpenTelemetry to trace DB-GPT.
Jaeger Support
Here is an example of how to use Jaeger to trace DB-GPT with docker:
Run the Jaeger all-in-one image:
docker run --rm --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 9411:9411 \
jaegertracing/all-in-one:1.58