Sample
go.opentelemetry.io/proto/otlp v1.7.1
Verified sample for golang go.opentelemetry.io/proto/otlp v1.7.1. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:fab3735a7c2e588b6bdd1f6756e0805b0be3cc2d625f0e7b53bebed326c71077
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-14 |
Case
HOW- Goal
- verify pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1
- Created
- 2026-09-14T16:53:50Z
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.
- Resource encapsulates key-value attributes and dropped attributes count with typed field getters.
- Resource serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal.
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
Source
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 pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1
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:2fefb1501ba1e6b7acdd440ce5449ef58e3a2e258af476e4d07a7152c7efceb3","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.","Resource encapsulates key-value attributes and dropped attributes count with typed field getters.","Resource serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal."],"goal":"verify pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1"],"schemaVersion":1},"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.7.1"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1","verifierAdapter":"golang@1"}
module example.com/otlpverification
go 1.26.6
require (
go.opentelemetry.io/proto/otlp v1.7.1
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.7.1 h1:gTOMpGDb0WTBOP8JaO72iL3auEZhVmAQg4ipjOVAtj4=
go.opentelemetry.io/proto/otlp v1.7.1/go.mod h1:b2rVh6rfI/s2pHWNlB7ILJcRALpcNDzKhACevjI+ZnE=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
package main
import (
"fmt"
"log"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
resourcepb "go.opentelemetry.io/proto/otlp/resource/v1"
"google.golang.org/protobuf/proto"
)
func main() {
scope := &commonpb.InstrumentationScope{
Name: "example.com/otlp-sample",
Version: "1.0.0",
Attributes: []*commonpb.KeyValue{
{
Key: "service.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "sample-service"},
},
},
},
}
res := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "host.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "localhost"},
},
},
},
}
fmt.Printf("InstrumentationScope: %s v%s\n", scope.GetName(), scope.GetVersion())
fmt.Printf("Resource attributes: %d\n", len(res.GetAttributes()))
wire, err := proto.Marshal(scope)
if err != nil {
log.Fatalf("Marshal failed: %v", err)
}
fmt.Printf("Marshaled scope to %d bytes\n", len(wire))
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1"
]
}
package main
import (
"bytes"
"fmt"
"os"
commonpb "go.opentelemetry.io/proto/otlp/common/v1"
resourcepb "go.opentelemetry.io/proto/otlp/resource/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")
}
// Assertion 6: Resource encapsulates key-value attributes and dropped attributes count with typed field getters.
{
res := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "service.instance.id",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "i-0123456789abcdef0"},
},
},
},
DroppedAttributesCount: 0,
}
assert(len(res.GetAttributes()) == 1, "expected 1 resource attribute")
assert(res.GetAttributes()[0].GetKey() == "service.instance.id", "expected attribute key 'service.instance.id'")
assert(res.GetAttributes()[0].GetValue().GetStringValue() == "i-0123456789abcdef0", "expected attribute value")
assert(res.GetDroppedAttributesCount() == 0, "expected DroppedAttributesCount 0")
}
// Assertion 7: Resource serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal.
{
orig := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "k8s.pod.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "backend-pod-xyz"},
},
},
},
DroppedAttributesCount: 3,
}
wire, err := proto.Marshal(orig)
assert(err == nil, "proto.Marshal resource failed")
assert(len(wire) > 0, "marshaled wire length is 0")
unmarshaled := &resourcepb.Resource{}
err = proto.Unmarshal(wire, unmarshaled)
assert(err == nil, "proto.Unmarshal resource failed")
assert(proto.Equal(orig, unmarshaled), "proto.Equal returned false for resource protobuf round-trip")
}
fmt.Println("All contract assertions passed.")
}
Origin Seeder
anonymous