샘플
go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue
검증된 샘플 — golang go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:fd38d0014751e9334f65aeea754675ab22081fd63bbf623aa22f3dd84fb69e1e
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-05 |
케이스
HOW- 목표
- verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
- 심벌
-
- go.opentelemetry.io/proto/otlp/common/v1.AnyValue
- 생성일
- 2026-09-05T10:16:56Z
컨트랙트
- AnyValue represents primitive attribute values including string, integer, double, boolean, and raw byte slices via its oneof Value field and typed getters.
- AnyValue supports nested structured collections including ArrayValue and KeyValueList with arbitrary levels of hierarchy.
- AnyValue getters safely handle nil receivers, unpopulated instances, and mismatched variants without panic by returning default zero values.
- AnyValue serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal.
- AnyValue serializes to and deserializes from protojson format, preserving field names and nested attribute structures.
- proto.Clone produces an isolated deep copy of AnyValue where mutating nested collections does not affect the original.
파일
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- test/main.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 go.opentelemetry.io/proto/otlp/common/v1.AnyValue 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.AnyValue
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:5f3781bc773d92f399cc30199c4e80a64b7a087e7d4b6befd2c5b84cadde6a5d","contract":["AnyValue represents primitive attribute values including string, integer, double, boolean, and raw byte slices via its oneof Value field and typed getters.","AnyValue supports nested structured collections including ArrayValue and KeyValueList with arbitrary levels of hierarchy.","AnyValue getters safely handle nil receivers, unpopulated instances, and mismatched variants without panic by returning default zero values.","AnyValue serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal.","AnyValue serializes to and deserializes from protojson format, preserving field names and nested attribute structures.","proto.Clone produces an isolated deep copy of AnyValue where mutating nested collections does not affect the original."],"goal":"verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue 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.AnyValue"]},"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.AnyValue"],"verifierAdapter":"golang@1"}
module example.com/otlpanyvalue
go 1.26.6
require (
go.opentelemetry.io/proto/otlp v1.9.0
google.golang.org/protobuf v1.36.10
)
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.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue 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.AnyValue"
]
}
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: AnyValue represents primitive attribute values (string, bool, int, double, bytes) through oneof Value field and typed getters
{
strVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "production-cluster"},
}
assert(strVal.GetStringValue() == "production-cluster", "expected StringValue 'production-cluster'")
assert(strVal.GetIntValue() == 0, "expected default 0 IntValue on StringValue")
assert(strVal.GetBoolValue() == false, "expected default false BoolValue on StringValue")
assert(strVal.GetDoubleValue() == 0.0, "expected default 0.0 DoubleValue on StringValue")
assert(strVal.GetBytesValue() == nil, "expected nil BytesValue on StringValue")
intVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_IntValue{IntValue: 4242},
}
assert(intVal.GetIntValue() == 4242, "expected IntValue 4242")
assert(intVal.GetStringValue() == "", "expected empty string on IntValue")
doubleVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_DoubleValue{DoubleValue: 99.95},
}
assert(doubleVal.GetDoubleValue() == 99.95, "expected DoubleValue 99.95")
boolVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BoolValue{BoolValue: true},
}
assert(boolVal.GetBoolValue() == true, "expected BoolValue true")
rawBytes := []byte{0x01, 0x02, 0x03, 0x04}
bytesVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_BytesValue{BytesValue: rawBytes},
}
assert(bytes.Equal(bytesVal.GetBytesValue(), rawBytes), "expected matching BytesValue")
}
// Assertion 2: AnyValue supports nested complex collections including ArrayValue and KeyValueList
{
elem1 := &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "web"}}
elem2 := &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "api"}}
arrVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_ArrayValue{
ArrayValue: &commonpb.ArrayValue{
Values: []*commonpb.AnyValue{elem1, elem2},
},
},
}
assert(len(arrVal.GetArrayValue().GetValues()) == 2, "expected 2 array values")
assert(arrVal.GetArrayValue().GetValues()[0].GetStringValue() == "web", "expected first element 'web'")
assert(arrVal.GetArrayValue().GetValues()[1].GetStringValue() == "api", "expected second element 'api'")
kvVal := &commonpb.AnyValue{
Value: &commonpb.AnyValue_KvlistValue{
KvlistValue: &commonpb.KeyValueList{
Values: []*commonpb.KeyValue{
{
Key: "service.name",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "auth-svc"}},
},
{
Key: "service.tags",
Value: arrVal,
},
},
},
},
}
kvList := kvVal.GetKvlistValue().GetValues()
assert(len(kvList) == 2, "expected 2 key-value pairs")
assert(kvList[0].GetKey() == "service.name", "expected key 'service.name'")
assert(kvList[0].GetValue().GetStringValue() == "auth-svc", "expected value 'auth-svc'")
assert(kvList[1].GetKey() == "service.tags", "expected key 'service.tags'")
assert(len(kvList[1].GetValue().GetArrayValue().GetValues()) == 2, "expected nested array with 2 values")
}
// Assertion 3: AnyValue getters safely handle nil receivers, unpopulated instances, and mismatched variants without panic
{
var nilVal *commonpb.AnyValue
assert(nilVal.GetStringValue() == "", "nil AnyValue GetStringValue must return empty string")
assert(nilVal.GetIntValue() == 0, "nil AnyValue GetIntValue must return 0")
assert(nilVal.GetBoolValue() == false, "nil AnyValue GetBoolValue must return false")
assert(nilVal.GetDoubleValue() == 0.0, "nil AnyValue GetDoubleValue must return 0.0")
assert(nilVal.GetBytesValue() == nil, "nil AnyValue GetBytesValue must return nil")
assert(nilVal.GetArrayValue() == nil, "nil AnyValue GetArrayValue must return nil")
assert(nilVal.GetKvlistValue() == nil, "nil AnyValue GetKvlistValue must return nil")
assert(nilVal.GetValue() == nil, "nil AnyValue GetValue must return nil")
emptyVal := &commonpb.AnyValue{}
assert(emptyVal.GetValue() == nil, "empty AnyValue GetValue must return nil")
assert(emptyVal.GetStringValue() == "", "empty AnyValue GetStringValue must return empty string")
assert(emptyVal.GetArrayValue() == nil, "empty AnyValue GetArrayValue must return nil")
}
// Assertion 4: AnyValue serializes to and deserializes from binary Protobuf wire format without data loss, satisfying proto.Equal
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_KvlistValue{
KvlistValue: &commonpb.KeyValueList{
Values: []*commonpb.KeyValue{
{
Key: "env",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "prod"}},
},
{
Key: "retries",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_IntValue{IntValue: 3}},
},
},
},
},
}
wire, err := proto.Marshal(orig)
assert(err == nil, "proto.Marshal failed")
assert(len(wire) > 0, "marshaled wire length is 0")
unmarshaled := &commonpb.AnyValue{}
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 5: AnyValue serializes to and deserializes from protojson format, preserving field names and nested structures
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_KvlistValue{
KvlistValue: &commonpb.KeyValueList{
Values: []*commonpb.KeyValue{
{
Key: "component",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_StringValue{StringValue: "router"}},
},
{
Key: "port",
Value: &commonpb.AnyValue{Value: &commonpb.AnyValue_IntValue{IntValue: 8443}},
},
},
},
},
}
jsonBytes, err := protojson.Marshal(orig)
assert(err == nil, "protojson.Marshal failed")
assert(bytes.Contains(jsonBytes, []byte(`"kvlistValue"`)), "json must contain 'kvlistValue'")
assert(bytes.Contains(jsonBytes, []byte(`"stringValue"`)), "json must contain 'stringValue'")
assert(bytes.Contains(jsonBytes, []byte(`"intValue"`)), "json must contain 'intValue'")
jsonUnmarshaled := &commonpb.AnyValue{}
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 6: proto.Clone produces an isolated deep copy of AnyValue where mutating nested collections does not affect the original
{
orig := &commonpb.AnyValue{
Value: &commonpb.AnyValue_ArrayValue{
ArrayValue: &commonpb.ArrayValue{
Values: []*commonpb.AnyValue{
{Value: &commonpb.AnyValue_StringValue{StringValue: "original-tag"}},
},
},
},
}
cloned := proto.Clone(orig).(*commonpb.AnyValue)
assert(proto.Equal(orig, cloned), "cloned AnyValue must equal original")
// Mutate cloned nested values
cloned.GetArrayValue().GetValues()[0].Value = &commonpb.AnyValue_StringValue{StringValue: "mutated-tag"}
cloned.GetArrayValue().Values = append(cloned.GetArrayValue().Values, &commonpb.AnyValue{
Value: &commonpb.AnyValue_StringValue{StringValue: "added-tag"},
})
// Verify original remains untouched
assert(orig.GetArrayValue().GetValues()[0].GetStringValue() == "original-tag", "original AnyValue was mutated")
assert(len(orig.GetArrayValue().GetValues()) == 1, "original AnyValue array length was modified")
}
fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/common/v1.AnyValue contract assertions verified")
}
오리진 시더
익명