feat(telemetry): add sensitive span attribute opt-in#3893
Conversation
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>
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
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>
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>
wenshao
left a comment
There was a problem hiding this comment.
Critical design concern (not mappable to a single diff line):
response_text now unconditionally flows to OTel direct log exporters, uiTelemetryService, and chatRecordingService with no opt-out. The logApiResponse function in loggers.ts uses ...event spread to copy all ApiResponseEvent properties into OTel log attributes. Before this PR, response_text was always undefined — the spread was a no-op. Now it is populated for non-internal prompts, yet includeSensitiveSpanAttributes only gates the log-to-span bridge. Unlike logPrompts, there is no equivalent guard for response logging.
Consider gating response_text behind includeSensitiveSpanAttributes in logApiResponse, or introducing a parallel logResponses setting.
— deepseek-v4-pro via Qwen Code /review
| 'response_text', | ||
| ]); | ||
|
|
||
| interface LogToSpanProcessorOptions { |
There was a problem hiding this comment.
[Suggestion] Setting name includeSensitiveSpanAttributes is misleading — only controls bridge spans
The name suggests it governs sensitive attributes across all telemetry sinks, but it only controls the log-to-span bridge (activated only in HTTP traces-only mode). Direct OTel log exporters, uiTelemetryService, and chatRecordingService all receive response_text irrespective of this setting. The settings schema description already documents this limitation, but the name itself invites misconfiguration.
Consider renaming to includeSensitiveBridgeSpanAttributes to accurately communicate scope.
— deepseek-v4-pro via Qwen Code /review
There was a problem hiding this comment.
Thanks for calling this out. I am going to keep the current includeSensitiveSpanAttributes name for this PR. This setting name was part of the original user-facing configuration design (telemetry.includeSensitiveSpanAttributes and QWEN_TELEMETRY_INCLUDE_SENSITIVE_SPAN_ATTRIBUTES), and the implementation now consistently passes that same name through config, SDK initialization, and the bridge options. The docs and schema have also been updated to explicitly say this only controls log-to-span bridge spans and does not govern OTel logs or other telemetry sinks. Renaming it to includeSensitiveBridgeSpanAttributes would be more explicit, but at this point it creates broader config/env/doc churn without changing behavior, so I prefer to keep the established name and rely on the clarified scope documentation.
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>
| return; | ||
| } | ||
|
|
||
| text += partText.slice(0, Math.max(0, remaining)); |
There was a problem hiding this comment.
[Suggestion] Math.max(0, remaining) is dead code — remaining can never be negative in this branch. The only way to reach this path is when partText.length > remaining, which implies remaining >= 0 since text.length never exceeds MAX_RESPONSE_TEXT_PREFIX_LENGTH (guarded by the truncation logic above). The defensive Math.max suggests uncertainty about the invariant.
| text += partText.slice(0, Math.max(0, remaining)); | |
| text += partText.slice(0, remaining); |
— deepseek-v4-pro via Qwen Code /review
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* 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): 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>
Summary
Validation
prompt,function_args, andresponse_textare retained in bridge-generated spans. Non-internal API responses populate response text at the source event so the bridge can forward it when the sensitive-span setting is enabled.Scope / Risk
response_textwhen a logs exporter is configured, and UI telemetry/chat recording can contain it for non-internal prompts. QwenLogger does not include response text.Testing Matrix
Testing matrix notes:
Linked Issues / Bugs