CodeSampleX

Sample

go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_IntValue

Verified sample for golang go.opentelemetry.io/proto/otlp v1.9.0: v1.AnyValue_IntValue. The contract ran on go 1.26 · linux debian/x64 · docker and passed.

sha256:91b18273ee8372ea438cc203963aec286cd00a0f370b491a951d5b2911cab434

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/common/v1.AnyValue_IntValue in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
Packages
Symbols
  • go.opentelemetry.io/proto/otlp/common/v1.AnyValue_IntValue
Created
2026-09-05T14:31:42Z

Contract

  1. AnyValue_IntValue wraps an int64 value as an AnyValue oneof variant
  2. AnyValue.GetIntValue returns the wrapped int64 when AnyValue_IntValue is set and non-int getters return zero values
  3. AnyValue with AnyValue_IntValue roundtrips through protobuf binary wire format without data loss
  4. AnyValue with AnyValue_IntValue roundtrips through protojson format preserving intValue
  5. AnyValue_IntValue preserves explicit zero value distinction from unpopulated AnyValue
  6. KeyValue attribute with AnyValue_IntValue provides key and int64 value access for telemetry metadata

Files

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Download the source artifact (tar.gz)

Source

PROMPT.md
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_IntValue 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_IntValue

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.
csx.json
{"case":{"caseId":"case:sha256:6d73b0659b10fb750f5f1a4d9bf1b5679a6b4222b7b571781594d5a85342cac3","contract":["AnyValue_IntValue wraps an int64 value as an AnyValue oneof variant","AnyValue.GetIntValue returns the wrapped int64 when AnyValue_IntValue is set and non-int getters return zero values","AnyValue with AnyValue_IntValue roundtrips through protobuf binary wire format without data loss","AnyValue with AnyValue_IntValue roundtrips through protojson format preserving intValue","AnyValue_IntValue preserves explicit zero value distinction from unpopulated AnyValue","KeyValue attribute with AnyValue_IntValue provides key and int64 value access for telemetry metadata"],"goal":"verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_IntValue 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_IntValue"]},"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_IntValue"],"verifierAdapter":"golang@1"}
go.mod
module sample

go 1.26.6

require (
	go.opentelemetry.io/proto/otlp v1.9.0
	google.golang.org/protobuf v1.36.11
)
go.sum
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.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
main.go
package main

import (
	"fmt"

	commonpb "go.opentelemetry.io/proto/otlp/common/v1"
)

// IntAttribute wraps an int64 value into an OpenTelemetry AnyValue_IntValue.
func IntAttribute(key string, val int64) *commonpb.KeyValue {
	return &commonpb.KeyValue{
		Key: key,
		Value: &commonpb.AnyValue{
			Value: &commonpb.AnyValue_IntValue{
				IntValue: val,
			},
		},
	}
}

// ExtractIntValue retrieves the int64 value from an AnyValue, or 0 if not set.
func ExtractIntValue(av *commonpb.AnyValue) int64 {
	if av == nil {
		return 0
	}
	return av.GetIntValue()
}

func main() {
	attr := IntAttribute("http.status_code", 200)
	fmt.Printf("Attribute %s=%d\n", attr.GetKey(), ExtractIntValue(attr.GetValue()))
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify go.opentelemetry.io/proto/otlp/common/v1.AnyValue_IntValue 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_IntValue"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"math"
	"os"

	commonpb "go.opentelemetry.io/proto/otlp/common/v1"
	"google.golang.org/protobuf/encoding/protojson"
	"google.golang.org/protobuf/proto"
)

func main() {
	// 1. AnyValue_IntValue wraps an int64 value as an AnyValue oneof variant
	{
		intVal := &commonpb.AnyValue_IntValue{IntValue: 42}
		av := &commonpb.AnyValue{Value: intVal}

		if av.GetValue() == nil {
			fmt.Fprintf(os.Stderr, "FAIL: expected non-nil Value\n")
			os.Exit(1)
		}
		extracted, ok := av.GetValue().(*commonpb.AnyValue_IntValue)
		if !ok {
			fmt.Fprintf(os.Stderr, "FAIL: expected *commonpb.AnyValue_IntValue\n")
			os.Exit(1)
		}
		if extracted.IntValue != 42 {
			fmt.Fprintf(os.Stderr, "FAIL: expected 42, got %d\n", extracted.IntValue)
			os.Exit(1)
		}
	}

	// 2. AnyValue.GetIntValue returns the wrapped int64 when AnyValue_IntValue is set and non-int getters return zero values
	{
		av := &commonpb.AnyValue{
			Value: &commonpb.AnyValue_IntValue{IntValue: 1024},
		}
		if av.GetIntValue() != 1024 {
			fmt.Fprintf(os.Stderr, "FAIL: expected 1024, got %d\n", av.GetIntValue())
			os.Exit(1)
		}
		if av.GetStringValue() != "" {
			fmt.Fprintf(os.Stderr, "FAIL: expected empty string for string value\n")
			os.Exit(1)
		}
		if av.GetBoolValue() != false {
			fmt.Fprintf(os.Stderr, "FAIL: expected false for bool value\n")
			os.Exit(1)
		}
		if av.GetDoubleValue() != 0.0 {
			fmt.Fprintf(os.Stderr, "FAIL: expected 0.0 for double value\n")
			os.Exit(1)
		}
		if av.GetBytesValue() != nil {
			fmt.Fprintf(os.Stderr, "FAIL: expected nil for bytes value\n")
			os.Exit(1)
		}
		if av.GetArrayValue() != nil {
			fmt.Fprintf(os.Stderr, "FAIL: expected nil for array value\n")
			os.Exit(1)
		}
		if av.GetKvlistValue() != nil {
			fmt.Fprintf(os.Stderr, "FAIL: expected nil for kvlist value\n")
			os.Exit(1)
		}
	}

	// 3. AnyValue with AnyValue_IntValue roundtrips through protobuf binary wire format without data loss
	{
		testValues := []int64{0, -1, 42, 1000000, math.MinInt64, math.MaxInt64}
		for _, v := range testValues {
			av := &commonpb.AnyValue{
				Value: &commonpb.AnyValue_IntValue{IntValue: v},
			}
			wire, err := proto.Marshal(av)
			if err != nil {
				fmt.Fprintf(os.Stderr, "FAIL: proto.Marshal error: %v\n", err)
				os.Exit(1)
			}
			var decoded commonpb.AnyValue
			if err := proto.Unmarshal(wire, &decoded); err != nil {
				fmt.Fprintf(os.Stderr, "FAIL: proto.Unmarshal error: %v\n", err)
				os.Exit(1)
			}
			if decoded.GetIntValue() != v {
				fmt.Fprintf(os.Stderr, "FAIL: wire roundtrip value mismatch: got %d, expected %d\n", decoded.GetIntValue(), v)
				os.Exit(1)
			}
			if _, ok := decoded.GetValue().(*commonpb.AnyValue_IntValue); !ok {
				fmt.Fprintf(os.Stderr, "FAIL: wire roundtrip value type is not AnyValue_IntValue\n")
				os.Exit(1)
			}
		}
	}

	// 4. AnyValue with AnyValue_IntValue roundtrips through protojson format preserving intValue
	{
		av := &commonpb.AnyValue{
			Value: &commonpb.AnyValue_IntValue{IntValue: 8080},
		}
		jsonBytes, err := protojson.Marshal(av)
		if err != nil {
			fmt.Fprintf(os.Stderr, "FAIL: protojson.Marshal error: %v\n", err)
			os.Exit(1)
		}
		var jsonDecoded commonpb.AnyValue
		if err := protojson.Unmarshal(jsonBytes, &jsonDecoded); err != nil {
			fmt.Fprintf(os.Stderr, "FAIL: protojson.Unmarshal error: %v\n", err)
			os.Exit(1)
		}
		if jsonDecoded.GetIntValue() != 8080 {
			fmt.Fprintf(os.Stderr, "FAIL: json roundtrip value mismatch: got %d, expected 8080\n", jsonDecoded.GetIntValue())
			os.Exit(1)
		}
	}

	// 5. AnyValue_IntValue preserves explicit zero value distinction from unpopulated AnyValue
	{
		zeroAv := &commonpb.AnyValue{
			Value: &commonpb.AnyValue_IntValue{IntValue: 0},
		}
		unpopulatedAv := &commonpb.AnyValue{}

		if zeroAv.GetValue() == nil {
			fmt.Fprintf(os.Stderr, "FAIL: explicit zero AnyValue must have non-nil Value\n")
			os.Exit(1)
		}
		if unpopulatedAv.GetValue() != nil {
			fmt.Fprintf(os.Stderr, "FAIL: unpopulated AnyValue must have nil Value\n")
			os.Exit(1)
		}
		if zeroAv.GetIntValue() != unpopulatedAv.GetIntValue() {
			fmt.Fprintf(os.Stderr, "FAIL: both explicit zero and unpopulated should return 0 from getter\n")
			os.Exit(1)
		}
	}

	// 6. KeyValue attribute with AnyValue_IntValue provides key and int64 value access for telemetry metadata
	{
		kv := &commonpb.KeyValue{
			Key: "http.status_code",
			Value: &commonpb.AnyValue{
				Value: &commonpb.AnyValue_IntValue{IntValue: 200},
			},
		}
		if kv.GetKey() != "http.status_code" {
			fmt.Fprintf(os.Stderr, "FAIL: KeyValue key mismatch: got %q\n", kv.GetKey())
			os.Exit(1)
		}
		if kv.GetValue().GetIntValue() != 200 {
			fmt.Fprintf(os.Stderr, "FAIL: KeyValue value mismatch: got %d\n", kv.GetValue().GetIntValue())
			os.Exit(1)
		}
	}

	fmt.Println("PASS: all contract assertions passed")
}

Origin Seeder

anonymous