You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(telemetry): define HTTP OTLP endpoint behavior and signal routing (#3779)
* 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>
|`otlpProtocol`|`QWEN_TELEMETRY_OTLP_PROTOCOL`|`--telemetry-otlp-protocol <grpc\|http>`| OTLP transport protocol |`"grpc"`/`"http"`|`"grpc"`|
67
-
|`outfile`|`QWEN_TELEMETRY_OUTFILE`|`--telemetry-outfile <path>`| Save telemetry to file (overrides `otlpEndpoint`) | file path | - |
68
-
|`logPrompts`|`QWEN_TELEMETRY_LOG_PROMPTS`|`--telemetry-log-prompts` / `--no-telemetry-log-prompts`| Include prompts in telemetry logs |`true`/`false`|`true`|
69
-
|`useCollector`|`QWEN_TELEMETRY_USE_COLLECTOR`| - | Use external OTLP collector (advanced) |`true`/`false`|`false`|
|`outfile`|`QWEN_TELEMETRY_OUTFILE`|`--telemetry-outfile <path>`| Save telemetry to file (overrides `otlpEndpoint`) | file path | - |
71
+
|`logPrompts`|`QWEN_TELEMETRY_LOG_PROMPTS`|`--telemetry-log-prompts` / `--no-telemetry-log-prompts`| Include prompts in telemetry logs |`true`/`false`|`true`|
72
+
|`useCollector`|`QWEN_TELEMETRY_USE_COLLECTOR`| - | Use external OTLP collector (advanced) |`true`/`false`|`false`|
70
73
71
74
**Note on boolean environment variables:** For the boolean settings (`enabled`,
72
75
`logPrompts`, `useCollector`), setting the corresponding environment variable to
73
76
`true` or `1` will enable the feature. Any other value will disable it.
74
77
78
+
**HTTP OTLP signal routing:** When using HTTP protocol (`otlpProtocol: "http"`),
0 commit comments