Langfuse¶
Send CredenceStack's traces to Langfuse (cloud or self-hosted) over OTLP/HTTP. Each scenario epoch appears as one trace, with the agent, tool and model calls as observations.
Facts on this page
Items marked (vendor docs) come from Langfuse's documentation as checked by the maintainers. Items marked TODO-verify were not confirmed by this build (it ran offline): check them against Langfuse's OpenTelemetry docs before relying on them.
Prerequisites¶
pip install "credencestack[otel]"- A Langfuse project (cloud or self-hosted) and permission to create API keys.
What you need from Langfuse¶
- The project's public key and secret key.
- Your region's endpoint (vendor docs):
| Region | OTLP endpoint |
|---|---|
| EU cloud | https://cloud.langfuse.com/api/public/otel |
| US cloud | https://us.cloud.langfuse.com/api/public/otel |
| Japan, HIPAA | Langfuse has these regions; their hosts are TODO-verify |
| Self-hosted | <your host>/api/public/otel |
Langfuse accepts OTLP over HTTP only (protobuf or JSON); gRPC is not supported
(vendor docs). The traces path is /api/public/otel/v1/traces (vendor docs),
which the exporter appends to the base endpoint for you.
Configure¶
Authentication is Basic auth built from the public and secret keys (vendor docs):
export LANGFUSE_PUBLIC_KEY=pk-lf-... # your project's keys
export LANGFUSE_SECRET_KEY=sk-lf-...
AUTH="$(printf '%s:%s' "$LANGFUSE_PUBLIC_KEY" "$LANGFUSE_SECRET_KEY" | base64 | tr -d '\n')"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://cloud.langfuse.com/api/public/otel"
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic%20${AUTH}"
Optional: Langfuse documents a header x-langfuse-ingestion-version=4 for real-time
display in its newer interface. Its current status is TODO-verify; to try it, append
,x-langfuse-ingestion-version=4 to OTEL_EXPORTER_OTLP_HEADERS.
Run¶
credencestack otel check
credencestack run -p payments -p resilience --agent my_agent:policy --otel
Verify¶
otel checkprints OK, and the run ends withOTel: exported N span(s).- In Langfuse, open your project's traces list (TODO-verify the menu name for your version) and set the time range to the last hour.
- You should see traces named
credencestack scenario PAY-001 #0and so on, one per scenario epoch, plus onecredencestack run <run_id>trace. - Open a scenario trace:
invoke_agent <your agent>withexecute_tool ...children (andchat ...for connectors that capture model calls), andcredencestack grade. - The scenario observation's attributes include
credencestack.result,credencestack.findings.countandcredencestack.findings.max_severity; its events include onecredencestack.findingper failing finding.
Useful views and alerts¶
- Filter on the metadata
credencestack.result = failto list failed scenarios, orcredencestack.findings.max_severity = critical. - Group by
credencestack.scenario.packorcredencestack.scenario.domain. - Add
CREDENCESTACK_OTEL_TRACE_URL_TEMPLATEwith your Langfuse trace URL pattern (containing{trace_id}) to link the report to Langfuse; the URL pattern is TODO-verify.
How Langfuse maps OpenTelemetry attributes to its own fields (metadata, input and output, usage) is Langfuse's choice and may change; it is TODO-verify which CredenceStack attributes it promotes.
Filter generated scenarios and difficulty¶
Scenario spans of generated scenarios carry
credencestack.forge.* attributes (reference). Langfuse keeps OpenTelemetry span attributes as observation metadata. In the traces view, filter on the metadata keys credencestack.forge.generated, credencestack.forge.level and credencestack.result (TODO-verify the exact filter field Langfuse shows for OTLP attributes), for example generated scenarios at level 4 or 5 that failed.
Compare the failure rate by level with the fixed scenarios (credencestack.forge.generated absent) to see the brittleness of an agent in your own traces.
Limitations and troubleshooting¶
- gRPC is not supported: keep
http/protobuf. - A 401 usually means the keys were swapped or the base64 value has a line break (use
tr -d '\n'). - Without
--otel-content, traces show no input or output: that is the default. Confidential content is never sent. - Self-hosted:
scripts/otel_smoke/langfuse.shsends the offline demo to a local instance started from Langfuse's own Docker Compose file.
Last verified¶
2026-11-28, offline: the facts marked (vendor docs) were supplied by the maintainers from Langfuse's documentation; nothing was tested against a Langfuse instance. Docs: https://langfuse.com/docs/opentelemetry/get-started.