Skip to main content

Documentation Index

Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-opensw-1778791721-ab646b9.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

VS Code Copilot Chat can export traces, metrics, and events over OpenTelemetry (OTel). Because LangSmith ingests OTLP directly, you can point Copilot Chat at LangSmith and inspect agent turns, model metadata, tool calls, and token usage alongside the rest of your LLM traces. This guide is based on Copilot’s Monitor agent usage with OpenTelemetry reference.

Prerequisites

Before setting up tracing, ensure you have:

Configure tracing

Copilot Chat enables OTel emission when any of COPILOT_OTEL_ENABLED, OTEL_EXPORTER_OTLP_ENDPOINT, or the github.copilot.chat.otel.enabled setting is set. The simplest way to send Copilot Chat traces to LangSmith is to export the following environment variables before launching VS Code:
export COPILOT_OTEL_ENABLED=true
export COPILOT_OTEL_PROTOCOL=http
export COPILOT_OTEL_ENDPOINT=https://api.smith.langchain.com/otel
export COPILOT_OTEL_CAPTURE_CONTENT=true
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<your_langsmith_api_key>,Langsmith-Project=<your_project_name>"
VariableDescription
COPILOT_OTEL_ENABLEDSet to true to enable Copilot Chat OTel export.
COPILOT_OTEL_PROTOCOLOTLP protocol. Use http to target LangSmith’s HTTP OTLP ingestion endpoint.
COPILOT_OTEL_ENDPOINTLangSmith OTLP endpoint. Takes precedence over OTEL_EXPORTER_OTLP_ENDPOINT.
COPILOT_OTEL_CAPTURE_CONTENTCapture full prompts, responses, tool arguments, and tool results on spans. Off by default.
OTEL_EXPORTER_OTLP_HEADERSAuthentication headers for the OTLP exporter. Use x-api-key=<your_langsmith_api_key> and optionally Langsmith-Project=<project> to route traces to a specific LangSmith project.
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.
Update the LangSmith endpoint for self-hosted installations or regional SaaS: GCP EU uses eu.api.smith.langchain.com; GCP APAC uses apac.api.smith.langchain.com; AWS US uses aws.api.smith.langchain.com. For self-hosted LangSmith, append /api/v1/otel to your LangSmith API URL—for example, https://ai-company.com/api/v1/otel.
COPILOT_OTEL_CAPTURE_CONTENT=true records full prompt and response content, system prompts, tool schemas, tool arguments, and tool results. Only enable it in trusted environments where capturing source code, file contents, and user prompts is acceptable.

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:
{
  "github.copilot.chat.otel.enabled": true,
  "github.copilot.chat.otel.exporterType": "otlp-http",
  "github.copilot.chat.otel.otlpEndpoint": "https://api.smith.langchain.com/otel",
  "github.copilot.chat.otel.captureContent": true
}
Authentication headers must still be provided through the OTEL_EXPORTER_OTLP_HEADERS environment variable—VS Code settings do not expose a header field. 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. Open your LangSmith project to view the resulting traces. Each agent interaction produces a hierarchical span tree following the OTel GenAI Semantic Conventions:
  • invoke_agent spans wrap the full agent orchestration, including agent name, conversation ID, turn count, and total token usage.
  • chat spans capture individual LLM API calls with model, token counts, response time, and finish reason.
  • execute_tool spans capture tool invocations with tool name, type, duration, and success status.
When an agent invokes a subagent, Copilot Chat propagates trace context automatically, so the subagent’s invoke_agent span appears as a child of the parent’s execute_tool span in LangSmith.

Add custom resource attributes

Use OTEL_RESOURCE_ATTRIBUTES to tag every trace with organizational metadata such as team or environment:
export OTEL_RESOURCE_ATTRIBUTES="team.id=platform,department=engineering"
These appear as resource attributes on each span and can be used to filter traces in LangSmith.

Troubleshooting

  • No traces appear in LangSmith. Confirm COPILOT_OTEL_ENABLED=true and that VS Code was launched from the shell where the variables are exported. Restart VS Code after changing environment variables.
  • 401 / 403 errors. Verify OTEL_EXPORTER_OTLP_HEADERS includes x-api-key=<your_langsmith_api_key> and that the API key belongs to the workspace you want to trace into.
  • Traces land in the wrong project. Set Langsmith-Project=<your_project_name> in OTEL_EXPORTER_OTLP_HEADERS. If unset, traces go to the workspace’s default project.
  • Prompts and responses are missing. Content capture is opt-in. Set COPILOT_OTEL_CAPTURE_CONTENT=true (or enable the github.copilot.chat.otel.captureContent setting).