샘플
go.opentelemetry.io/otel/trace v1.37.0: EventOption
검증된 샘플 — golang go.opentelemetry.io/otel/trace v1.37.0: EventOption. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:8b9fc38c5ffac1f0a6c90c596f3d55eb5d1bb0f867299ae74c92b49f116b4f0b
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-19 |
케이스
HOW- 목표
- verify go.opentelemetry.io/otel/trace.EventOption in pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0
- 심벌
-
- go.opentelemetry.io/otel/trace.EventOption
- 생성일
- 2026-09-17T22:02:31Z
컨트랙트
- NewEventConfig without options assigns a non-zero call timestamp, empty attributes, and false stack trace flag
- WithAttributes option applies attributes to EventConfig and multiple calls append in order without overwriting
- WithTimestamp option sets explicit timestamp on EventConfig
- WithStackTrace option sets stack trace capture flag on EventConfig
- Span AddEvent and RecordError accept EventOption options including WithAttributes, WithTimestamp, and WithStackTrace
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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.EventOption in pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/otel/trace.EventOption
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:10f7465a36273e1ccdbf13f84822580efc2116acb73bc7b22b0efe863c4dcfca","contract":["NewEventConfig without options assigns a non-zero call timestamp, empty attributes, and false stack trace flag","WithAttributes option applies attributes to EventConfig and multiple calls append in order without overwriting","WithTimestamp option sets explicit timestamp on EventConfig","WithStackTrace option sets stack trace capture flag on EventConfig","Span AddEvent and RecordError accept EventOption options including WithAttributes, WithTimestamp, and WithStackTrace"],"goal":"verify go.opentelemetry.io/otel/trace.EventOption in pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/trace.EventOption"]},"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.37.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0","symbols":["go.opentelemetry.io/otel/trace.EventOption"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require (
go.opentelemetry.io/otel v1.37.0
go.opentelemetry.io/otel/trace v1.37.0
)
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.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I=
go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package main
import (
"context"
"fmt"
"time"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
func main() {
tp := trace.NewNoopTracerProvider()
tracer := tp.Tracer("event-sample")
_, span := tracer.Start(context.Background(), "sample-operation")
defer span.End()
eventTime := time.Now()
span.AddEvent("cache_lookup",
trace.WithTimestamp(eventTime),
trace.WithAttributes(
attribute.String("cache.key", "user:123"),
attribute.Bool("cache.hit", false),
),
)
sampleErr := fmt.Errorf("simulated failure")
span.RecordError(sampleErr,
trace.WithStackTrace(true),
trace.WithTimestamp(time.Now()),
trace.WithAttributes(attribute.String("error.severity", "warning")),
)
opts := []trace.EventOption{
trace.WithTimestamp(eventTime),
trace.WithAttributes(attribute.String("status", "ready")),
trace.WithStackTrace(false),
}
cfg := trace.NewEventConfig(opts...)
fmt.Printf("EventConfig timestamp: %v, stackTrace: %v, attributes: %d\n",
cfg.Timestamp(), cfg.StackTrace(), len(cfg.Attributes()))
}
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/otel/trace.EventOption in pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel/trace@v1.37.0"
],
"symbols": [
"go.opentelemetry.io/otel/trace.EventOption"
]
}
package main
import (
"context"
"fmt"
"os"
"time"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
func main() {
// Assertion 1: NewEventConfig without options assigns a non-zero call timestamp, empty attributes, and false stack trace flag
{
cfg := trace.NewEventConfig()
if cfg.Timestamp().IsZero() {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected non-zero timestamp\n")
os.Exit(1)
}
if len(cfg.Attributes()) != 0 {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected 0 attributes, got %d\n", len(cfg.Attributes()))
os.Exit(1)
}
if cfg.StackTrace() {
fmt.Fprintf(os.Stderr, "assertion 1 failed: expected stackTrace to be false\n")
os.Exit(1)
}
}
// Assertion 2: WithAttributes option applies attributes to EventConfig and multiple calls append in order without overwriting
{
attr1 := attribute.String("env", "production")
attr2 := attribute.Int("code", 200)
attr3 := attribute.Bool("retryable", false)
cfg := trace.NewEventConfig(
trace.WithAttributes(attr1, attr2),
trace.WithAttributes(attr3),
)
attrs := cfg.Attributes()
if len(attrs) != 3 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected 3 attributes, got %d\n", len(attrs))
os.Exit(1)
}
if attrs[0] != attr1 || attrs[1] != attr2 || attrs[2] != attr3 {
fmt.Fprintf(os.Stderr, "assertion 2 failed: attributes mismatch: %+v\n", attrs)
os.Exit(1)
}
}
// Assertion 3: WithTimestamp option sets explicit timestamp on EventConfig
{
t1 := time.Date(2026, time.September, 17, 10, 0, 0, 0, time.UTC)
t2 := time.Date(2026, time.September, 17, 10, 5, 0, 0, time.UTC)
cfg1 := trace.NewEventConfig(trace.WithTimestamp(t1))
if !cfg1.Timestamp().Equal(t1) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected %v, got %v\n", t1, cfg1.Timestamp())
os.Exit(1)
}
// Multiple calls overwrite with last-one-wins
cfg2 := trace.NewEventConfig(trace.WithTimestamp(t1), trace.WithTimestamp(t2))
if !cfg2.Timestamp().Equal(t2) {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected last timestamp %v, got %v\n", t2, cfg2.Timestamp())
os.Exit(1)
}
}
// Assertion 4: WithStackTrace option sets stack trace capture flag on EventConfig
{
cfgFalse := trace.NewEventConfig(trace.WithStackTrace(false))
if cfgFalse.StackTrace() {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected stackTrace false\n")
os.Exit(1)
}
cfgTrue := trace.NewEventConfig(trace.WithStackTrace(true))
if !cfgTrue.StackTrace() {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected stackTrace true\n")
os.Exit(1)
}
// Multiple calls overwrite with last-one-wins
cfgOverride := trace.NewEventConfig(trace.WithStackTrace(true), trace.WithStackTrace(false))
if cfgOverride.StackTrace() {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected stackTrace false after overwrite\n")
os.Exit(1)
}
}
// Assertion 5: Span AddEvent and RecordError accept EventOption options including WithAttributes, WithTimestamp, and WithStackTrace
{
tp := trace.NewNoopTracerProvider()
tracer := tp.Tracer("contract-tracer")
_, span := tracer.Start(context.Background(), "test-span")
defer span.End()
eventTime := time.Date(2026, time.September, 17, 11, 0, 0, 0, time.UTC)
eventOpts := []trace.EventOption{
trace.WithTimestamp(eventTime),
trace.WithAttributes(attribute.String("event.name", "checkpoint")),
}
span.AddEvent("checkpoint", eventOpts...)
errOpts := []trace.EventOption{
trace.WithTimestamp(eventTime),
trace.WithStackTrace(true),
trace.WithAttributes(attribute.String("error.type", "test_error")),
}
span.RecordError(fmt.Errorf("simulated contract error"), errOpts...)
}
fmt.Println("All EventOption contract assertions passed successfully.")
}
오리진 시더
익명