Sample
go.opentelemetry.io/proto/otlp v1.9.0: v1.Resource
Verified sample for golang go.opentelemetry.io/proto/otlp v1.9.0: v1.Resource. The contract ran on go 1.26 · linux debian/x64 · docker and passed.
sha256:184e0b5b37634736dd026ca27806fe4da9513c13af333323087e0fed00aba2ac
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-05 |
Case
HOW- Goal
- verify go.opentelemetry.io/proto/otlp/resource/v1.Resource in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
- Symbols
-
- go.opentelemetry.io/proto/otlp/resource/v1.Resource
- Created
- 2026-09-05T15:37:00Z
Contract
- Resource encapsulates key-value attributes, dropped attributes count, and entity references with typed field getters.
- Resource getters safely handle nil receiver instances and unpopulated messages by returning default zero values without panicking.
- Resource serializes to and deserializes from standard binary Protobuf wire format without data loss, satisfying proto.Equal.
- Resource serializes to and deserializes from protojson format, preserving camelCase field names and attribute structures.
- proto.Clone creates an isolated deep copy of Resource where mutating attributes on the clone does not modify the original.
- Resource.Reset clears all fields restoring the message to its empty zero state.
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/main.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 go.opentelemetry.io/proto/otlp/resource/v1.Resource 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/resource/v1.Resource
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:114476be4f3f15e14f4366a17206d0db79b60835459deb9aa45f4a7ff5234384","contract":["Resource encapsulates key-value attributes, dropped attributes count, and entity references with typed field getters.","Resource getters safely handle nil receiver instances and unpopulated messages by returning default zero values without panicking.","Resource serializes to and deserializes from standard binary Protobuf wire format without data loss, satisfying proto.Equal.","Resource serializes to and deserializes from protojson format, preserving camelCase field names and attribute structures.","proto.Clone creates an isolated deep copy of Resource where mutating attributes on the clone does not modify the original.","Resource.Reset clears all fields restoring the message to its empty zero state."],"goal":"verify go.opentelemetry.io/proto/otlp/resource/v1.Resource 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/resource/v1.Resource"]},"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/resource/v1.Resource"],"verifierAdapter":"golang@1"}
module example.com/otlpresource
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/resource/v1.Resource 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/resource/v1.Resource"
]
}
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: Resource encapsulates key-value attributes, dropped attributes count, and entity references with typed field getters
{
attr1 := &commonpb.KeyValue{
Key: "service.name",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "order-processor"},
},
}
attr2 := &commonpb.KeyValue{
Key: "service.version",
Value: &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "1.2.3"},
},
}
res := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{attr1, attr2},
DroppedAttributesCount: 4,
}
attrs := res.GetAttributes()
assert(len(attrs) == 2, "expected 2 attributes")
assert(attrs[0].GetKey() == "service.name", "expected key 'service.name'")
assert(attrs[0].GetValue().GetStringValue() == "order-processor", "expected value 'order-processor'")
assert(attrs[1].GetKey() == "service.version", "expected key 'service.version'")
assert(attrs[1].GetValue().GetStringValue() == "1.2.3", "expected value '1.2.3'")
assert(res.GetDroppedAttributesCount() == 4, "expected dropped attributes count 4")
assert(res.GetEntityRefs() == nil, "expected nil entity refs when omitted")
}
// Assertion 2: Resource getters safely handle nil receiver instances and unpopulated messages by returning default zero values without panicking
{
var nilRes *resourcepb.Resource
assert(nilRes.GetAttributes() == nil, "nil Resource GetAttributes must return nil")
assert(nilRes.GetDroppedAttributesCount() == 0, "nil Resource GetDroppedAttributesCount must return 0")
assert(nilRes.GetEntityRefs() == nil, "nil Resource GetEntityRefs must return nil")
emptyRes := &resourcepb.Resource{}
assert(emptyRes.GetAttributes() == nil, "empty Resource GetAttributes must return nil")
assert(emptyRes.GetDroppedAttributesCount() == 0, "empty Resource GetDroppedAttributesCount must return 0")
assert(emptyRes.GetEntityRefs() == nil, "empty Resource GetEntityRefs must return nil")
}
// Assertion 3: Resource serializes to and deserializes from standard binary Protobuf wire format without data loss, satisfying proto.Equal
{
orig := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "host.id",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "node-42"}},
},
{
Key: "host.arch",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "amd64"}},
},
},
DroppedAttributesCount: 2,
}
wire, err := proto.Marshal(orig)
assert(err == nil, "proto.Marshal failed")
assert(len(wire) > 0, "marshaled wire length must be > 0")
unmarshaled := &resourcepb.Resource{}
err = proto.Unmarshal(wire, unmarshaled)
assert(err == nil, "proto.Unmarshal failed")
assert(proto.Equal(orig, unmarshaled), "proto.Equal failed after wire round-trip")
assert(unmarshaled.GetDroppedAttributesCount() == 2, "unmarshaled dropped attributes count mismatch")
assert(len(unmarshaled.GetAttributes()) == 2, "unmarshaled attributes length mismatch")
}
// Assertion 4: Resource serializes to and deserializes from protojson format, preserving camelCase field names and attribute structures
{
orig := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "cloud.provider",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "gcp"}},
},
},
DroppedAttributesCount: 1,
}
jsonBytes, err := protojson.Marshal(orig)
assert(err == nil, "protojson.Marshal failed")
assert(bytes.Contains(jsonBytes, []byte(`"droppedAttributesCount":1`)), "json must contain 'droppedAttributesCount':1")
assert(bytes.Contains(jsonBytes, []byte(`"attributes"`)), "json must contain 'attributes'")
assert(bytes.Contains(jsonBytes, []byte(`"cloud.provider"`)), "json must contain 'cloud.provider'")
jsonUnmarshaled := &resourcepb.Resource{}
err = protojson.Unmarshal(jsonBytes, jsonUnmarshaled)
assert(err == nil, "protojson.Unmarshal failed")
assert(proto.Equal(orig, jsonUnmarshaled), "proto.Equal failed after protojson round-trip")
}
// Assertion 5: proto.Clone creates an isolated deep copy of Resource where mutating attributes on the clone does not modify the original
{
orig := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "region",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "us-central1"}},
},
},
DroppedAttributesCount: 5,
}
cloned := proto.Clone(orig).(*resourcepb.Resource)
assert(proto.Equal(orig, cloned), "cloned Resource must equal original")
cloned.DroppedAttributesCount = 10
cloned.Attributes[0].Key = "mutated-key"
cloned.Attributes = append(cloned.Attributes, &commonpb.KeyValue{
Key: "new.key",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "new.value"}},
})
assert(orig.GetDroppedAttributesCount() == 5, "original DroppedAttributesCount mutated")
assert(len(orig.GetAttributes()) == 1, "original Attributes length mutated")
assert(orig.GetAttributes()[0].GetKey() == "region", "original attribute key mutated")
}
// Assertion 6: Resource.Reset clears all fields restoring the message to its empty zero state
{
res := &resourcepb.Resource{
Attributes: []*commonpb.KeyValue{
{
Key: "k",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "v"}},
},
},
DroppedAttributesCount: 3,
}
res.Reset()
assert(res.GetDroppedAttributesCount() == 0, "Reset did not clear DroppedAttributesCount")
assert(len(res.GetAttributes()) == 0, "Reset did not clear Attributes")
assert(proto.Equal(res, &resourcepb.Resource{}), "Reset did not restore to empty Resource")
}
fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/resource/v1.Resource contract assertions verified")
}
Origin Seeder
anonymous