tencent cloud

Monitoring

Download
Focus Mode
Font Size
Last updated: 2026-09-30 18:15:49
AI-Translated
CodeBuddy Code supports reporting traces to your own OpenTelemetry Collector through the standard OTLP protocol, facilitating integration with enterprise self-built observability platforms.
Current Scope:
Supports traces (distributed tracing) + 4 privacy opt-in toggles. Custom reporting of metrics and logs is not currently supported.

Quick Start

# 1. Enable telemetry
export CODEBUDDY_CODE_ENABLE_TELEMETRY=1

# 2. Configure the OTLP endpoint
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

# 3. (Optional) Enable privacy opt-in content recording
export OTEL_LOG_USER_PROMPTS=1
export OTEL_LOG_TOOL_DETAILS=1
export OTEL_LOG_TOOL_CONTENT=1

# 4. Run
codebuddy
Note:
Compatible with Claude Code configuration: CLAUDE_CODE_ENABLE_TELEMETRY is equivalent to CODEBUDDY_CODE_ENABLE_TELEMETRY.

Configuration Variables

Basic Configuration

Variable
Purpose
Example
CODEBUDDY_CODE_ENABLE_TELEMETRY
Enable OTel reporting (required).
1
OTEL_TRACES_EXPORTER
Exporter type
otlp (default), console, none
OTEL_EXPORTER_OTLP_ENDPOINT
OTLP Collector address, with /v1/traces automatically appended.
http://localhost:4318
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
Dedicated full URL for Traces, with higher priority.
http://localhost:4318/v1/traces
OTEL_EXPORTER_OTLP_HEADERS
Request headers k1=v1,k2=v2, with URL encoding supported for values.
Authorization=Bearer%20token
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
Transport protocol
http/protobuf (only supported)
OTEL_SERVICE_NAME
Override the default service.name
codebuddy-code
OTEL_RESOURCE_ATTRIBUTES
Attach resource attributes.
team=platform,env=prod

Privacy opt-in Switch

By default, spans do not record any sensitive information (prompt content, tool parameters, tool outputs, and so on). You need to opt in incrementally through the following environment variables:
Variable
Purpose
Recorded Content
OTEL_LOG_USER_PROMPTS=1
Record user prompts.
user_prompt attribute (not recorded by default; only user_prompt_length is recorded).
OTEL_LOG_TOOL_DETAILS=1
Record tool parameters.
tool_input attribute (truncated at ~4 KB) + tool-specific attributes (file.path, command, and others)
OTEL_LOG_TOOL_CONTENT=1
Record full tool input and output.
tool_input/tool_result span events (truncated at 60 KB)
OTEL_LOG_RAW_API_BODIES=1
Record full API request/response bodies.
Reserved, not yet implemented

GenAI Semantic Convention Switch (agentLens / Zhiyan LLM Monitoring)

By default, reporting uses CodeBuddy's own naming conventions (such as codebuddy_code.* spans and span.type). To integrate with agentLens (Tencent Zhiyan LLM monitoring, based on OTel), append the gen_ai.* semantic convention fields through OTEL_SEMCONV (additive only, preserving all original fields):
Value
Description
codebuddy (default)
No new fields are written, and the behavior is exactly the same as the current state.
agentlens
Enable agentLens semantics and append fields such as gen_ai.*.
Disabled by default with zero impact on existing users. To disable it, simply unset the variable.
The input and output of LLM spans (input.value / output.value) are produced along with this toggle, so you do not need to additionally enable OTEL_LOG_RAW_API_BODIES. However, the user prompt and final response text of entry spans are still gated by OTEL_LOG_USER_PROMPTS, and their content is not recorded when this toggle is disabled.
Your model requests are not modified: token usage (gen_ai.usage.*) depends on whether the upstream returns usage. If usage is not returned, the LLM span lacks the token field, while other fields remain unchanged. To obtain tokens reliably, include include_usage in your business-side requests.
Key fields carried by various spans after enabling:
span Type (span.type)
gen_ai.span.kind
Key Field
interaction (entry)
AGENT
gen_ai.user.time_to_first_token,input.value / output.value
subagent (nested)
AGENT
gen_ai.operation.name
model_stream (LLM call)
LLM
gen_ai.system / model_name / request.model / request.parameters / response.time_to_first_token / response.finish_reason / usage.input_tokens / usage.output_tokens / usage.total_tokens / input.value / output.value
tool / user_input_wait
TOOL
tool.name / tool.parameters / input.value / output.value
mcp_call
TOOL
tool.name / gen_ai.mcp.server_name / gen_ai.mcp.tool_name
context_compact / session_replay / teammate_busy
TASK
—
model_request
(Not reported)
See the description below.
Common fields (all spans): gen_ai.session.id / gen_ai.user.id / gen_ai.framework / gen_ai.business.scenario (omitted by default).
Note the field prefix: input.value / output.value / tool.name / tool.parameters follow the OpenInference convention and do not have the gen_ai. prefix, while gen_ai.system / gen_ai.model_name / gen_ai.mcp.* and similar fields do have the prefix.
model_request is not reported: it is an auxiliary HTTP request span for model calls and appears in pairs with model_stream, which carries the inference. Reporting both simultaneously causes duplicate counting of LLM call counts, tokens, and TTFT. Therefore, this span is not reported under agentlens. By default, the codebuddy trace remains fully intact for local troubleshooting.

Span Structure

Each user prompt produces a root span of type codebuddy_code.interaction. Tool call records are its child spans:
codebuddy_code.interaction
├── codebuddy_code.tool (Read)
├── codebuddy_code.tool (Bash)
└── codebuddy_code.tool (Agent -> tool spans of sub-agents)

Span Attributes

All spans include the span.type attribute to identify their type.
codebuddy_code.interaction
Attribute
Description
Controlled By
span.type
Fixed value "interaction"
-
conversation.id
Conversation ID
-
conversation.agent
Agent name
-
user_prompt
User prompt content (not recorded when the feature is disabled)
OTEL_LOG_USER_PROMPTS
user_prompt_length
Prompt length (always recorded)
-
conversation.cancelled
true when the conversation is canceled.
-
codebuddy_code.tool
Attribute
Description
Controlled By
span.type
Fixed value "tool"
-
tool_name
Tool Name
-
tool.call_id
Tool Call ID (Always Recorded)
-
file.path
File path (Read/Write/Edit)
OTEL_LOG_TOOL_DETAILS
command
Bash Command
OTEL_LOG_TOOL_DETAILS
command.timeout
Command timeout in milliseconds
OTEL_LOG_TOOL_DETAILS
glob.pattern
Glob search pattern
OTEL_LOG_TOOL_DETAILS
grep.pattern
Grep regular expression pattern
OTEL_LOG_TOOL_DETAILS
http.url
WebFetch URL
OTEL_LOG_TOOL_DETAILS
search.query
WebSearch query
OTEL_LOG_TOOL_DETAILS
agent.prompt
Sub-Agent prompt
OTEL_LOG_TOOL_DETAILS
agent.type
Sub-Agent type
OTEL_LOG_TOOL_DETAILS
mcp.server
MCP server name
OTEL_LOG_TOOL_DETAILS
mcp.tool
MCP tool name
OTEL_LOG_TOOL_DETAILS
tool_input
Tool input JSON, truncated at approximately 4 KB
OTEL_LOG_TOOL_DETAILS
tool_input_truncated
Whether the input is truncated
OTEL_LOG_TOOL_DETAILS
tool_input_original_length
Original length before truncation
OTEL_LOG_TOOL_DETAILS
codebuddy_code.tool span events (requires OTEL_LOG_TOOL_CONTENT=1)
Event name
Attribute
Description
tool_input
content
Complete tool input, truncated at 60 KB
tool_input
content_truncated
Truncated or Not
tool_input
content_original_length
Length before truncation
tool_result
content
Complete tool output, truncated at 60 KB
tool_result
content_truncated
Truncated or Not
tool_result
content_original_length
Length before truncation

Typical Scenarios

Reporting to a Self-Built Enterprise Collector

export CODEBUDDY_CODE_ENABLE_TELEMETRY=1
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otel.corp.example.com
export OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20<TOKEN>
export OTEL_SERVICE_NAME=codebuddy-code
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment=prod,team=copilot

Local Debugging (console Output)

export CODEBUDDY_CODE_ENABLE_TELEMETRY=1
export OTEL_TRACES_EXPORTER=console
export OTEL_LOG_USER_PROMPTS=1
export OTEL_LOG_TOOL_DETAILS=1
export OTEL_LOG_TOOL_CONTENT=1

Disabling telemetry

export OTEL_TRACES_EXPORTER=none
# Or disable globally:
export DISABLE_TELEMETRY=1

Priority and Fallback

1. DISABLE_TELEMETRY=1 has the highest priority and disables all telemetry.
2. Enablement determination: the built-in product configuration is enabled or CODEBUDDY_CODE_ENABLE_TELEMETRY / CLAUDE_CODE_ENABLE_TELEMETRY is set to a truthy value (1 / true / yes / on).
3. Endpoint priority: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT > OTEL_EXPORTER_OTLP_ENDPOINT > telemetry.tracing.url in the built-in product configuration.
4. Headers: env and product configurations are merged, and env keys with the same name override product keys.

Protocol Support

Only http/protobuf (OTLP/HTTP + Protobuf encoding) is supported, which is consistent with the Claude Code default. Setting OTEL_EXPORTER_OTLP_PROTOCOL=grpc or http/json is ignored and written to the alarm log, falling back to the default protobuf.

Security and Privacy

By default, spans record only tool names and call IDs, and do not include user prompts, tool parameters, file contents, or source code.
user_prompt_length is always recorded (length only), while the prompt text is written only when OTEL_LOG_USER_PROMPTS=1 is set.
Tool parameters (file paths, commands, and so on) require OTEL_LOG_TOOL_DETAILS=1. Individual values exceeding 512 characters are truncated, and the total size is limited to approximately 4 KB.
The full tool input and output content requires OTEL_LOG_TOOL_CONTENT=1. It is recorded through span events and truncated at 60 KB.
All opt-in switches are disabled by default, and enterprise administrators can configure them centrally through managed settings.

FAQs

Q1: Does It Conflict with Internal Enterprise Reporting Channels?

There is no conflict. OTel custom reporting and the built-in standard report (telemetry.report.standard) are two independent channels and can be enabled at the same time.

Q2: Are metrics/logs Supported?

Not yet supported, but it is on the roadmap. If you have a strong requirement, please provide feedback in the corresponding Issue.

Q3: Is It Compatible with Claude Code's OTEL Format?

Yes. Span naming, attribute naming, and truncation policies all align with Claude Code conventions ({product}.interaction / {product}.tool), ensuring that upstream analysis platforms can process them uniformly.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback