CodeSampleX

샘플

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

검증된 샘플 — golang go.opentelemetry.io/proto/otlp v1.9.0: v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA. go 1.26 · linux debian/x64 · docker에서…

sha256:489b06ad8c9cd28fadffca50f3cd13427c7c7bd0fddfbba76fb52551618a3ae8

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA in pkg:golang/go.opentelemetry.io/proto/otlp@v1.9.0
패키지
심벌
  • go.opentelemetry.io/proto/otlp/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA
생성일
2026-09-05T21:52:46Z

컨트랙트

  1. AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA represents delta temporality with integer enum value 1 and string identifier AGGREGATION_TEMPORALITY_DELTA.
  2. AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA can be assigned to Sum, Histogram, and ExponentialHistogram metrics, and retrieved via typed getters.
  3. Protobuf wire serialization and deserialization preserves AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA across binary round-trip with proto.Equal verifying integrity.
  4. JSON serialization via protojson formats AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA as AGGREGATION_TEMPORALITY_DELTA and successfully unmarshals back to the enum.
  5. proto.Clone accurately replicates metric structures configured with AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA into independent deep copies.
  6. AggregationTemporality enum methods correctly reflect DELTA temporality metadata and value mapping.

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA 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/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA

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:5a36694ef140da450dc4478c0888a57df7ac03d58326d3e6b80a31e6f45f0308","contract":["AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA represents delta temporality with integer enum value 1 and string identifier AGGREGATION_TEMPORALITY_DELTA.","AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA can be assigned to Sum, Histogram, and ExponentialHistogram metrics, and retrieved via typed getters.","Protobuf wire serialization and deserialization preserves AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA across binary round-trip with proto.Equal verifying integrity.","JSON serialization via protojson formats AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA as AGGREGATION_TEMPORALITY_DELTA and successfully unmarshals back to the enum.","proto.Clone accurately replicates metric structures configured with AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA into independent deep copies.","AggregationTemporality enum methods correctly reflect DELTA temporality metadata and value mapping."],"goal":"verify go.opentelemetry.io/proto/otlp/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA 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/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA"]},"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/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA"],"verifierAdapter":"golang@1"}
go.mod
module example.com/otlpdelta

go 1.26.6

require (
	go.opentelemetry.io/proto/otlp v1.9.0
	google.golang.org/protobuf v1.36.10
)
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.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
spec.json
{
  "schemaVersion": 1,
  "goal": "verify go.opentelemetry.io/proto/otlp/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA 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/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA"
  ]
}
test/main.go
package main

import (
	"bytes"
	"fmt"
	"os"

	metricspb "go.opentelemetry.io/proto/otlp/metrics/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() {
	delta := metricspb.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA

	// Assertion 1: AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA represents delta temporality with integer enum value 1 and string identifier AGGREGATION_TEMPORALITY_DELTA
	{
		assert(delta == 1, "expected enum value 1 for DELTA temporality")
		assert(delta.String() == "AGGREGATION_TEMPORALITY_DELTA", "expected String() to return 'AGGREGATION_TEMPORALITY_DELTA'")
		assert(int32(delta) == 1, "expected int32 cast to equal 1")
		assert(metricspb.AggregationTemporality_name[int32(delta)] == "AGGREGATION_TEMPORALITY_DELTA", "expected name map lookup to match")
	}

	// Assertion 2: AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA can be assigned to Sum, Histogram, and ExponentialHistogram metrics, and retrieved via typed getters
	{
		sum := &metricspb.Sum{
			AggregationTemporality: delta,
			IsMonotonic:            true,
		}
		assert(sum.GetAggregationTemporality() == delta, "expected Sum GetAggregationTemporality() to return DELTA")

		hist := &metricspb.Histogram{
			AggregationTemporality: delta,
		}
		assert(hist.GetAggregationTemporality() == delta, "expected Histogram GetAggregationTemporality() to return DELTA")

		expHist := &metricspb.ExponentialHistogram{
			AggregationTemporality: delta,
		}
		assert(expHist.GetAggregationTemporality() == delta, "expected ExponentialHistogram GetAggregationTemporality() to return DELTA")
	}

	// Assertion 3: Protobuf wire serialization and deserialization preserves AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA across binary round-trip with proto.Equal verifying integrity
	{
		metric := &metricspb.Metric{
			Name:        "http.server.request.duration",
			Description: "Duration of HTTP server requests",
			Unit:        "ms",
			Data: &metricspb.Metric_Sum{
				Sum: &metricspb.Sum{
					AggregationTemporality: delta,
					IsMonotonic:            true,
					DataPoints: []*metricspb.NumberDataPoint{
						{
							Value: &metricspb.NumberDataPoint_AsInt{AsInt: 100},
						},
					},
				},
			},
		}

		wireBytes, err := proto.Marshal(metric)
		assert(err == nil, "proto.Marshal failed")
		assert(len(wireBytes) > 0, "expected non-empty wire bytes")

		unmarshaled := &metricspb.Metric{}
		err = proto.Unmarshal(wireBytes, unmarshaled)
		assert(err == nil, "proto.Unmarshal failed")
		assert(proto.Equal(metric, unmarshaled), "unmarshaled metric does not equal original")
		assert(unmarshaled.GetSum().GetAggregationTemporality() == delta, "expected unmarshaled Sum to retain DELTA temporality")
	}

	// Assertion 4: JSON serialization via protojson formats AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA as AGGREGATION_TEMPORALITY_DELTA and successfully unmarshals back to the enum
	{
		sum := &metricspb.Sum{
			AggregationTemporality: delta,
			IsMonotonic:            false,
		}

		jsonBytes, err := protojson.Marshal(sum)
		assert(err == nil, "protojson.Marshal failed")
		assert(bytes.Contains(jsonBytes, []byte(`"AGGREGATION_TEMPORALITY_DELTA"`)), "protojson output must contain AGGREGATION_TEMPORALITY_DELTA string")

		unmarshaled := &metricspb.Sum{}
		err = protojson.Unmarshal(jsonBytes, unmarshaled)
		assert(err == nil, "protojson.Unmarshal failed")
		assert(unmarshaled.GetAggregationTemporality() == delta, "expected protojson unmarshal to restore DELTA temporality")
		assert(proto.Equal(sum, unmarshaled), "protojson unmarshaled Sum must match original")
	}

	// Assertion 5: proto.Clone accurately replicates metric structures configured with AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA into independent deep copies
	{
		orig := &metricspb.Metric{
			Name: "system.cpu.utilization",
			Data: &metricspb.Metric_Histogram{
				Histogram: &metricspb.Histogram{
					AggregationTemporality: delta,
					DataPoints: []*metricspb.HistogramDataPoint{
						{
							Count: 5,
							Sum:   proto.Float64(42.5),
						},
					},
				},
			},
		}

		cloned := proto.Clone(orig).(*metricspb.Metric)
		assert(proto.Equal(orig, cloned), "cloned metric must match original")
		assert(cloned.GetHistogram().GetAggregationTemporality() == delta, "cloned histogram must have DELTA temporality")

		// Modify clone to ensure independence
		cloned.GetHistogram().AggregationTemporality = metricspb.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE
		assert(orig.GetHistogram().GetAggregationTemporality() == delta, "mutating clone must not mutate original")
	}

	// Assertion 6: AggregationTemporality enum methods correctly reflect DELTA temporality metadata and value mapping
	{
		enumPtr := delta.Enum()
		assert(enumPtr != nil && *enumPtr == delta, "Enum() must return pointer to enum value")
		assert(delta.Number() == 1, "Number() must return protoreflect.EnumNumber(1)")
		desc := delta.Descriptor()
		assert(desc != nil, "Descriptor() must not be nil")
		assert(string(desc.Name()) == "AggregationTemporality", "Descriptor Name must be AggregationTemporality")
		valueDesc := desc.Values().ByNumber(delta.Number())
		assert(valueDesc != nil, "ValueDescriptor for DELTA must not be nil")
		assert(string(valueDesc.Name()) == "AGGREGATION_TEMPORALITY_DELTA", "ValueDescriptor name must match")
	}

	fmt.Println("PASS: all go.opentelemetry.io/proto/otlp/metrics/v1.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA contract assertions verified")
}

오리진 시더

익명