Instrumentation & Tracing
Send the interactions your AI app produces to Prisma using OpenTelemetry, so they can be validated against your policies
Prisma validates the interactions your systems produce. Before it can validate anything, it has to see those interactions — every prompt your app sends and every response your model returns. Instrumentation is how they get there.
Prisma reads interactions over OpenTelemetry. You don't wrap your model calls or route them through a proxy. You point the SDK at your deployment, turn on an instrumentor for your LLM library, and each model call becomes a span that Prisma ingests and validates.
Tracing here is ingestion, not a dashboard
Prisma uses traces as the pipe that carries interactions in for validation — not as an observability product to browse. The goal isn't a latency chart; it's getting every interaction in front of your policies.
How it works
You add two things to your app — the SDK and an instrumentor. Everything past the network hop happens inside Prisma:
- In your app — your normal model call runs untouched. The instrumentor wraps it and emits an OpenTelemetry span carrying the input and output; the SDK's exporter ships spans in the background, so tracing adds no latency.
- On the wire — spans travel over OTLP/HTTP to
…/v1/traces, stamped with the project and run identity thatinit()configured. - In Prisma — each trace is received, the input and output are read off the span, and the interaction is validated against the evaluators attached to the run.
The SDK does not auto-instrument your code. It sets up the provider; you choose and enable the instrumentor. Any OpenTelemetry span emitted in the process — including from instrumentors you add yourself — is captured automatically.
Before you start
- A running Prisma deployment and an API key (
pq_prisma_sk_…). See Installation & Setup. - Python 3.10+ and an AI app to instrument.
Install the SDK and an instrumentor
Install palqee-prisma-ai plus the instrumentor that matches your LLM library.
pip install palqee-prisma-ai openinference-instrumentation-openaiuv pip install palqee-prisma-ai openinference-instrumentation-openaiSwap openinference-instrumentation-openai for the package that matches your stack — see Choose an instrumentor below.
Configure your environment
Point the SDK at your deployment with two environment variables.
export PALQEE_PRISMA_API_KEY="pq_prisma_sk_…"
export PALQEE_PRISMA_BASE_URL="https://prisma.your-company.com"Both are required. If either is missing, init() raises a PrismaValidationError telling you which one. Your workspace is resolved server-side from the API key — you never pass it.
Initialize and instrument
Call init() once at startup, then turn on an instrumentor. This page covers tracing only, so we omit evaluators — interactions flow in and are recorded against the run. To attach policies that validate them, see Validations.
Only two lines tie your app to Prisma — init() and the instrumentor — and just the instrumentor line changes from one library to the next. The example uses OpenAI; pick yours under Choose an instrumentor.
import palqee_prisma_ai
from openinference.instrumentation.openai import OpenAIInstrumentor
# 1. Configure tracing for this project. Returns a PrismaSession.
session = palqee_prisma_ai.init("support-bot")
# 2. Turn on the instrumentor for your library.
# This is the only line that changes per stack.
OpenAIInstrumentor().instrument()
# --- Your existing application code, unchanged — now traced. ---
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Why was I charged twice this month?"}],
)
print(response.choices[0].message.content)Confirm traces are arriving
Run your app, then open your support-bot project in Prisma. Under Validation Runs you'll see your run; the interaction count rises as spans arrive. If you attached evaluators, validations appear alongside.
Traces are batched, so allow a few seconds. Short-lived scripts should flush before exit — see Flush before exit.
Choose an instrumentor
Prisma ingests any OpenTelemetry span your process emits — it isn't tied to a fixed list of providers. So it works with the entire OpenInference and OpenLLMetry instrumentor ecosystems: LLM providers, agent and orchestration frameworks, vector databases, and more. To add coverage, install the matching instrumentor and call its .instrument() once at startup — nothing changes on Prisma's side.
A few common ones:
| Your stack | Instrumentor package (OpenInference) |
|---|---|
| OpenAI | openinference-instrumentation-openai |
| Anthropic | openinference-instrumentation-anthropic |
| Google Gemini | openinference-instrumentation-google-genai |
| Amazon Bedrock | openinference-instrumentation-bedrock |
| LangChain / LangGraph | openinference-instrumentation-langchain |
| LlamaIndex | openinference-instrumentation-llama-index |
| CrewAI | openinference-instrumentation-crewai |
This is a sample, not the full set. For the complete, always-current catalog — plus OpenLLMetry equivalents (opentelemetry-instrumentation-*, covering AutoGen, Haystack, vector stores, and more) — see:
- OpenInference instrumentors — LLM providers and agent frameworks
- OpenLLMetry instrumentors — providers, frameworks, and vector databases
The rule is simple: if it emits OpenTelemetry spans, Prisma captures it. For code no instrumentor covers, emit spans yourself — see Instrument custom code.
What Prisma reads from a span
By default Prisma reads interactions using OpenInference semantic conventions:
input.value— the prompt / user messageoutput.value— the model's responseinput.reference— optional ground-truth or reference text
The instrumentors above set these for you, and Prisma recognises both the OpenInference and OpenLLMetry conventions — so whichever ecosystem your instrumentor comes from, the fields are read automatically. You don't configure mapping for traces; init()'s input_mapping applies to batched datasets, not spans. For a step no instrumentor covers, set the attributes yourself — see Instrument custom code.
Instrument custom code
For a step no off-the-shelf instrumentor covers — a retrieval call, a tool, a homegrown model wrapper — create a span yourself with the OpenTelemetry API and set the attributes Prisma reads.
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("retrieval-answer") as span:
span.set_attribute("input.value", user_question)
answer = my_pipeline(user_question)
span.set_attribute("output.value", answer)Because init() already configured the provider, this span is exported and validated like any instrumented call.
Flush before exit
Spans are exported in the background, so a process that exits immediately can drop spans still in the buffer. The SDK registers an atexit handler that flushes on normal shutdown (up to a 5-second wait), so most apps need nothing extra.
For short scripts, batch jobs, and serverless / Lambda handlers — where the process may be frozen or killed right after returning — flush explicitly before you exit:
session = palqee_prisma_ai.init("support-bot")
# … your traced calls …
session.end() # force-flushes buffered spans, then closes the clientA hard kill (SIGKILL) still loses whatever is buffered — there's no handler to run.
Send traces to a different endpoint
By default traces go to {PALQEE_PRISMA_BASE_URL}/v1/traces. If your OpenTelemetry collector lives somewhere else — a split deployment, or a local collector in development — set the optional endpoint and the SDK sends traces there instead:
export PALQEE_PRISMA_OTEL_ENDPOINT="https://otel.your-company.com"Most deployments don't need this — the control-plane API and the trace endpoint share a host. The /v1/traces path is appended automatically if you omit it.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| No interactions appear | The instrumentor's .instrument() wasn't called, or ran after your model calls. Call it once, at startup, before any model call. |
| Last few interactions missing | Process exited before the batch flushed. Call session.end() before exit (see Flush before exit). |
PrismaAuthenticationError on init | API key is malformed — it must start with pq_prisma_sk_. Re-copy it from Organization Settings → API Keys. |
PrismaValidationError on init | PALQEE_PRISMA_API_KEY or PALQEE_PRISMA_BASE_URL isn't set. |
| Traces never arrive, no error | base_url points somewhere unreachable, or a collector override is wrong. Verify {base_url}/v1/traces is reachable. |
Next steps
- Validations — attach policies so ingested interactions are validated
- Policy Metrics — write the rules your interactions are checked against
- Human Review — route ambiguous cases to experts

