Beispiel
go.opentelemetry.io/proto/otlp v1.9.0: v1.InstrumentationScope
Verifiziertes Beispiel für golang go.opentelemetry.io/proto/otlp v1.9.0: v1.InstrumentationScope. Der Vertrag lief auf go 1.26 · linux debian/x64 · docker…
sha256:017bb59756b43854c3d161a645e8a79f64428939697419260f9effd2404afc8a
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-05 |
Fall
HOW- Ziel
- verify go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
- Symbole
-
- go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope
- Erstellt
- 2026-09-05T15:05:49Z
Contract
- InstrumentationScope stores name, version, attributes, and dropped attributes count.
- InstrumentationScope getters safely handle nil receivers and unpopulated instances without panic, returning zero values.
- InstrumentationScope serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal.
- InstrumentationScope serializes to and deserializes from protojson format, preserving field names and nested attributes.
- proto.Clone produces an isolated deep copy of InstrumentationScope where mutating attributes does not affect the original.
Dateien
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/main.go
Quelltext
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/proto/otlp/common/v1.InstrumentationScope in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope
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:cb7b88942b3013c3d8500cfdc1702ea04afd800efbcc40af28542c7bb2a672b1","contract":["InstrumentationScope stores name, version, attributes, and dropped attributes count.","InstrumentationScope getters safely handle nil receivers and unpopulated instances without panic, returning zero values.","InstrumentationScope serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal.","InstrumentationScope serializes to and deserializes from protojson format, preserving field names and nested attributes.","proto.Clone produces an isolated deep copy of InstrumentationScope where mutating attributes does not affect the original."],"goal":"verify go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope"]},"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/proto/otlp@v1.9.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0","symbols":["go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope"],"verifierAdapter":"golang@1"}
module example.com/otlpinstrumentationscope
go 1.26.6
require (
go.opentelemetry.io/proto/otlp v1.9.0
google.golang.org/protobuf v1.36.12
)
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0"
],
"symbols": [
"go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope"
]
}
package main
import (
"bytes"
"fmt"
"os"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
func assert(condition bool, message string) {
if !condition {
fmt.Fprintf(os.Stderr, "assertion failed: %s\n", message)
os.Exit(1)
}
}
func main() {
// Assertion 1: InstrumentationScope stores name, version, attributes, and dropped attributes count
{
scope := &commonpb.InstrumentationScope{
Name: "io.opentelemetry.example",
Version: "1.2.3",
Attributes: []*commonpb.KeyValue{
{
Key: "service.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "payment-service"},
},
},
{
Key: "library.language",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "go"},
},
},
},
DroppedAttributesCount: 2,
}
assert(scope.GetName() == "io.opentelemetry.example", "expected Name 'io.opentelemetry.example'")
assert(scope.GetVersion() == "1.2.3", "expected Version '1.2.3'")
assert(len(scope.GetAttributes()) == 2, "expected 2 attributes")
assert(scope.GetAttributes()[0].GetKey() == "service.name", "expected first attribute key 'service.name'")
assert(scope.GetAttributes()[0].GetValue().GetStringValue() == "payment-service", "expected first attribute value 'payment-service'")
assert(scope.GetAttributes()[1].GetKey() == "library.language", "expected second attribute key 'library.language'")
assert(scope.GetAttributes()[1].GetValue().GetStringValue() == "go", "expected second attribute value 'go'")
assert(scope.GetDroppedAttributesCount() == 2, "expected DroppedAttributesCount 2")
}
// Assertion 2: InstrumentationScope getters safely handle nil receivers and unpopulated instances without panic, returning zero values
{
var nilScope *commonpb.InstrumentationScope
assert(nilScope.GetName() == "", "nil InstrumentationScope GetName must return empty string")
assert(nilScope.GetVersion() == "", "nil InstrumentationScope GetVersion must return empty string")
assert(nilScope.GetAttributes() == nil, "nil InstrumentationScope GetAttributes must return nil")
assert(nilScope.GetDroppedAttributesCount() == 0, "nil InstrumentationScope GetDroppedAttributesCount must return 0")
emptyScope := &commonpb.InstrumentationScope{}
assert(emptyScope.GetName() == "", "empty InstrumentationScope GetName must return empty string")
assert(emptyScope.GetVersion() == "", "empty InstrumentationScope GetVersion must return empty string")
assert(emptyScope.GetAttributes() == nil, "empty InstrumentationScope GetAttributes must return nil")
assert(emptyScope.GetDroppedAttributesCount() == 0, "empty InstrumentationScope GetDroppedAttributesCount must return 0")
}
// Assertion 3: InstrumentationScope serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal
{
orig := &commonpb.InstrumentationScope{
Name: "net.http.client",
Version: "2.0.0",
Attributes: []*commonpb.KeyValue{
{
Key: "component",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "http"},
},
},
},
DroppedAttributesCount: 1,
}
wire, err := proto.Marshal(orig)
assert(err == nil, "proto.Marshal failed")
assert(len(wire) > 0, "marshaled wire length is 0")
unmarshaled := &commonpb.InstrumentationScope{}
err = proto.Unmarshal(wire, unmarshaled)
assert(err == nil, "proto.Unmarshal failed")
assert(proto.Equal(orig, unmarshaled), "proto.Equal returned false for protobuf round-trip")
}
// Assertion 4: InstrumentationScope serializes to and deserializes from protojson format, preserving field names and nested attributes
{
orig := &commonpb.InstrumentationScope{
Name: "database.sql",
Version: "0.5.1",
Attributes: []*commonpb.KeyValue{
{
Key: "db.system",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "postgresql"},
},
},
},
DroppedAttributesCount: 5,
}
jsonBytes, err := protojson.Marshal(orig)
assert(err == nil, "protojson.Marshal failed")
assert(bytes.Contains(jsonBytes, []byte(`"name"`)), "json must contain 'name'")
assert(bytes.Contains(jsonBytes, []byte(`"version"`)), "json must contain 'version'")
assert(bytes.Contains(jsonBytes, []byte(`"attributes"`)), "json must contain 'attributes'")
assert(bytes.Contains(jsonBytes, []byte(`"droppedAttributesCount"`)), "json must contain 'droppedAttributesCount'")
jsonUnmarshaled := &commonpb.InstrumentationScope{}
err = protojson.Unmarshal(jsonBytes, jsonUnmarshaled)
assert(err == nil, "protojson.Unmarshal failed")
assert(proto.Equal(orig, jsonUnmarshaled), "proto.Equal returned false for protojson round-trip")
}
// Assertion 5: proto.Clone produces an isolated deep copy of InstrumentationScope where mutating attributes does not affect the original
{
orig := &commonpb.InstrumentationScope{
Name: "cache.redis",
Version: "1.0.0",
Attributes: []*commonpb.KeyValue{
{
Key: "cache.type",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "redis"},
},
},
},
DroppedAttributesCount: 0,
}
cloned := proto.Clone(orig).(*commonpb.InstrumentationScope)
assert(proto.Equal(orig, cloned), "cloned InstrumentationScope must equal original")
cloned.Name = "cache.memcached"
cloned.Attributes[0].Key = "mutated.key"
cloned.DroppedAttributesCount = 10
assert(orig.GetName() == "cache.redis", "original Scope Name was mutated")
assert(orig.GetAttributes()[0].GetKey() == "cache.type", "original Scope Attribute Key was mutated")
assert(orig.GetDroppedAttributesCount() == 0, "original Scope DroppedAttributesCount was mutated")
assert(!proto.Equal(orig, cloned), "orig should not equal mutated clone")
}
fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/common/v1.InstrumentationScope contract assertions verified")
}
Ursprungs-Seeder
anonym