Sample
go.opentelemetry.io/otel/sdk/metric v1.44.0: metricdata.CumulativeTemporality
Verified sample for golang go.opentelemetry.io/otel/sdk/metric v1.44.0: metricdata.CumulativeTemporality. The contract ran on go 1.26 · linux debian/x64 …
sha256:a4ff93c8d0328f7be3a961ba3bd3e7fc04b55f02865f7469f39aef770ce9a84c
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
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go 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-10-10 |
Case
HOW- Goal
- verify go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0
- Symbols
-
- go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality
- Environment
- go 1.26
- Created
- 2026-10-10T18:58:44Z
Contract
- CumulativeTemporality constant identifies cumulative measurement intervals expanding from a starting point
- CumulativeTemporality String returns string representation CumulativeTemporality
- CumulativeTemporality MarshalText encodes text representation without error
- DefaultTemporalitySelector selects CumulativeTemporality for all standard instrument kinds
- ManualReader with cumulative temporality selector produces Sum aggregations with CumulativeTemporality
Files
- PROMPT.md
- csx.json
- go.mod
- go.sum
- spec.json
- temporality.go
- test/contract_test.go
Source
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.CumulativeTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality
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:908d384671016fc8a0ac9bc49be590d18dd58c478f1c412ea94f74e1a7e9950b","contract":["CumulativeTemporality constant identifies cumulative measurement intervals expanding from a starting point","CumulativeTemporality String returns string representation CumulativeTemporality","CumulativeTemporality MarshalText encodes text representation without error","DefaultTemporalitySelector selects CumulativeTemporality for all standard instrument kinds","ManualReader with cumulative temporality selector produces Sum aggregations with CumulativeTemporality"],"goal":"verify go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","libc":"glibc","libcVersion":"2.39","moduleSystem":"go.mod","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","runtimeVersion":"1.26","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0","symbols":["go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality"],"verifierAdapter":"golang@1"}
module example.com/otel-metric-temporality
go 1.26.6
require go.opentelemetry.io/otel/sdk/metric v1.44.0
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-logr/logr v1.4.3 // 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.44.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
golang.org/x/sys v0.45.0 // indirect
)
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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
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.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/xoEU1+cTA=
go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk=
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality in pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel/sdk/metric@v1.44.0"
],
"symbols": [
"go.opentelemetry.io/otel/sdk/metric/metricdata.CumulativeTemporality"
]
}
package sample
import (
"context"
"fmt"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)
// CumulativeTemporality returns the standard CumulativeTemporality constant.
func CumulativeTemporality() metricdata.Temporality {
return metricdata.CumulativeTemporality
}
// IsCumulative checks if a given Temporality represents cumulative aggregation.
func IsCumulative(t metricdata.Temporality) bool {
return t == metricdata.CumulativeTemporality
}
// FormatTemporality returns string and text representation of a Temporality.
func FormatTemporality(t metricdata.Temporality) (string, []byte, error) {
b, err := t.MarshalText()
if err != nil {
return "", nil, err
}
return t.String(), b, nil
}
// CumulativeMeterSystem holds a MeterProvider and ManualReader using CumulativeTemporality.
type CumulativeMeterSystem struct {
Reader *metric.ManualReader
Provider *metric.MeterProvider
}
// NewCumulativeMeterSystem initializes a MeterProvider using CumulativeTemporality.
func NewCumulativeMeterSystem() *CumulativeMeterSystem {
reader := metric.NewManualReader(
metric.WithTemporalitySelector(func(k metric.InstrumentKind) metricdata.Temporality {
return metricdata.CumulativeTemporality
}),
)
provider := metric.NewMeterProvider(metric.WithReader(reader))
return &CumulativeMeterSystem{
Reader: reader,
Provider: provider,
}
}
// RecordAndCollectCumulative records counter values and collects metric data with CumulativeTemporality.
func (s *CumulativeMeterSystem) RecordAndCollectCumulative(ctx context.Context, meterName, counterName string, value int64) (*metricdata.ResourceMetrics, error) {
meter := s.Provider.Meter(meterName)
counter, err := meter.Int64Counter(counterName)
if err != nil {
return nil, fmt.Errorf("failed to create counter: %w", err)
}
counter.Add(ctx, value)
var rm metricdata.ResourceMetrics
if err := s.Reader.Collect(ctx, &rm); err != nil {
return nil, fmt.Errorf("failed to collect metrics: %w", err)
}
return &rm, nil
}
package test
import (
"context"
"testing"
sample "example.com/otel-metric-temporality"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)
func TestCumulativeTemporalityContract(t *testing.T) {
ctx := context.Background()
// 1. CumulativeTemporality constant identifies cumulative measurement intervals expanding from a starting point
ct := sample.CumulativeTemporality()
if ct != metricdata.CumulativeTemporality {
t.Fatalf("expected CumulativeTemporality, got %v", ct)
}
if !sample.IsCumulative(ct) {
t.Fatalf("expected IsCumulative to return true for CumulativeTemporality")
}
if sample.IsCumulative(metricdata.DeltaTemporality) {
t.Fatalf("expected IsCumulative to return false for DeltaTemporality")
}
// 2. CumulativeTemporality String returns string representation CumulativeTemporality
strName, b, err := sample.FormatTemporality(metricdata.CumulativeTemporality)
if err != nil {
t.Fatalf("unexpected error marshaling CumulativeTemporality: %v", err)
}
if strName != "CumulativeTemporality" {
t.Fatalf("expected String() 'CumulativeTemporality', got %q", strName)
}
// 3. CumulativeTemporality MarshalText encodes text representation without error
if string(b) != "CumulativeTemporality" {
t.Fatalf("expected MarshalText() 'CumulativeTemporality', got %q", string(b))
}
// 4. DefaultTemporalitySelector selects CumulativeTemporality for all standard instrument kinds
kinds := []metric.InstrumentKind{
metric.InstrumentKindCounter,
metric.InstrumentKindUpDownCounter,
metric.InstrumentKindHistogram,
metric.InstrumentKindObservableCounter,
metric.InstrumentKindObservableUpDownCounter,
metric.InstrumentKindObservableGauge,
}
for _, k := range kinds {
if got := metric.DefaultTemporalitySelector(k); got != metricdata.CumulativeTemporality {
t.Fatalf("expected DefaultTemporalitySelector for kind %v to be CumulativeTemporality, got %v", k, got)
}
}
// 5. ManualReader with cumulative temporality selector produces Sum aggregations with CumulativeTemporality
system := sample.NewCumulativeMeterSystem()
defer func() {
_ = system.Provider.Shutdown(ctx)
_ = system.Reader.Shutdown(ctx)
}()
rm, err := system.RecordAndCollectCumulative(ctx, "test-meter", "requests_total", 5)
if err != nil {
t.Fatalf("failed to record and collect: %v", err)
}
if len(rm.ScopeMetrics) == 0 || len(rm.ScopeMetrics[0].Metrics) == 0 {
t.Fatalf("expected collected metrics, got none")
}
metricObj := rm.ScopeMetrics[0].Metrics[0]
sumData, ok := metricObj.Data.(metricdata.Sum[int64])
if !ok {
t.Fatalf("expected metric data to be Sum[int64], got %T", metricObj.Data)
}
if sumData.Temporality != metricdata.CumulativeTemporality {
t.Fatalf("expected Sum temporality to be CumulativeTemporality, got %v", sumData.Temporality)
}
if len(sumData.DataPoints) == 0 || sumData.DataPoints[0].Value != 5 {
t.Fatalf("expected data point value 5, got %v", sumData.DataPoints)
}
}
Origin Seeder
anonymous