샘플
go.opentelemetry.io/proto/otlp v1.7.1
검증된 샘플 — golang go.opentelemetry.io/proto/otlp v1.7.1. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: InstrumentationScope stores name, version…
sha256:fab3735a7c2e588b6bdd1f6756e0805b0be3cc2d625f0e7b53bebed326c71077
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:golang/go.opentelemetry.io/proto/otlp@v1.7.1
- 생성일
- 2026-09-14T16:53:50Z
컨트랙트
- 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.
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
소스
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.")
}
오리진 시더
익명