Ejemplo
github.com/prometheus/client_model v0.6.1: go.MetricType_GAUGE
Muestra verificada para golang github.com/prometheus/client_model v0.6.1: go.MetricType_GAUGE. El contrato se ejecutó en go 1.26 · linux debian/x64 · docker…
sha256:e61a04c4230a7a753827f145f36df4557f497266589db798d0cb330ee6253e95
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go 1.26 go 1
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify github.com/prometheus/client_model/go.MetricType_GAUGE in pkg:golang/github.com/prometheus/client_model@v0.6.1
- Símbolos
-
- github.com/prometheus/client_model/go.MetricType_GAUGE
- Entorno
- go 1.26.6
- Creado
- 2026-09-05T15:23:41Z
Contrato
- MetricType_GAUGE enum value equals 1 and String() returns GAUGE
- CreateGaugeMetricFamily sets MetricFamily Type to MetricType_GAUGE with non-nil Gauge value
Archivos
- PROMPT.md
- csx.json
- gauge.go
- go.mod
- go.sum
- spec.json
- test/contract_test.go
Código fuente
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_GAUGE in pkg:golang/github.com/prometheus/client_model@v0.6.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/prometheus/client_model@v0.6.1
Demonstrate these symbols/APIs:
- github.com/prometheus/client_model/go.MetricType_GAUGE
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:d9e4f211b6fa05597403045d71cf6c3ce52fceedd2c506a17169205232951b4f","contract":["MetricType_GAUGE enum value equals 1 and String() returns GAUGE","CreateGaugeMetricFamily sets MetricFamily Type to MetricType_GAUGE with non-nil Gauge value"],"goal":"verify github.com/prometheus/client_model/go.MetricType_GAUGE in pkg:golang/github.com/prometheus/client_model@v0.6.1","kind":"HOW","packages":["pkg:golang/github.com/prometheus/client_model@v0.6.1"],"schemaVersion":1,"symbols":["github.com/prometheus/client_model/go.MetricType_GAUGE"]},"contractCommand":["go","test","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","packageManagerVersion":"1.26.6","runtime":"go","runtimeVersion":"1.26.6","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/prometheus/client_model@v0.6.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/prometheus/client_model@v0.6.1","symbols":["github.com/prometheus/client_model/go.MetricType_GAUGE"],"verifierAdapter":"golang@1"}
package sample
import (
dto "github.com/prometheus/client_model/go"
)
// StringPtr returns a pointer to a string.
func StringPtr(s string) *string {
return &s
}
// Float64Ptr returns a pointer to a float64.
func Float64Ptr(f float64) *float64 {
return &f
}
// MetricTypePtr returns a pointer to a MetricType.
func MetricTypePtr(t dto.MetricType) *dto.MetricType {
return &t
}
// CreateGaugeMetric creates a Metric containing a Gauge with the given labels and value.
func CreateGaugeMetric(labels map[string]string, value float64) *dto.Metric {
var labelPairs []*dto.LabelPair
for k, v := range labels {
labelPairs = append(labelPairs, &dto.LabelPair{
Name: StringPtr(k),
Value: StringPtr(v),
})
}
return &dto.Metric{
Label: labelPairs,
Gauge: &dto.Gauge{
Value: Float64Ptr(value),
},
}
}
// CreateGaugeMetricFamily creates a MetricFamily with MetricType_GAUGE type and given name, help, and metrics.
func CreateGaugeMetricFamily(name, help string, metrics []*dto.Metric) *dto.MetricFamily {
return &dto.MetricFamily{
Name: StringPtr(name),
Help: StringPtr(help),
Type: dto.MetricType_GAUGE.Enum(),
Metric: metrics,
}
}
// FormatMetricType returns the string representation of a MetricType.
func FormatMetricType(t dto.MetricType) string {
return t.String()
}
module sample
go 1.26.6
require github.com/prometheus/client_model v0.6.1
require google.golang.org/protobuf v1.33.0 // indirect
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.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
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.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
{
"schemaVersion": 1,
"goal": "verify github.com/prometheus/client_model/go.MetricType_GAUGE in pkg:golang/github.com/prometheus/client_model@v0.6.1",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/prometheus/client_model@v0.6.1"
],
"symbols": [
"github.com/prometheus/client_model/go.MetricType_GAUGE"
]
}
package test
import (
"testing"
dto "github.com/prometheus/client_model/go"
"sample"
)
func TestMetricTypeGaugeContract(t *testing.T) {
// Verify MetricType_GAUGE constant value and string representation
if dto.MetricType_GAUGE != 1 {
t.Fatalf("expected dto.MetricType_GAUGE to have value 1, got %d", int32(dto.MetricType_GAUGE))
}
if dto.MetricType_GAUGE.String() != "GAUGE" {
t.Fatalf("expected dto.MetricType_GAUGE.String() to be %q, got %q", "GAUGE", dto.MetricType_GAUGE.String())
}
if sample.FormatMetricType(dto.MetricType_GAUGE) != "GAUGE" {
t.Fatalf("expected FormatMetricType(dto.MetricType_GAUGE) to return %q, got %q", "GAUGE", sample.FormatMetricType(dto.MetricType_GAUGE))
}
// Verify MetricFamily configured with MetricType_GAUGE
labels := map[string]string{
"service": "api-gateway",
"env": "production",
}
val := 42.5
m := sample.CreateGaugeMetric(labels, val)
mf := sample.CreateGaugeMetricFamily("active_connections", "Number of currently active connections", []*dto.Metric{m})
if mf.GetType() != dto.MetricType_GAUGE {
t.Fatalf("expected MetricFamily type to be MetricType_GAUGE, got %v", mf.GetType())
}
if mf.GetName() != "active_connections" {
t.Fatalf("expected MetricFamily name %q, got %q", "active_connections", mf.GetName())
}
if mf.GetHelp() != "Number of currently active connections" {
t.Fatalf("expected MetricFamily help %q, got %q", "Number of currently active connections", mf.GetHelp())
}
if len(mf.GetMetric()) != 1 {
t.Fatalf("expected 1 metric, got %d", len(mf.GetMetric()))
}
metric := mf.GetMetric()[0]
if metric.GetGauge() == nil {
t.Fatal("expected gauge in metric to be non-nil")
}
if metric.GetGauge().GetValue() != val {
t.Fatalf("expected gauge value %f, got %f", val, metric.GetGauge().GetValue())
}
}
Seeder de origen
anónimo