Sample
github.com/prometheus/client_model v0.2.0: go.MetricType_COUNTER
Verified sample for golang github.com/prometheus/client_model v0.2.0: go.MetricType_COUNTER. The contract ran on go 1.26 · linux alpine/x64 · docker and…
sha256:6342aabbbe68e3573149bfb071082fbc2c572b6c7c2531a306bfc2a94e6ec26f
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 linux 24 · ubuntu · glibc 2.39 x64 go go go
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f… |
2026-08-27 |
Case
HOW- Goal
- verify github.com/prometheus/client_model/go.MetricType_COUNTER in pkg:golang/github.com/prometheus/client_model@v0.2.0
- Symbols
-
- github.com/prometheus/client_model/go.MetricType_COUNTER
- Environment
- go
- Created
- 2026-08-27T16:04:27Z
Contract
- dto.MetricType_COUNTER is an enum constant of type dto.MetricType with value 0 representing Prometheus counter metrics.
- dto.MetricType_COUNTER has String representation 'COUNTER', Enum helper returning *MetricType, and maps in MetricType_name and MetricType_value.
- dto.MetricFamily configured with Type MetricType_COUNTER.Enum() stores counter metric values and roundtrips through protobuf marshal and unmarshal.
- dto.MetricType unmarshals JSON string 'COUNTER' and numeric 0 to MetricType_COUNTER.
Files
- NOTES.md
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
Source
# prometheus client_model MetricType_COUNTER Verification Notes
## Search Results
An initial search via `search_known_solution` for `pkg:golang/github.com/prometheus/client_model@v0.2.0` with `github.com/prometheus/client_model/go.MetricType_COUNTER` was conducted.
## Pinned Version
- Package: `github.com/prometheus/client_model`
- Release: `v0.2.0` (in `go.mod` / `go.sum`)
## Observed Behavior
1. **MetricType_COUNTER Enum Constant**:
- `dto.MetricType_COUNTER` is a typed constant of enum type `dto.MetricType` equal to `0`.
- `dto.MetricType_COUNTER.String()` returns `"COUNTER"`.
- `dto.MetricType_COUNTER.Enum()` returns `*dto.MetricType`.
- `dto.MetricType_name` and `dto.MetricType_value` map between string representation and int32 representation.
2. **MetricFamily Integration & Protobuf Serialization**:
- `dto.MetricFamily` configured with `Type: dto.MetricType_COUNTER.Enum()` contains metrics with `Counter` definitions and roundtrips through protobuf serialization without data loss.
3. **JSON Unmarshaling**:
- `dto.MetricType` unmarshals both string `"COUNTER"` and integer `0` to `dto.MetricType_COUNTER`.
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 github.com/prometheus/client_model/go.MetricType_COUNTER in pkg:golang/github.com/prometheus/client_model@v0.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/client_model@v0.2.0
Demonstrate these symbols/APIs:
- github.com/prometheus/client_model/go.MetricType_COUNTER
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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.
package clientmodelcounter_test
import (
"encoding/json"
"testing"
"github.com/golang/protobuf/proto"
dto "github.com/prometheus/client_model/go"
)
func TestMetricTypeCounterConstantAndProperties(t *testing.T) {
// Verify MetricType_COUNTER enum value
if dto.MetricType_COUNTER != 0 {
t.Fatalf("expected MetricType_COUNTER == 0, got %d", dto.MetricType_COUNTER)
}
// Verify String() method returns "COUNTER"
if str := dto.MetricType_COUNTER.String(); str != "COUNTER" {
t.Fatalf("expected MetricType_COUNTER.String() == %q, got %q", "COUNTER", str)
}
// Verify Enum() returns pointer to MetricType_COUNTER
enumPtr := dto.MetricType_COUNTER.Enum()
if enumPtr == nil || *enumPtr != dto.MetricType_COUNTER {
t.Fatalf("expected Enum() to return pointer to MetricType_COUNTER, got %v", enumPtr)
}
// Verify name and value mappings
if name, ok := dto.MetricType_name[int32(dto.MetricType_COUNTER)]; !ok || name != "COUNTER" {
t.Fatalf("expected MetricType_name mapping to COUNTER, got %q (ok=%v)", name, ok)
}
if val, ok := dto.MetricType_value["COUNTER"]; !ok || val != int32(dto.MetricType_COUNTER) {
t.Fatalf("expected MetricType_value mapping for COUNTER to 0, got %d (ok=%v)", val, ok)
}
}
func TestMetricFamilyWithCounter(t *testing.T) {
metricName := "http_requests_total"
metricHelp := "Total number of HTTP requests processed"
counterValue := 1024.0
labelName := "method"
labelValue := "GET"
family := &dto.MetricFamily{
Name: &metricName,
Help: &metricHelp,
Type: dto.MetricType_COUNTER.Enum(),
Metric: []*dto.Metric{
{
Label: []*dto.LabelPair{
{
Name: &labelName,
Value: &labelValue,
},
},
Counter: &dto.Counter{
Value: &counterValue,
},
},
},
}
if family.GetName() != metricName {
t.Errorf("expected family name %q, got %q", metricName, family.GetName())
}
if family.GetHelp() != metricHelp {
t.Errorf("expected family help %q, got %q", metricHelp, family.GetHelp())
}
if family.GetType() != dto.MetricType_COUNTER {
t.Fatalf("expected family type %v, got %v", dto.MetricType_COUNTER, family.GetType())
}
metrics := family.GetMetric()
if len(metrics) != 1 {
t.Fatalf("expected 1 metric in family, got %d", len(metrics))
}
if metrics[0].GetCounter() == nil {
t.Fatal("expected counter in metric to be non-nil")
}
if metrics[0].GetCounter().GetValue() != counterValue {
t.Errorf("expected counter value %f, got %f", counterValue, metrics[0].GetCounter().GetValue())
}
// Protobuf serialization roundtrip
data, err := proto.Marshal(family)
if err != nil {
t.Fatalf("failed to marshal MetricFamily: %v", err)
}
var decoded dto.MetricFamily
if err := proto.Unmarshal(data, &decoded); err != nil {
t.Fatalf("failed to unmarshal MetricFamily: %v", err)
}
if decoded.GetType() != dto.MetricType_COUNTER {
t.Fatalf("expected unmarshaled type %v, got %v", dto.MetricType_COUNTER, decoded.GetType())
}
if len(decoded.GetMetric()) != 1 || decoded.GetMetric()[0].GetCounter().GetValue() != counterValue {
t.Fatalf("unmarshaled counter metric does not match original")
}
}
func TestMetricTypeJSONUnmarshal(t *testing.T) {
var mt dto.MetricType
if err := json.Unmarshal([]byte(`"COUNTER"`), &mt); err != nil {
t.Fatalf("failed to unmarshal JSON \"COUNTER\": %v", err)
}
if mt != dto.MetricType_COUNTER {
t.Fatalf("expected unmarshaled JSON to be MetricType_COUNTER, got %v", mt)
}
if err := json.Unmarshal([]byte(`0`), &mt); err != nil {
t.Fatalf("failed to unmarshal numeric JSON 0: %v", err)
}
if mt != dto.MetricType_COUNTER {
t.Fatalf("expected unmarshaled numeric 0 to be MetricType_COUNTER, got %v", mt)
}
}
{"case":{"caseId":"case:sha256:e759102d05d81cecaf31fac0baea3fc0093e0c8440b34dd62787418afaf47695","contract":["dto.MetricType_COUNTER is an enum constant of type dto.MetricType with value 0 representing Prometheus counter metrics.","dto.MetricType_COUNTER has String representation 'COUNTER', Enum helper returning *MetricType, and maps in MetricType_name and MetricType_value.","dto.MetricFamily configured with Type MetricType_COUNTER.Enum() stores counter metric values and roundtrips through protobuf marshal and unmarshal.","dto.MetricType unmarshals JSON string 'COUNTER' and numeric 0 to MetricType_COUNTER."],"goal":"verify github.com/prometheus/client_model/go.MetricType_COUNTER in pkg:golang/github.com/prometheus/client_model@v0.2.0","kind":"HOW","packages":["pkg:golang/github.com/prometheus/client_model@v0.2.0"],"schemaVersion":1,"symbols":["github.com/prometheus/client_model/go.MetricType_COUNTER"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","executionContext":"go","language":"go","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","runtime":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/prometheus/client_model@v0.2.0"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/client_model@v0.2.0","symbols":["github.com/prometheus/client_model/go.MetricType_COUNTER"],"verifierAdapter":"golang@1"}
module example.com/clientmodelcounter
go 1.22
require (
github.com/golang/protobuf v1.5.0
github.com/prometheus/client_model v0.2.0
)
require google.golang.org/protobuf v1.26.0-rc.1 // indirect
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1 h1:7QnIQpGRHE5RnLKnESfDoxm2dTapTZua5a0kS0A+VXQ=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
{
"schemaVersion": 1,
"goal": "verify github.com/prometheus/client_model/go.MetricType_COUNTER in pkg:golang/github.com/prometheus/client_model@v0.2.0",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/client_model@v0.2.0"
],
"symbols": [
"github.com/prometheus/client_model/go.MetricType_COUNTER"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
Origin Seeder
anonymous