Prompt Flow
cetra reads the spans of Prompt Flow’s @trace functions and of the OpenAI calls they make, with the messages, the tokens and the cost of each call.
Install
Section titled “Install”Install Prompt Flow’s tracing package and its devkit, which sets up the exporter. The fixture was captured with both at 1.18.5.
pip install promptflow-tracing==1.18.5 promptflow-devkit==1.18.5 openaiThe fixture also pins opentelemetry-sdk to 1.38.0, because promptflow-tracing needs a version below 1.39.
Set up
Section titled “Set up”Prompt Flow traces only when PF_DISABLE_TRACING is false. Set the exporter variables, with the full traces URL, then start your program.
export PF_DISABLE_TRACING=falseexport OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8080/v1/tracesexport OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <SK_CETRA_KEY>"Replace <SK_CETRA_KEY> with your sk-cetra-… API key. See Send OpenTelemetry.
from openai import OpenAIfrom promptflow.tracing import tracefrom promptflow.tracing._start_trace import setup_exporter_from_environ
setup_exporter_from_environ()client = OpenAI()
@tracedef answer(question: str) -> str: response = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": question}], ) return response.choices[0].message.content or ""
print(answer("What is the weather in Paris?"))Prompt Flow posts to OTEL_EXPORTER_OTLP_ENDPOINT exactly as you give it. Unlike most exporters, it does not add /v1/traces, so give the full URL.
What you get
Section titled “What you get”Each @trace function is one span, and each chat call inside a traced function is one llm span:
- The decorated function that starts the flow is a
span, with its inputs and its output as JSON text. - Each chat call is an
llmspan, with the provider, the response model, the token counts and the cost, which cetra computes from its price table. Its input and output are the messages, including the tool call in the answer. - A decorated tool function is a
span, with its arguments and its result. - An embedding call is an
embeddingspan with its token counts. No fixture covers it.
Limits
Section titled “Limits”- Set
PF_DISABLE_TRACING=false. Without it,@tracedoes nothing and no span is sent. - Prompt Flow’s
Functionspans are plainspans. Prompt Flow has no tool kind: a decorated function can be any code, so cetra does not call it a tool. - The fixture covers two chat calls through the OpenAI client, a tool call and then the answer. Other clients and Prompt Flow’s own LLM tools were not captured.
- Prompt Flow’s last release at capture time was 1.18.5, of 2026-05-01.
- The fixture was captured with
promptflow-tracingandpromptflow-devkit1.18.5 andopenai3.45.0. - If a field is missing, look at the span’s Attributes tab and compare it with Span attributes.
- Traces: read the trace as a tree and a timeline.
- Cost and tokens: how cost is computed from the token counts.