CodeSampleX

Sample

go.opentelemetry.io/otel/trace v1.24.0: NewSpanEndConfig

Verified sample for golang go.opentelemetry.io/otel/trace v1.24.0: NewSpanEndConfig. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:76705f7b98a3a6aa37cab4206a8ae9a5ce232349c2c39f4d9386ccc888c228e1

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-09-03

Case

HOW
Goal
verify go.opentelemetry.io/otel/trace.NewSpanEndConfig in pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0
Packages
Symbols
  • go.opentelemetry.io/otel/trace.NewSpanEndConfig
Created
2026-09-03T01:30:07Z

Contract

  1. NewSpanEndConfig returns default SpanConfig with zero timestamp and disabled stack trace when called with no options
  2. NewSpanEndConfig applies WithTimestamp option to configure end timestamp
  3. NewSpanEndConfig applies WithStackTrace option to configure stack trace capture
  4. NewSpanEndConfig applies multiple SpanEndOption configurations concurrently
  5. NewSpanEndConfig applies later SpanEndOption to overwrite earlier option value

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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.NewSpanEndConfig in pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0
Demonstrate these symbols/APIs:
  - go.opentelemetry.io/otel/trace.NewSpanEndConfig

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.
csx.json
{"case":{"caseId":"case:sha256:833152995785f7ae0a2ae8b4cd7dac9ca0df22660f5b3678130d63304c05f7ec","contract":["NewSpanEndConfig returns default SpanConfig with zero timestamp and disabled stack trace when called with no options","NewSpanEndConfig applies WithTimestamp option to configure end timestamp","NewSpanEndConfig applies WithStackTrace option to configure stack trace capture","NewSpanEndConfig applies multiple SpanEndOption configurations concurrently","NewSpanEndConfig applies later SpanEndOption to overwrite earlier option value"],"goal":"verify go.opentelemetry.io/otel/trace.NewSpanEndConfig in pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/trace.NewSpanEndConfig"]},"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.24.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0","symbols":["go.opentelemetry.io/otel/trace.NewSpanEndConfig"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.22

require (
	go.opentelemetry.io/otel v1.24.0 // indirect
	go.opentelemetry.io/otel/trace v1.24.0
)
go.sum
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
main.go
package main

import (
	"context"
	"fmt"
	"time"

	"go.opentelemetry.io/otel/trace"
	"go.opentelemetry.io/otel/trace/noop"
)

func main() {
	tp := noop.NewTracerProvider()
	tracer := tp.Tracer("example.com/trace-sample")

	ctx := context.Background()
	ctx, span := tracer.Start(ctx, "example-operation")

	endTime := time.Now().UTC()
	endConfig := trace.NewSpanEndConfig(
		trace.WithTimestamp(endTime),
		trace.WithStackTrace(true),
	)

	fmt.Printf("Span end config: timestamp=%v, stackTrace=%v\n",
		endConfig.Timestamp(), endConfig.StackTrace())

	span.End(
		trace.WithTimestamp(endConfig.Timestamp()),
		trace.WithStackTrace(endConfig.StackTrace()),
	)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify go.opentelemetry.io/otel/trace.NewSpanEndConfig in pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/go.opentelemetry.io/otel/trace@v1.24.0"
  ],
  "symbols": [
    "go.opentelemetry.io/otel/trace.NewSpanEndConfig"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"
	"time"

	"go.opentelemetry.io/otel/trace"
)

func main() {
	// 1. NewSpanEndConfig returns default SpanConfig with zero timestamp and disabled stack trace when called with no options
	defaultCfg := trace.NewSpanEndConfig()
	if !defaultCfg.Timestamp().IsZero() {
		fmt.Fprintf(os.Stderr, "expected zero timestamp, got %v\n", defaultCfg.Timestamp())
		os.Exit(1)
	}
	if defaultCfg.StackTrace() {
		fmt.Fprintf(os.Stderr, "expected stackTrace false, got true\n")
		os.Exit(1)
	}

	// 2. NewSpanEndConfig applies WithTimestamp option to configure end timestamp
	expectedTime := time.Unix(1700000000, 123456789).UTC()
	timeCfg := trace.NewSpanEndConfig(trace.WithTimestamp(expectedTime))
	if !timeCfg.Timestamp().Equal(expectedTime) {
		fmt.Fprintf(os.Stderr, "expected timestamp %v, got %v\n", expectedTime, timeCfg.Timestamp())
		os.Exit(1)
	}

	// 3. NewSpanEndConfig applies WithStackTrace option to configure stack trace capture
	stackCfg := trace.NewSpanEndConfig(trace.WithStackTrace(true))
	if !stackCfg.StackTrace() {
		fmt.Fprintf(os.Stderr, "expected stackTrace true, got false\n")
		os.Exit(1)
	}

	// 4. NewSpanEndConfig applies multiple SpanEndOption configurations concurrently
	multiCfg := trace.NewSpanEndConfig(
		trace.WithTimestamp(expectedTime),
		trace.WithStackTrace(true),
	)
	if !multiCfg.Timestamp().Equal(expectedTime) {
		fmt.Fprintf(os.Stderr, "expected timestamp %v, got %v\n", expectedTime, multiCfg.Timestamp())
		os.Exit(1)
	}
	if !multiCfg.StackTrace() {
		fmt.Fprintf(os.Stderr, "expected stackTrace true, got false\n")
		os.Exit(1)
	}

	// 5. NewSpanEndConfig applies later SpanEndOption to overwrite earlier option value
	overwriteTime := expectedTime.Add(5 * time.Second)
	overwrittenCfg := trace.NewSpanEndConfig(
		trace.WithTimestamp(expectedTime),
		trace.WithTimestamp(overwriteTime),
		trace.WithStackTrace(true),
		trace.WithStackTrace(false),
	)
	if !overwrittenCfg.Timestamp().Equal(overwriteTime) {
		fmt.Fprintf(os.Stderr, "expected overwritten timestamp %v, got %v\n", overwriteTime, overwrittenCfg.Timestamp())
		os.Exit(1)
	}
	if overwrittenCfg.StackTrace() {
		fmt.Fprintf(os.Stderr, "expected overwritten stackTrace false, got true\n")
		os.Exit(1)
	}

	fmt.Println("All contract assertions passed successfully.")
}

Origin Seeder

anonymous