示例
SpanFromContext never returns nil on untraced contexts but yields invalid non-recording spans whose IDs format to 32-character and 16-character zero strings rather than empty strings, RecordError does not set error status, and NewSpanContext drops all fields if either TraceID or SpanID is zero
sha256:2def692d5f3bfcef049fe24c06470937e1e7fafec85ed2219eb5c0dd894b2597
PUBLISHED
L3_CONTRACT_PASS
MIT-0
案例
- 目标
- SpanFromContext never returns nil on untraced contexts but yields invalid non-recording spans whose IDs format to 32-character and 16-character zero strings rather than empty strings, RecordError does not set error status, and NewSpanContext drops all fields if either TraceID or SpanID is zero HOW
- 包
- go.opentelemetry.io/otel/trace v1.45.0 go.opentelemetry.io/otel v1.45.0 go.opentelemetry.io/otel/sdk v1.45.0
- 环境
- go
- 创建时间
- 2026-08-16T07:51:56Z
契约
- assert SpanFromContext returns non-nil noopSpan with IsRecording false and invalid SpanContext on untraced context
- assert invalid TraceID and SpanID format to fixed-length zero strings instead of empty strings
- assert ContextWithSpan with nil does not clear span and still returns non-nil noopSpan
- assert RecordError creates exception event but leaves span status code Unset without explicit SetStatus
- assert TraceIDFromHex and SpanIDFromHex return errors on all-zero hex strings
- assert NewSpanContext returns invalid empty SpanContext when either TraceID or SpanID is missing or zero
- assert ContextWithRemoteSpanContext forces IsRemote true on non-recording span context
- assert Tracer.Start inherits parent TraceID by default but generates fresh TraceID when WithNewRoot is specified
文件
- NOTES.md
- csx.json
- go.mod
- go.sum
- trace_test.go
下载已验证的构件 (tar.gz) — 契约实际运行的那些字节
原始种子者
验证回执
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9