Beispiel
go.opentelemetry.io/otel v1.37.0: attribute.Int
Verifiziertes Beispiel für golang go.opentelemetry.io/otel v1.37.0: attribute.Int. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker und bestand.
sha256:41a0ce718f9eb1a90ecb967f987c9038c6e332f007ece7e453aa78beb53ba938
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 go
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-16 |
Fall
HOW- Ziel
- verify go.opentelemetry.io/otel/attribute.Int in pkg:golang/go.opentelemetry.io/otel@v1.37.0
- Symbole
-
- go.opentelemetry.io/otel/attribute.Int
- Erstellt
- 2026-09-16T16:28:36Z
Contract
- attribute.Int constructs a KeyValue with specified Key and INT64 Value type
- attribute.Int with positive, zero, or negative integer values preserves the int64 representation
- attribute.IntValue creates an INT64 Value type emitting the integer string representation
- attribute.Int with empty key produces a KeyValue where key.Defined() and Valid() are false
- attribute.IntSlice constructs an INT64SLICE Value type containing converted int64 slice elements
- attribute.NewSet with attribute.Int KeyValues allows key lookup and value retrieval via HasValue and Value
Dateien
- NOTES.md
- PROMPT.md
- attribute_int_test.go
- csx.json
- go.mod
- go.sum
- spec.json
Quelltext
# go.opentelemetry.io/otel - attribute.Int
## Search Result
`search_known_solution` answered `COMPATIBLE` for `go.opentelemetry.io/otel` and symbol `go.opentelemetry.io/otel/attribute.Int` (adapted and verified against v1.37.0).
## Release Pinned
- Package: `go.opentelemetry.io/otel`
- Version: `v1.37.0`
## Observed Behaviour
`attribute.Int` is a constructor in `go.opentelemetry.io/otel/attribute` that returns a `KeyValue` pairing a string key with an integer value represented as `INT64`:
1. **Type & Value Representation**:
- `attribute.Int(k, v)` constructs a `KeyValue` where `kv.Key == attribute.Key(k)` and `kv.Value.Type() == attribute.INT64`.
- The underlying integer value is cast to `int64` and retrieved via `kv.Value.AsInt64()`.
- `attribute.IntValue(v)` returns a standalone `Value` of type `INT64` with string representation emitted via `.Emit()`.
2. **Validation**:
- For valid non-empty keys, `kv.Valid()` returns `true` and `kv.Key.Defined()` returns `true`.
- When given an empty key `""`, `kv.Key.Defined()` returns `false` and `kv.Valid()` returns `false`.
3. **Collections & Set Membership**:
- `attribute.IntSlice(k, []int{...})` creates an `INT64SLICE` KeyValue with `AsInt64Slice()`.
- `attribute.NewSet(...)` accepts `attribute.Int` KeyValues and supports membership querying via `set.HasValue(key)` and retrieval via `set.Value(key)`.
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/attribute.Int in pkg:golang/go.opentelemetry.io/otel@v1.37.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel@v1.37.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/otel/attribute.Int
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 (
"reflect"
"testing"
"go.opentelemetry.io/otel/attribute"
)
func TestAttributeInt(t *testing.T) {
// 1. attribute.Int constructs a KeyValue with INT64 Value type and expected int64 value
statusCodeKV := attribute.Int("http.status_code", 200)
if statusCodeKV.Key != attribute.Key("http.status_code") {
t.Fatalf("expected Key to be 'http.status_code', got %q", statusCodeKV.Key)
}
if statusCodeKV.Value.Type() != attribute.INT64 {
t.Fatalf("expected Value.Type() to be INT64, got %v", statusCodeKV.Value.Type())
}
if statusCodeKV.Value.AsInt64() != 200 {
t.Fatalf("expected Value.AsInt64() to be 200, got %d", statusCodeKV.Value.AsInt64())
}
if !statusCodeKV.Valid() {
t.Fatalf("expected statusCodeKV.Valid() to be true")
}
// 2. Negative and zero int values are preserved as INT64
zeroKV := attribute.Int("counter.zero", 0)
if zeroKV.Value.AsInt64() != 0 {
t.Fatalf("expected 0, got %d", zeroKV.Value.AsInt64())
}
negKV := attribute.Int("offset", -15)
if negKV.Value.AsInt64() != -15 {
t.Fatalf("expected -15, got %d", negKV.Value.AsInt64())
}
// 3. attribute.IntValue creates a standalone Value with INT64 type
intValue := attribute.IntValue(42)
if intValue.Type() != attribute.INT64 {
t.Fatalf("expected intValue.Type() to be INT64, got %v", intValue.Type())
}
if intValue.AsInt64() != 42 {
t.Fatalf("expected intValue.AsInt64() to be 42, got %d", intValue.AsInt64())
}
if intValue.Emit() != "42" {
t.Fatalf("expected intValue.Emit() to be '42', got %q", intValue.Emit())
}
// 4. attribute.Int with empty key produces an invalid KeyValue
emptyKeyKV := attribute.Int("", 500)
if emptyKeyKV.Key.Defined() {
t.Fatalf("expected empty key Defined() to be false")
}
if emptyKeyKV.Valid() {
t.Fatalf("expected empty key KeyValue.Valid() to be false")
}
// 5. attribute.IntSlice converts []int into INT64SLICE Value type
sliceKV := attribute.IntSlice("retry.delays", []int{10, 20, 30})
if sliceKV.Value.Type() != attribute.INT64SLICE {
t.Fatalf("expected sliceKV.Value.Type() to be INT64SLICE, got %v", sliceKV.Value.Type())
}
expectedSlice := []int64{10, 20, 30}
if !reflect.DeepEqual(sliceKV.Value.AsInt64Slice(), expectedSlice) {
t.Fatalf("expected %v, got %v", expectedSlice, sliceKV.Value.AsInt64Slice())
}
// 6. attribute.NewSet integration with attribute.Int KeyValues
set := attribute.NewSet(
statusCodeKV,
attribute.Int("retry.attempts", 3),
)
if !set.HasValue(attribute.Key("http.status_code")) {
t.Fatalf("expected set to have 'http.status_code'")
}
if val, ok := set.Value(attribute.Key("http.status_code")); !ok || val.AsInt64() != 200 {
t.Fatalf("expected set.Value('http.status_code') to be 200, got %v (ok=%v)", val.AsInt64(), ok)
}
if val, ok := set.Value(attribute.Key("retry.attempts")); !ok || val.AsInt64() != 3 {
t.Fatalf("expected set.Value('retry.attempts') to be 3, got %v (ok=%v)", val.AsInt64(), ok)
}
if set.HasValue(attribute.Key("nonexistent")) {
t.Fatalf("expected set.HasValue('nonexistent') to be false")
}
}
{"case":{"caseId":"case:sha256:9d048f0da66cdfc500178459fa11dfc2940401b5ab9ee101c91f2b0d888ec53c","contract":["attribute.Int constructs a KeyValue with specified Key and INT64 Value type","attribute.Int with positive, zero, or negative integer values preserves the int64 representation","attribute.IntValue creates an INT64 Value type emitting the integer string representation","attribute.Int with empty key produces a KeyValue where key.Defined() and Valid() are false","attribute.IntSlice constructs an INT64SLICE Value type containing converted int64 slice elements","attribute.NewSet with attribute.Int KeyValues allows key lookup and value retrieval via HasValue and Value"],"goal":"verify go.opentelemetry.io/otel/attribute.Int in pkg:golang/go.opentelemetry.io/otel@v1.37.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel@v1.37.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/attribute.Int"]},"contractCommand":["go","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@v1.37.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel@v1.37.0","symbols":["go.opentelemetry.io/otel/attribute.Int"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.23.0
require go.opentelemetry.io/otel 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=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/otel/attribute.Int in pkg:golang/go.opentelemetry.io/otel@v1.37.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel@v1.37.0"
],
"symbols": [
"go.opentelemetry.io/otel/attribute.Int"
]
}
Ursprungs-Seeder
anonym