In an agent-based workspace, create an agent once before sending traces. Use agent addressing to select its identifier and environment. If an integration requires
project_name, use the selected environment’s tracer_session_name as a compatibility value.Prerequisites
Before setting up tracing, ensure you have:- A recent version of Visual Studio Code with GitHub Copilot Chat installed and signed in.
- A LangSmith API key.
Choose your harness
Since VS Code 1.143, Copilot runs on the new Copilot harness by default and you can still switch back to the older Local harness from the harness picker. Each one takes its own endpoint and settings. Only the Local harness sends Git information so use it if you want your traces tagged with the repo and branch.Configure tracing
Copilot Chat enables OTel emission when any ofCOPILOT_OTEL_ENABLED, OTEL_EXPORTER_OTLP_ENDPOINT, or the github.copilot.chat.otel.enabled setting (Local harness) is set. The simplest way to send Copilot Chat traces to LangSmith is to export the following environment variables before launching VS Code:
This endpoint is for the Copilot harness, which sends to the URL exactly as written. The Local harness adds
/v1/traces on its own so use https://api.smith.langchain.com/otel there instead.
VS Code must inherit these environment variables, so export them in the shell session that launches VS Code (for example, by adding them to ~/.zshrc, ~/.bashrc, or a shell profile) before starting the editor.
Set the endpoint to your LangSmith API URL (LANGSMITH_ENDPOINT) plus /otel on the Local harness, or plus /otel/v1/traces on the Copilot harness. For the URL on each deployment type, see Find your OTLP endpoint.
Alternative: VS Code settings
If you prefer not to set environment variables, you can enable OTel from VS Code settings instead. Open Settings (⌘, / Ctrl+,), search for copilot otel, and configure these for the Local harness:
chat.agentHost.otel.enabled, chat.agentHost.otel.otlpEndpoint (set to https://api.smith.langchain.com/otel/v1/traces), and chat.agentHost.otel.captureContent, as listed in VS Code’s Agent Host OTel reference.
Authentication headers must still be provided through the OTEL_EXPORTER_OTLP_HEADERS environment variable—VS Code settings do not expose a header field. On the Local harness, environment variables also take precedence over VS Code settings when both are set.
View traces in LangSmith
Start a Copilot Chat session and send a request. In LangSmith, select your agent and environment, then open Tracing. Each agent interaction produces a hierarchical span tree following the OTel GenAI Semantic Conventions:invoke_agentspans wrap the full agent orchestration, including agent name, conversation ID, turn count, and total token usage.chatspans capture individual LLM API calls with model, token counts, response time, and finish reason.execute_toolspans capture tool invocations with tool name, type, duration, and success status.
invoke_agent span appears as a child of the parent’s execute_tool span in LangSmith.
Trace metadata
LangSmith adds the same coding agent metadata that the Claude Code, Codex, and Cursor plugins send, so Copilot traces work with the same filters and charts. Each conversation is grouped into one thread, andls_integration is set to copilot.
On the Local harness, the top-level run includes the branch and commit of the open folder, plus the repo details when it has a remote. You don’t need to turn anything on for this. The Copilot harness doesn’t send Git information so those fields won’t appear on its traces.
Troubleshooting
- No traces appear in LangSmith. Confirm
COPILOT_OTEL_ENABLED=trueand that VS Code was launched from the shell where the variables are exported. VerifyOTEL_EXPORTER_OTLP_HEADERSincludesx-api-key=<your_langsmith_api_key>and that the API key belongs to the workspace you want to trace into. Restart VS Code after changing environment variables. - Traces land in the wrong environment. Set
Langsmith-Agent-Id=<your-agent-id>,Langsmith-Agent-Environment=localinOTEL_EXPORTER_OTLP_HEADERS. Use the registered agent ID and the intended environment. RemoveLangsmith-Projectwhen using agent headers. - No traces from the Copilot harness. Its endpoint must end in
/otel/v1/traces, since it doesn’t add the path itself. - Prompts and responses are missing. Content capture is opt-in. On the Local harness, set
COPILOT_OTEL_CAPTURE_CONTENT=true(or enablegithub.copilot.chat.otel.captureContent), and on the Copilot harness setOTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true(or enablechat.agentHost.otel.captureContent).
Related resources
- VS Code Copilot: Monitor agent usage with OpenTelemetry
- Trace with OpenTelemetry
- Configure legacy integrations
Connect these docs to your agent of choice via MCP for real-time answers.

