Ejemplo
go.opentelemetry.io/otel/log v0.19.0: WithInstrumentationAttributes
Muestra verificada para golang go.opentelemetry.io/otel/log v0.19.0: WithInstrumentationAttributes. El contrato se ejecutó en go 1.26 · linux debian/x64 …
sha256:83069a6b783a2050c0a35d13a202bfe6fca45cba42a5da837bf4b834a2289bea
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 go
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-01 |
Caso
HOW- Objetivo
- verify go.opentelemetry.io/otel/log.WithInstrumentationAttributes in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0
- Paquetes
- Símbolos
-
- go.opentelemetry.io/otel/log.WithInstrumentationAttributes
- Creado
- 2026-09-01T05:44:51Z
Contrato
- WithInstrumentationAttributes configures instrumentation scope attributes in LoggerConfig
- WithInstrumentationAttributes handles multiple attribute options by merging attributes
- WithInstrumentationAttributes deduplicates duplicate keys with last-write wins
- ScopedLogger retains instrumentation attributes alongside scope name and version
Archivos
- PROMPT.md
- attributes.go
- csx.json
- go.mod
- go.sum
- spec.json
- test/contract.go
Código fuente
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/log.WithInstrumentationAttributes in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel/log@v0.19.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/otel/log.WithInstrumentationAttributes
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.
package sample
import (
"context"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/log/embedded"
)
// ScopedLogger represents a logger configured with scope attributes.
type ScopedLogger struct {
embedded.Logger
name string
config log.LoggerConfig
}
// NewScopedLogger initializes a ScopedLogger with the given scope name and options.
func NewScopedLogger(name string, opts ...log.LoggerOption) *ScopedLogger {
cfg := log.NewLoggerConfig(opts...)
return &ScopedLogger{
name: name,
config: cfg,
}
}
// Name returns the scope name.
func (l *ScopedLogger) Name() string {
return l.name
}
// Config returns the resolved LoggerConfig.
func (l *ScopedLogger) Config() log.LoggerConfig {
return l.config
}
// ScopeAttributes returns the configured instrumentation attributes.
func (l *ScopedLogger) ScopeAttributes() attribute.Set {
return l.config.InstrumentationAttributes()
}
// Emit implements log.Logger interface.
func (l *ScopedLogger) Emit(ctx context.Context, record log.Record) {}
// Enabled implements log.Logger interface.
func (l *ScopedLogger) Enabled(ctx context.Context, param log.EnabledParameters) bool {
return true
}
{"case":{"caseId":"case:sha256:13420ad3cda805089ae66c99ed1b9b43c2ecf2209b0fe9b56b0727308cae6e4b","contract":["WithInstrumentationAttributes configures instrumentation scope attributes in LoggerConfig","WithInstrumentationAttributes handles multiple attribute options by merging attributes","WithInstrumentationAttributes deduplicates duplicate keys with last-write wins","ScopedLogger retains instrumentation attributes alongside scope name and version"],"goal":"verify go.opentelemetry.io/otel/log.WithInstrumentationAttributes in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/log@v0.19.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/log.WithInstrumentationAttributes"]},"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/log@v0.19.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/log@v0.19.0","symbols":["go.opentelemetry.io/otel/log.WithInstrumentationAttributes"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require (
go.opentelemetry.io/otel v1.43.0
go.opentelemetry.io/otel/log v0.19.0
)
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.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=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
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/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE=
go.opentelemetry.io/otel/log v0.19.0 h1:KUZs/GOsw79TBBMfDWsXS+KZ4g2Ckzksd1ymzsIEbo4=
go.opentelemetry.io/otel/log v0.19.0/go.mod h1:5DQYeGmxVIr4n0/BcJvF4upsraHjg6vudJJpnkL6Ipk=
go.opentelemetry.io/otel/log v0.22.0 h1:5DBNnfvaJ6CVdkJ+Jle8Tzs50aSSv49TXGj9XRsEYw0=
go.opentelemetry.io/otel/log v0.22.0/go.mod h1:gzOt/R67vF2GniAqWu8Qv0SXy89f71muHcrkz76PCdc=
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/otel/log.WithInstrumentationAttributes in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel/log@v0.19.0"
],
"symbols": [
"go.opentelemetry.io/otel/log.WithInstrumentationAttributes"
]
}
package main
import (
"fmt"
"os"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
"sample"
)
func main() {
// 1. WithInstrumentationAttributes configures instrumentation scope attributes in LoggerConfig
cfg1 := log.NewLoggerConfig(
log.WithInstrumentationAttributes(
attribute.String("service.name", "auth-service"),
attribute.Int64("service.port", 8080),
),
)
attrs1 := cfg1.InstrumentationAttributes()
if attrs1.Len() != 2 {
fmt.Fprintf(os.Stderr, "expected 2 attributes, got %d\n", attrs1.Len())
os.Exit(1)
}
v1, ok1 := attrs1.Value("service.name")
if !ok1 || v1.AsString() != "auth-service" {
fmt.Fprintf(os.Stderr, "expected service.name to be 'auth-service', got %v\n", v1)
os.Exit(1)
}
v2, ok2 := attrs1.Value("service.port")
if !ok2 || v2.AsInt64() != 8080 {
fmt.Fprintf(os.Stderr, "expected service.port to be 8080, got %v\n", v2)
os.Exit(1)
}
// 2. WithInstrumentationAttributes handles multiple attribute options by merging attributes
cfg2 := log.NewLoggerConfig(
log.WithInstrumentationAttributes(attribute.String("env", "production")),
log.WithInstrumentationAttributes(attribute.String("region", "us-east-1")),
)
attrs2 := cfg2.InstrumentationAttributes()
if attrs2.Len() != 2 {
fmt.Fprintf(os.Stderr, "expected 2 attributes after multiple options, got %d\n", attrs2.Len())
os.Exit(1)
}
envVal, ok := attrs2.Value("env")
if !ok || envVal.AsString() != "production" {
fmt.Fprintf(os.Stderr, "expected env to be 'production', got %v\n", envVal)
os.Exit(1)
}
regionVal, ok := attrs2.Value("region")
if !ok || regionVal.AsString() != "us-east-1" {
fmt.Fprintf(os.Stderr, "expected region to be 'us-east-1', got %v\n", regionVal)
os.Exit(1)
}
// 3. WithInstrumentationAttributes deduplicates duplicate keys with last-write wins
cfg3 := log.NewLoggerConfig(
log.WithInstrumentationAttributes(attribute.String("version", "v1.0")),
log.WithInstrumentationAttributes(attribute.String("version", "v2.0")),
)
attrs3 := cfg3.InstrumentationAttributes()
if attrs3.Len() != 1 {
fmt.Fprintf(os.Stderr, "expected 1 deduplicated attribute, got %d\n", attrs3.Len())
os.Exit(1)
}
verVal, ok := attrs3.Value("version")
if !ok || verVal.AsString() != "v2.0" {
fmt.Fprintf(os.Stderr, "expected deduplicated version 'v2.0', got %v\n", verVal)
os.Exit(1)
}
// 4. ScopedLogger retains instrumentation attributes alongside scope name and version
logger := sample.NewScopedLogger(
"example.com/payment",
log.WithInstrumentationVersion("1.2.0"),
log.WithSchemaURL("https://opentelemetry.io/schemas/1.24.0"),
log.WithInstrumentationAttributes(
attribute.String("component", "checkout"),
attribute.Bool("experimental", true),
),
)
if logger.Name() != "example.com/payment" {
fmt.Fprintf(os.Stderr, "expected logger name 'example.com/payment', got %q\n", logger.Name())
os.Exit(1)
}
if logger.Config().InstrumentationVersion() != "1.2.0" {
fmt.Fprintf(os.Stderr, "expected version '1.2.0', got %q\n", logger.Config().InstrumentationVersion())
os.Exit(1)
}
if logger.Config().SchemaURL() != "https://opentelemetry.io/schemas/1.24.0" {
fmt.Fprintf(os.Stderr, "expected schema URL 'https://opentelemetry.io/schemas/1.24.0', got %q\n", logger.Config().SchemaURL())
os.Exit(1)
}
loggerAttrs := logger.ScopeAttributes()
if loggerAttrs.Len() != 2 {
fmt.Fprintf(os.Stderr, "expected 2 logger attributes, got %d\n", loggerAttrs.Len())
os.Exit(1)
}
compVal, ok := loggerAttrs.Value("component")
if !ok || compVal.AsString() != "checkout" {
fmt.Fprintf(os.Stderr, "expected component 'checkout', got %v\n", compVal)
os.Exit(1)
}
expVal, ok := loggerAttrs.Value("experimental")
if !ok || !expVal.AsBool() {
fmt.Fprintf(os.Stderr, "expected experimental true, got %v\n", expVal)
os.Exit(1)
}
}
Seeder de origen
anónimo