For the complete documentation index, see llms.txt. This page is also available as Markdown.

Tracing Copilot with Langfuse

Copilot can send a trace of every chat request to Langfuse, an LLM observability platform. Use it to see what Copilot did on a turn and why: the prompts it sent, the model's replies, each tool it called with the tool's input and output, and the token usage and latency of each step.

Tracing is off by default. It turns on when both Langfuse keys are configured, and it works with Langfuse Cloud and with a self-hosted Langfuse instance.

Configuration

Environment Variable
Default
Description

COPILOT_LANGFUSE_PUBLIC_KEY

(unset)

Public key of your Langfuse project (pk-lf-...).

COPILOT_LANGFUSE_SECRET_KEY

(unset)

Secret key of your Langfuse project (sk-lf-...).

COPILOT_LANGFUSE_BASE_URL

https://cloud.langfuse.com

URL of the Langfuse instance. Leave it unset for Langfuse Cloud in the EU region. Set it to https://us.cloud.langfuse.com for the US region, or to the URL of a self-hosted instance.

  1. In Langfuse, open the project that should receive the traces and create an API key pair in its settings.

  2. In the Backoffice, set COPILOT_LANGFUSE_PUBLIC_KEY and COPILOT_LANGFUSE_SECRET_KEY, plus COPILOT_LANGFUSE_BASE_URL if you don't use Langfuse Cloud in the EU region. On a self-managed installation you can set them as environment variables instead.

  3. Send a message to Copilot. The trace appears in Langfuse a few seconds after the turn ends.

You don't need to restart anything. Copilot reads the keys on every chat request, so a new or rotated key pair takes effect on the next request. To turn tracing off, remove either key (for example DELETE /config/COPILOT_LANGFUSE_SECRET_KEY). Spans that are still buffered are sent before the pipeline shuts down.

Both keys must be set for tracing to work. An empty or whitespace-only value counts as unset, and the Backoffice rejects one.

Copilot sends the traces from the Appmixer API nodes, so those nodes need outbound HTTPS access to the Langfuse URL. On an installation with restricted egress, allow this host before you enable tracing.

What a trace contains

Each Copilot chat turn becomes one trace, named copilot.chat. It contains the whole agent run: every LLM call with its prompt and completion, every tool call with its input and output, and the token usage and latency of each step.

Copilot sets these trace attributes so you can filter and group traces:

Langfuse field
Value

User ID

ID of the Appmixer user who sent the message.

Session ID

ID of the Copilot conversation thread, so every turn of one conversation is grouped in one Langfuse session.

Tags

copilot; the provider path, direct or appmixer-cloud-proxy; and on the direct path, the LLM provider, such as anthropic.

Metadata

flowId, when the conversation is about a flow.

To look into a user's report, filter by their user ID, open the session for the conversation and step through the turn that went wrong.

Data protection

A trace can contain:

  • The user's messages and Copilot's replies.

  • The system prompt, including COPILOT_CUSTOM_CONTEXT, COPILOT_TONE_OF_RESPONSE and the user's aiContext (see Per-user context).

  • Tool inputs and outputs, such as the flow descriptor, the components available to the user, and inspector field options.

  • Example values of output variables from the flow's most recent run, up to COPILOT_VARIABLES_MAX_EXAMPLE_CHARS characters each (160 by default). These values are the real data that passed through the flow.

If the data that flows through your flows must not leave the platform, set COPILOT_VARIABLES_MAX_EXAMPLE_CHARS to 0. Copilot then doesn't read run data at all, so it reaches neither the model nor the traces.

Copilot never puts the values of the LLM gateway headers (COPILOT_LLM_HEADERS and the headers forwarded by COPILOT_FORWARDED_HEADERS) into a trace. The Langfuse keys are never logged.

Relation to OpenTelemetry

Langfuse tracing doesn't depend on the platform's OpenTelemetry instrumentation, and you can enable either one or both. Copilot sends its traces through its own pipeline, which records every request: a sampling ratio configured for the platform's OpenTelemetry, such as OTEL_TRACES_SAMPLER, doesn't drop Copilot traces.

Verifying the setup

The Appmixer API node logs show whether tracing is active:

  • Copilot Langfuse tracing enabled. is logged with the base URL when the first chat request after you configure the keys sets up the tracing pipeline.

  • Copilot plugin configuration. is logged when the plugin loads. It includes langfuseEnabled and langfuseBaseUrl, but only as they were at startup, so keys added later in the Backoffice don't show in this message.

  • Copilot Langfuse tracing could not be initialized; continuing without it. means the configuration was rejected. Chat keeps working without traces, and Copilot doesn't try again until the Langfuse configuration changes. The warning is logged once.

  • Copilot Langfuse flush failed. means traces could not be delivered, usually because the URL is unreachable or the keys are wrong.

If tracing is enabled but no traces appear, check that the keys belong to the project you are looking at, that COPILOT_LANGFUSE_BASE_URL matches the region of your Langfuse account, and that the API nodes can reach that URL.

Other debugging options

  • Copilot errors, LLM retries and tool failures are written to the regular Appmixer logs, without the content of the messages.

  • On a self-managed installation, you can turn on debug logging for Copilot alone with LOG_LEVEL_OVERRIDES=system-plugin-copilot:debug and leave the rest of the node at its usual level. LOG_LEVEL=debug also works, but it applies to everything running on the node.

  • The AI usage page in Insights shows token usage and cost per user and per request. See Monitoring AI Usage.

Last updated

Was this helpful?