* docs(telemetry): align config and docs semantics for target, outfile, and CLI flags
- Remove stale warning note "This feature requires corresponding code
changes" — the OTLP implementation is now complete (#3779, #4061)
- Clarify that `target` is an informational destination label and does
not control exporter routing; `otlpEndpoint` or `outfile` must be set
to configure where data is sent
- Mark `--telemetry-target` CLI flag as deprecated in the configuration
table to match the deprecateOption() call in cli/src/config/config.ts
- Fix `outfile` / `QWEN_TELEMETRY_OUTFILE` descriptions: remove the
incorrect "when target is local" qualifier — outfile overrides OTLP
export regardless of the target value
- Simplify the file-based output example by removing the now-redundant
`"target": "local"` and `"otlpEndpoint": ""` fields
Closes the "Align telemetry config and docs semantics for target,
useCollector, otlpEndpoint, otlpProtocol, and outfile" checklist item
in #3731.
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* docs(telemetry): address Copilot review comments on outfile and target descriptions
- Fix outfile table row in telemetry.md: "overrides `otlpEndpoint`" →
"overrides OTLP export" (outfile disables all OTLP exporting, not
just the base endpoint)
- Use fully-qualified setting names (`telemetry.otlpEndpoint`,
`telemetry.outfile`) in the target description in settings.md for
consistency with the rest of the table
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
* docs(telemetry): update QWEN_TELEMETRY_TARGET env var description and add outfile note
- Align QWEN_TELEMETRY_TARGET env var description with the updated
telemetry.target setting semantics (informational label, not routing)
- Add a note after the file-based output example clarifying that outfile
automatically disables OTLP export
🤖 Generated with [Qwen Code](https://github.com/QwenLM/qwen-code)
useCollector was plumbed through config (interface, constructor, getter,
env var resolution) but never consumed by the telemetry SDK — the setting
had no runtime effect. TelemetryTarget.QWEN existed in the enum but
parseTelemetryTargetValue() only accepted 'local' and 'gcp', making
'qwen' unreachable (it would throw FatalConfigError).
Remove both dead code paths along with their tests and documentation.
Part of #3731
* feat(telemetry): add sensitive span attribute opt-in
Add a telemetry setting and environment override for including sensitive attributes in spans created by the log-to-span bridge. Keep the default filtering behavior for prompt, function_args, and response_text unless explicitly enabled.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): clarify span bridge options
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* feat(telemetry): populate api response text
Populate response_text on API response telemetry events for non-internal prompts so opted-in bridge spans can include model response bodies.
Exclude thought text from the recorded response text and keep internal prompt responses omitted.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* docs(telemetry): clarify sensitive span attribute scope
Clarify that the sensitive span attribute setting only controls log-to-span bridge spans, while response text may still reach other telemetry sinks from API response events.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): cap recorded response text
Limit response_text captured for API response telemetry to a bounded length and mark truncated values to avoid oversized OTLP attributes.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
---------
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* feat(telemetry): define HTTP OTLP endpoint behavior and signal routing
- Add resolveHttpOtlpUrl() that appends /v1/traces, /v1/logs, /v1/metrics
to base HTTP OTLP endpoints per the OpenTelemetry specification
- Add per-signal endpoint overrides (otlpTracesEndpoint, otlpLogsEndpoint,
otlpMetricsEndpoint) for backends with non-standard paths (e.g. Alibaba Cloud)
- Add LogToSpanProcessor that bridges OTel log records to spans for
traces-only backends, with session-based traceId correlation and
error status propagation
- Auto-wire LogToSpanProcessor when traces URL exists but logs URL doesn't
- Validate per-signal URLs gracefully (log error + skip, don't crash)
- Preserve query strings when appending signal paths to URLs
- Guard gRPC branch against missing base endpoint with per-signal config
- Update telemetry documentation with signal routing semantics and
Alibaba Cloud HTTP per-signal endpoint examples
Closes#3734
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): fix TS noPropertyAccessFromIndexSignature errors in tests
Use typed ExportedSpan interface and bracket notation for index signature
properties to satisfy strict TypeScript checks in CI.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): replace MD5 with SHA-256 for traceId derivation
CodeQL flagged MD5 as a weak cryptographic algorithm when used with
session.id (considered sensitive data). Switch to SHA-256 truncated
to 32 hex chars to satisfy CodeQL while maintaining the same traceId
format required by the OTel specification.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): address review feedback for LogToSpanProcessor robustness
- Wrap JSON.stringify in try/catch to handle circular refs and BigInt
- Add export timeout (30s) and try/catch to prevent hung shutdown
- Track in-flight exports to avoid interval-vs-shutdown race condition
- Fix deriveSpanStatus: use truthy checks (!!), drop success===false
heuristic since declined tool calls are normal, not errors
- Enforce http(s) scheme in validateUrl to reject file:/javascript: URLs
- Change DiagLogLevel from ERROR to WARN to preserve operational diagnostics
- Preserve logRecord.instrumentationScope instead of hardcoding
- Forward severityNumber/severityText as span attributes
- Add tests for circular refs, error status edge cases, severity
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): flush sdk shutdown through cleanup
Remove async process exit handlers from telemetry initialization and route SDK shutdown through Config cleanup so normal CLI exit paths await pending telemetry exports. Keep shutdown idempotent while an SDK shutdown is in flight.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): harden bridged log shutdown
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
* fix(telemetry): address review follow-ups
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
---------
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
The `tool_token_count` field was sourced from `toolUsePromptTokenCount`
on the GenAI usage metadata, but none of the providers we adapt
(OpenAI/DashScope, Anthropic) populate it, and Google's Gemini API only
emits it for built-in server-side tools that qwen-code does not use.
The metric was therefore always zero in practice, so the dedicated
counter, telemetry field, UI row, and supporting plumbing are removed
end-to-end (telemetry types, OTEL counter type, UI aggregation, model
stats display, qwen-logger payload, VS Code session schema, and docs).
- Remove deprecated fields: embedding_model, api_key_enabled, vertex_ai_enabled, log_prompts_enabled
- Add new fields: truncate_tool_output_threshold, truncate_tool_output_lines, hooks, ide_enabled, interactive_shell_enabled
This aligns telemetry data with the current CLI configuration options.
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>