CodeSampleX

Sample

go.opentelemetry.io/otel/sdk/metric v1.45.0: metricdata.DeltaTemporality

Verified sample for golang go.opentelemetry.io/otel/sdk/metric v1.45.0: metricdata.DeltaTemporality. The contract ran on go 1.26 · linux debian/x64 · docker…

sha256:6ce442eab4b4867c60e38ea48ee12ba8c3b26e24202a8f56cf947048c29738a7

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-16

Case

HOW
Goal
verify go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0
Packages
Symbols
  • go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality
Created
2026-09-16T10:04:56Z

Contract

  1. metricdata.DeltaTemporality is defined as Temporality representing delta aggregation intervals
  2. metricdata.DeltaTemporality string representation and text marshaling return DeltaTemporality
  3. DeltaTemporality differs from CumulativeTemporality
  4. metric.DeltaTemporalitySelector selects DeltaTemporality for counter and histogram instruments
  5. ManualReader configured with DeltaTemporality produces metric aggregations with DeltaTemporality

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/otel/sdk/metric/metricdata.DeltaTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0
Demonstrate these symbols/APIs:
  - go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality

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:9c558c8a9a7a7f1805398961bdcff9a6c1c8697b0fcee36b1f0088a5e5393f3c","contract":["metricdata.DeltaTemporality is defined as Temporality representing delta aggregation intervals","metricdata.DeltaTemporality string representation and text marshaling return DeltaTemporality","DeltaTemporality differs from CumulativeTemporality","metric.DeltaTemporalitySelector selects DeltaTemporality for counter and histogram instruments","ManualReader configured with DeltaTemporality produces metric aggregations with DeltaTemporality"],"goal":"verify go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality"]},"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/otel/sdk/metric@v1.45.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0","symbols":["go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require go.opentelemetry.io/otel/sdk/metric v1.45.0

require (
	github.com/cespare/xxhash/v2 v2.3.0 // indirect
	github.com/go-logr/logr v1.4.4 // indirect
	github.com/go-logr/stdr v1.2.2 // indirect
	github.com/google/uuid v1.6.0 // indirect
	go.opentelemetry.io/auto/sdk v1.2.1 // indirect
	go.opentelemetry.io/otel v1.45.0 // indirect
	go.opentelemetry.io/otel/metric v1.45.0 // indirect
	go.opentelemetry.io/otel/sdk v1.45.0 // indirect
	go.opentelemetry.io/otel/trace v1.45.0 // indirect
	golang.org/x/sys v0.47.0 // indirect
)
go.sum
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.45.0 h1:pdrWmLHofpubmArBv1LgFSv1Z0Ie/ppdZzu+kUN5EeU=
go.opentelemetry.io/otel v1.45.0/go.mod h1:XZxIqPapzEYnhNSScF5DIqXhm/rYi0FzCe2XddAwZfQ=
go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc=
go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE=
go.opentelemetry.io/otel/metric v1.45.0 h1:7Eg1uH7CJ5cXv9is6tnBe1FI6rj1nwUdbFypRm3br/M=
go.opentelemetry.io/otel/metric v1.45.0/go.mod h1:HAPbm1nd3p1PmFH7v2dR+6BjXxw+Lq4a2+pndMAm08s=
go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8=
go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o=
go.opentelemetry.io/otel/metric/x v0.67.0 h1:PcicCNZFkZ4bXfSooXdo3WN7RBOVOtjVdo1wD358Uns=
go.opentelemetry.io/otel/metric/x v0.68.0 h1:TA/cBT23D3MnxYPwHL7YFOdYGdx0A0v+s7Mzotpd1dU=
go.opentelemetry.io/otel/metric/x v0.68.0/go.mod h1:agudOmvWhwUTjgibWDzxD2PoWYnpw5Ht5jISYOD2Hd4=
go.opentelemetry.io/otel/sdk v1.45.0 h1:4VVSMgQ83dUgW2aoX5f6JgLvHwIvzcuLnF9lUdCSpCw=
go.opentelemetry.io/otel/sdk v1.45.0/go.mod h1:Sr40LgXV7DsKMMJMKOhUWOgMWTfAaqvm2kF0g7ilwuA=
go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI=
go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM=
go.opentelemetry.io/otel/sdk/metric v1.45.0 h1:oVFszMfyj1Am6s24Vtc7wBb8BKLcwepJjNEYILuiE3o=
go.opentelemetry.io/otel/sdk/metric v1.45.0/go.mod h1:vUWUxDZvu1WVRj8JA8S0AdhsPrZoDpA2DdZauIh4mDA=
go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE=
go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4=
go.opentelemetry.io/otel/trace v1.45.0 h1:l/mP6Uv7oNO7/TblbhpbgMidxhq1uO/rPsikOyVhxag=
go.opentelemetry.io/otel/trace v1.45.0/go.mod h1:qoJJA2xNMnxRrdISU/kLtfUH2wNeQbiv+jhs/CxI8bc=
go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c=
go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
main.go
package main

import (
	"context"
	"fmt"

	"go.opentelemetry.io/otel/sdk/metric"
	"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

func main() {
	fmt.Printf("DeltaTemporality: %s\n", metricdata.DeltaTemporality)

	selector := metric.DeltaTemporalitySelector
	temporality := selector(metric.InstrumentKindCounter)
	fmt.Printf("Counter temporality: %s\n", temporality)

	reader := metric.NewManualReader(metric.WithTemporalitySelector(metric.DeltaTemporalitySelector))
	mp := metric.NewMeterProvider(metric.WithReader(reader))
	defer func() { _ = mp.Shutdown(context.Background()) }()

	meter := mp.Meter("sample-meter")
	counter, err := meter.Int64Counter("items_processed")
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	counter.Add(ctx, 42)

	var rm metricdata.ResourceMetrics
	if err := reader.Collect(ctx, &rm); err != nil {
		panic(err)
	}

	for _, sm := range rm.ScopeMetrics {
		for _, m := range sm.Metrics {
			if sumData, ok := m.Data.(metricdata.Sum[int64]); ok {
				fmt.Printf("Metric %s has temporality: %s\n", m.Name, sumData.Temporality)
			}
		}
	}
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0",
  "kind": "HOW",
  "packages": [
    "pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.45.0"
  ],
  "symbols": [
    "go.opentelemetry.io/otel/sdk/metric/metricdata.DeltaTemporality"
  ]
}
test/contract.go
package main

import (
	"context"
	"fmt"
	"os"

	"go.opentelemetry.io/otel/sdk/metric"
	"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

func main() {
	if err := runTests(); err != nil {
		fmt.Fprintf(os.Stderr, "Contract test failed: %v\n", err)
		os.Exit(1)
	}
	fmt.Println("All contract assertions passed.")
}

func runTests() error {
	// 1. metricdata.DeltaTemporality is defined as Temporality representing delta aggregation intervals
	var t metricdata.Temporality = metricdata.DeltaTemporality
	if t != metricdata.DeltaTemporality {
		return fmt.Errorf("expected Temporality to match DeltaTemporality")
	}

	// 2. metricdata.DeltaTemporality string representation and text marshaling return DeltaTemporality
	if str := metricdata.DeltaTemporality.String(); str != "DeltaTemporality" {
		return fmt.Errorf("expected String() 'DeltaTemporality', got %q", str)
	}
	text, err := metricdata.DeltaTemporality.MarshalText()
	if err != nil {
		return fmt.Errorf("unexpected error marshaling DeltaTemporality: %w", err)
	}
	if string(text) != "DeltaTemporality" {
		return fmt.Errorf("expected MarshalText() 'DeltaTemporality', got %q", string(text))
	}

	// 3. DeltaTemporality differs from CumulativeTemporality
	if metricdata.DeltaTemporality == metricdata.CumulativeTemporality {
		return fmt.Errorf("expected DeltaTemporality != CumulativeTemporality")
	}

	// 4. metric.DeltaTemporalitySelector selects DeltaTemporality for counter and histogram instruments
	if got := metric.DeltaTemporalitySelector(metric.InstrumentKindCounter); got != metricdata.DeltaTemporality {
		return fmt.Errorf("expected DeltaTemporality for Counter, got %v", got)
	}
	if got := metric.DeltaTemporalitySelector(metric.InstrumentKindHistogram); got != metricdata.DeltaTemporality {
		return fmt.Errorf("expected DeltaTemporality for Histogram, got %v", got)
	}
	if got := metric.DeltaTemporalitySelector(metric.InstrumentKindObservableCounter); got != metricdata.DeltaTemporality {
		return fmt.Errorf("expected DeltaTemporality for ObservableCounter, got %v", got)
	}

	// 5. ManualReader configured with DeltaTemporality produces metric aggregations with DeltaTemporality
	reader := metric.NewManualReader(metric.WithTemporalitySelector(metric.DeltaTemporalitySelector))
	mp := metric.NewMeterProvider(metric.WithReader(reader))
	defer func() { _ = mp.Shutdown(context.Background()) }()

	meter := mp.Meter("example.com/test-meter")
	counter, err := meter.Int64Counter("test_counter")
	if err != nil {
		return fmt.Errorf("failed to create counter: %w", err)
	}

	ctx := context.Background()
	counter.Add(ctx, 15)

	var rm metricdata.ResourceMetrics
	if err := reader.Collect(ctx, &rm); err != nil {
		return fmt.Errorf("failed to collect metrics: %w", err)
	}

	if len(rm.ScopeMetrics) == 0 || len(rm.ScopeMetrics[0].Metrics) == 0 {
		return fmt.Errorf("expected at least one metric recorded")
	}

	sumData, ok := rm.ScopeMetrics[0].Metrics[0].Data.(metricdata.Sum[int64])
	if !ok {
		return fmt.Errorf("expected metric data to be Sum[int64], got %T", rm.ScopeMetrics[0].Metrics[0].Data)
	}

	if sumData.Temporality != metricdata.DeltaTemporality {
		return fmt.Errorf("expected sum temporality to be DeltaTemporality, got %v", sumData.Temporality)
	}

	if len(sumData.DataPoints) != 1 || sumData.DataPoints[0].Value != 15 {
		return fmt.Errorf("expected data point value 15, got %v", sumData.DataPoints)
	}

	return nil
}

Origin Seeder

anonymous