The `promptflow-tracing` package provides tracing capabilities for Prompt Flow, enabling the capture and visualization of internal execution processes for both DAG and Flex flows. It's designed to be compatible with OpenTelemetry, offering comprehensive observability for LLM-based applications, including those using frameworks like Langchain or OpenAI. The current version is 1.18.4, and the library is actively developed with frequent releases.
pip install promptflow-tracingVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to enable tracing for LLM calls (e.g., OpenAI) using `start_trace()` and how to trace custom functions with the `@trace` decorator. Upon execution, if `promptflow-devkit` is installed, a local URL to the trace UI will be printed to the console, allowing visualization of the captured traces.
To enable tracing, call `promptflow.tracing.start_trace()` in your application code or ensure appropriate environment variables are set for your deployment environment.
Upgrade your Python environment to 3.9 or newer (up to <4.0 as per PyPI metadata).
If tracing is not critical for deployment, temporarily disable it by setting the environment variable `PF_DISABLE_TRACING=true` in your deployment environment as a workaround. Investigate logs for missing token usage data if full tracing is required.
Review your application's interaction with `promptflow-tracing` and any integrated LLM frameworks. Explicitly manage `start_trace()` and `@trace` usage, or configure OpenTelemetry exporters to filter unwanted spans if necessary.
For explicit control, install `promptflow-tracing` directly. For the full Prompt Flow experience including UI visualization, `pip install promptflow` is generally sufficient and recommended. Always ensure a clean environment or upgrade carefully by uninstalling old `promptflow` versions before installing newer ones if issues arise.
Install the package using: `pip install promptflow-tracing`
Ensure LLM responses provide valid token information. If the issue persists, consider upgrading 'promptflow-tracing' to the latest version. A temporary workaround for deployment issues can be to disable tracing by setting the environment variable: `os.environ['PF_DISABLE_TRACING'] = 'true'`.
To enable tracing, add `from promptflow.tracing import start_trace; start_trace()` at the beginning of your application code, or set the environment variable `PF_DISABLE_TRACING='false'` before running your flow.