Sample
go.opentelemetry.io/otel/trace v1.47.0: TraceID
Verified sample for golang go.opentelemetry.io/otel/trace v1.47.0: TraceID. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:794c1039153d35179024dd1b368ef0d617aec2e86a3e25c012204b154323f7e1
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-10-10 |
Case
HOW- Goal
- verify go.opentelemetry.io/otel/trace.TraceID in pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0
- Symbols
-
- go.opentelemetry.io/otel/trace.TraceID
- Created
- 2026-10-10T18:46:31Z
Contract
- TraceIDFromHex creates a valid TraceID from a 32-character hexadecimal string.
- TraceIDFromHex returns an error for invalid length or invalid hexadecimal characters.
- TraceID zero value is invalid and produces a 32-character zero string.
- TraceID preserves raw byte array values and formats correctly via String.
- TraceID MarshalJSON outputs a valid quoted JSON hex string.
- TraceID integrates with SpanContext to identify traces.
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify go.opentelemetry.io/otel/trace.TraceID in pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/otel/trace.TraceID
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:ba01094bcbb2c977ad117ac478451205c7de0d9d46b7d6b9710615b516e8c102","contract":["TraceIDFromHex creates a valid TraceID from a 32-character hexadecimal string.","TraceIDFromHex returns an error for invalid length or invalid hexadecimal characters.","TraceID zero value is invalid and produces a 32-character zero string.","TraceID preserves raw byte array values and formats correctly via String.","TraceID MarshalJSON outputs a valid quoted JSON hex string.","TraceID integrates with SpanContext to identify traces."],"goal":"verify go.opentelemetry.io/otel/trace.TraceID in pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/trace.TraceID"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0","symbols":["go.opentelemetry.io/otel/trace.TraceID"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require go.opentelemetry.io/otel/trace v1.47.0
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
go.opentelemetry.io/otel v1.47.0 // indirect
)
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM=
go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0=
package main
import (
"encoding/json"
"fmt"
"go.opentelemetry.io/otel/trace"
)
func main() {
// 1. Create a TraceID from hex string (32 hex characters)
hexStr := "4bf92f3577b34da6a3ce929d0e0e4736"
traceID, err := trace.TraceIDFromHex(hexStr)
if err != nil {
panic(err)
}
fmt.Printf("TraceID: %s, IsValid: %t\n", traceID.String(), traceID.IsValid())
// 2. Create TraceID from raw byte array (16 bytes)
raw := [16]byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10}
rawTraceID := trace.TraceID(raw)
fmt.Printf("Raw TraceID: %s\n", rawTraceID.String())
// 3. Marshal TraceID to JSON
data, err := json.Marshal(traceID)
if err != nil {
panic(err)
}
fmt.Printf("JSON representation: %s\n", string(data))
// 4. Integrate with SpanContext
sc := trace.NewSpanContext(trace.SpanContextConfig{
TraceID: traceID,
})
fmt.Printf("SpanContext TraceID: %s, HasTraceID: %t\n", sc.TraceID().String(), sc.HasTraceID())
}
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/otel/trace.TraceID in pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel/trace@v1.47.0"
],
"symbols": [
"go.opentelemetry.io/otel/trace.TraceID"
]
}
package main
import (
"fmt"
"os"
"go.opentelemetry.io/otel/trace"
)
func main() {
// Assertion 1: TraceIDFromHex creates a valid TraceID from a 32-character hexadecimal string.
hexStr := "4bf92f3577b34da6a3ce929d0e0e4736"
traceID, err := trace.TraceIDFromHex(hexStr)
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: TraceIDFromHex returned error: %v\n", err)
os.Exit(1)
}
if !traceID.IsValid() {
fmt.Fprintf(os.Stderr, "FAIL: expected traceID to be valid\n")
os.Exit(1)
}
if traceID.String() != hexStr {
fmt.Fprintf(os.Stderr, "FAIL: expected String() to be '%s', got '%s'\n", hexStr, traceID.String())
os.Exit(1)
}
// Assertion 2: TraceIDFromHex returns an error for invalid length or invalid hexadecimal characters.
if _, err := trace.TraceIDFromHex("1234"); err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected error for short hex string\n")
os.Exit(1)
}
if _, err := trace.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e473678"); err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected error for long hex string\n")
os.Exit(1)
}
if _, err := trace.TraceIDFromHex("4bf92f3577b34da6a3ce929d0e0e47zz"); err == nil {
fmt.Fprintf(os.Stderr, "FAIL: expected error for non-hex characters\n")
os.Exit(1)
}
// Assertion 3: TraceID zero value is invalid and produces a 32-character zero string.
var zero trace.TraceID
if zero.IsValid() {
fmt.Fprintf(os.Stderr, "FAIL: expected zero TraceID to be invalid\n")
os.Exit(1)
}
if zero.String() != "00000000000000000000000000000000" {
fmt.Fprintf(os.Stderr, "FAIL: expected zero TraceID string '00000000000000000000000000000000', got '%s'\n", zero.String())
os.Exit(1)
}
// Assertion 4: TraceID preserves raw byte array values and formats correctly via String.
raw := [16]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}
rawTraceID := trace.TraceID(raw)
if !rawTraceID.IsValid() {
fmt.Fprintf(os.Stderr, "FAIL: expected rawTraceID with non-zero bytes to be valid\n")
os.Exit(1)
}
if rawTraceID.String() != "000102030405060708090a0b0c0d0e0f" {
fmt.Fprintf(os.Stderr, "FAIL: expected String() to be '000102030405060708090a0b0c0d0e0f', got '%s'\n", rawTraceID.String())
os.Exit(1)
}
if [16]byte(rawTraceID) != raw {
fmt.Fprintf(os.Stderr, "FAIL: byte representation mismatch\n")
os.Exit(1)
}
// Assertion 5: TraceID MarshalJSON outputs a valid quoted JSON hex string.
jsonData, err := traceID.MarshalJSON()
if err != nil {
fmt.Fprintf(os.Stderr, "FAIL: MarshalJSON returned error: %v\n", err)
os.Exit(1)
}
expectedJSON := fmt.Sprintf("%q", hexStr)
if string(jsonData) != expectedJSON {
fmt.Fprintf(os.Stderr, "FAIL: expected JSON %s, got %s\n", expectedJSON, string(jsonData))
os.Exit(1)
}
// Assertion 6: TraceID integrates with SpanContext to identify traces.
sc := trace.NewSpanContext(trace.SpanContextConfig{
TraceID: traceID,
})
if !sc.HasTraceID() {
fmt.Fprintf(os.Stderr, "FAIL: expected SpanContext to have TraceID\n")
os.Exit(1)
}
if sc.TraceID() != traceID {
fmt.Fprintf(os.Stderr, "FAIL: expected SpanContext TraceID '%s', got '%s'\n", traceID.String(), sc.TraceID().String())
os.Exit(1)
}
fmt.Println("PASS: all trace.TraceID contract assertions passed.")
}
Origin Seeder
anonymous