Trace GitHub Copilot with Langfuse
What is GitHub Copilot? GitHub Copilot is GitHub's AI coding assistant. Its agent mode in VS Code and the Copilot CLI can understand your codebase, edit files, run commands, and complete multi-step coding tasks autonomously.
What is Langfuse? Langfuse is an open-source AI engineering platform. It helps teams trace agentic applications, debug issues, evaluate quality, and monitor costs in production.
What can this integration trace?
GitHub Copilot has built-in OpenTelemetry export, and Langfuse is an OpenTelemetry backend. Point Copilot's exporter at Langfuse's OTLP endpoint and traces flow in with no SDK, no proxy, and no code changes. You can monitor:
- Agent runs: one
invoke_agentspan per chat or agent-mode interaction, wrapping the full orchestration - LLM calls: one
chatspan per model API call, with model name, provider, and finish reasons - Tool calls: one
execute_toolspan per tool invocation (terminal commands, file edits, MCP tools), plusexecute_hookspans for hooks - Token usage: input, output, cache-read, cache-creation, and reasoning tokens per model call, so you can monitor cost
- Prompts and responses: full message content and tool arguments when content capture is enabled (see below)
- Context: conversation and session IDs, plus git context (repository URL, branch, commit SHA) for filtering traces by repo or team
All spans follow the OpenTelemetry GenAI semantic conventions, which Langfuse maps natively to traces, generations, and tool observations.
Content capture is off by default
By default, Copilot exports span structure, timing, and token counts but no prompt content, model responses, or tool arguments. To see inputs and outputs in Langfuse, enable content capture (github.copilot.chat.otel.captureContent in VS Code, OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true for the Copilot CLI). Only enable it if you are comfortable storing this content in Langfuse.
Copilot exports OTLP over HTTP: the VS Code extension uses http/protobuf by default and the Copilot CLI uses http/json. Langfuse's OTLP endpoint accepts both, so no collector or proxy is needed. gRPC is not supported by Langfuse, but Copilot doesn't require it.
Set up Langfuse
Sign up for Langfuse Cloud or self-host Langfuse. Create a project and copy your public and secret API keys from the project settings.
Create your Basic Auth header
Langfuse authenticates OTLP requests with Basic Auth. Generate the header value by base64-encoding your keys as public_key:secret_key:
# macOS / BSD
echo -n "pk-lf-1234567890:sk-lf-1234567890" | base64
# Linux / GNU (disable line wrapping)
echo -n "pk-lf-1234567890:sk-lf-1234567890" | base64 -w 0The result is referred to as <AUTH_STRING> in the next steps.
Configure VS Code
Add the OpenTelemetry settings to your VS Code settings.json:
{
"github.copilot.chat.otel.enabled": true,
"github.copilot.chat.otel.otlpEndpoint": "https://cloud.langfuse.com/api/public/otel", // πͺπΊ EU data region
// Other Langfuse data regions: πΊπΈ US https://us.cloud.langfuse.com/api/public/otel,
// π―π΅ Japan https://jp.cloud.langfuse.com/api/public/otel, βοΈ HIPAA https://hipaa.cloud.langfuse.com/api/public/otel
// π Local deployment: http://localhost:3000/api/public/otel
"github.copilot.chat.otel.exporterType": "otlp-http",
"github.copilot.chat.otel.captureContent": true, // opt-in: include prompts, responses, and tool arguments
}Authentication headers can only be configured through the OTEL_EXPORTER_OTLP_HEADERS environment variable β there is no VS Code setting for them. Add it to your shell profile (~/.zshrc, ~/.bashrc, or ~/.bash_profile):
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <AUTH_STRING>,x-langfuse-ingestion-version=4"The environment variable must be visible to the VS Code process. After setting it, fully restart VS Code from a terminal that has the variable set (code .), or set it system-wide and log out and back in.
Configure the Copilot CLI (optional)
The standalone Copilot CLI is configured entirely through environment variables. Add these to your shell profile:
export COPILOT_OTEL_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT="https://cloud.langfuse.com/api/public/otel" # πͺπΊ EU data region
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <AUTH_STRING>,x-langfuse-ingestion-version=4"
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true # opt-in: include prompts, responses, and tool argumentsWhen you launch terminal CLI sessions from VS Code with OpenTelemetry enabled, the extension forwards COPILOT_OTEL_ENABLED and the endpoint automatically β but not the content-capture flag, so set OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT yourself if you want prompts and responses from CLI sessions.
Use Copilot and view traces in Langfuse
Use Copilot chat or agent mode as usual. Open your Langfuse project to see the captured traces:
- Agent traces (
invoke_agent): one trace per turn, from your prompt to the final answer - Generations (
chat): one per model call, with input messages, response, model name, and token usage - Tool spans (
bash,view,grep, β¦): nested under the agent span, with arguments and results when content capture is enabled - Sessions: turns that share a Copilot conversation are grouped via the session ID β open the Sessions view to replay a full multi-turn run
![]()
Notes and limitations
- Langfuse ingests traces only. Copilot also emits OTel metrics and events; Langfuse's OTLP endpoint does not store these signals. Trace data β including token usage on spans β is unaffected.
- Large attributes are truncated by the
github.copilot.chat.otel.maxAttributeSizeCharssetting in VS Code. Set it to0to disable truncation. - Data privacy. With content capture enabled, prompts, model responses, and tool inputs/outputs are stored in Langfuse. Leave
captureContentoff for sessions that touch data you don't want persisted. - No overhead when disabled. Copilot doesn't load the OTel SDK unless export is enabled.
Troubleshooting
No traces appearing in Langfuse
- OpenTelemetry isn't enabled. Confirm
github.copilot.chat.otel.enabledistrue(VS Code) orCOPILOT_OTEL_ENABLED=true(CLI). - The headers variable isn't visible to the process. VS Code must be launched from an environment where
OTEL_EXPORTER_OTLP_HEADERSis set β restarting from a configured terminal withcode .is the most reliable way to verify. - Debug locally first. Set
github.copilot.chat.otel.exporterTypeto"console"(orCOPILOT_OTEL_EXPORTER_TYPE=filefor the CLI) to confirm spans are being generated before pointing the exporter at Langfuse.
Authentication errors
Verify your API keys are correct, the base64 string was generated without line wrapping, and the endpoint matches the region your keys belong to:
- EU region:
https://cloud.langfuse.com/api/public/otel - US region:
https://us.cloud.langfuse.com/api/public/otel - Japan region:
https://jp.cloud.langfuse.com/api/public/otel - HIPAA region:
https://hipaa.cloud.langfuse.com/api/public/otel
Traces have no input/output content
Content capture is off by default β the spans still carry model name and token usage, but prompts, responses, and tool arguments are suppressed. Enable github.copilot.chat.otel.captureContent (VS Code) or OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true (Copilot CLI) and start a new Copilot session.
Learn more
- Langfuse OpenTelemetry endpoint: Endpoint, authentication, and supported protocols
- VS Code: Monitor agent usage with OpenTelemetry: Full list of settings, signals, and attributes
- Copilot SDK OpenTelemetry instrumentation: Tracing agents built on the Copilot SDK
- Use Langfuse in VS Code via MCP: The reverse direction β let Copilot query your Langfuse prompts, traces, and datasets
Last edited