샘플
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432: graphite.Config, graphite.Once
검증된 샘플 — golang github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432: graphite.Config, graphite.Once. go 1.26 · linux alpine/x64 …
sha256:22ea0c3a207feb0ed79fe189738d16267e365b43aff9232bf6e6e7f25858d709
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
go 1.26 linux 24 · ubuntu · glibc 2.39 amd64 go 1.26 go 1.26 go 1
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-28 |
케이스
HOW- 목표
- verify pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432
- 심벌
-
- graphite.Config
- graphite.Once
- 환경
- go 1.26.6
- 생성일
- 2026-08-28T00:44:12Z
컨트랙트
- graphite.Config defines exporter settings with Addr, Registry, and Prefix
- graphite.Once flushes Counter and Gauge metrics to a Graphite TCP server
- graphite.Once returns an error when the TCP address is unreachable
파일
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- reporter.go
- spec.json
소스
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 pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432
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 sample
import (
"bufio"
"net"
"strings"
"sync"
"testing"
"time"
"github.com/rcrowley/go-metrics"
)
func TestContract(t *testing.T) {
// 1. Verify graphite.Config defines exporter settings
registry := metrics.NewRegistry()
dummyAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("failed to resolve dummy TCP addr: %v", err)
}
cfg := NewConfig(dummyAddr, registry, "csx.app", 5*time.Second)
if cfg.Prefix != "csx.app" {
t.Fatalf("expected Prefix 'csx.app', got %q", cfg.Prefix)
}
if cfg.Registry != registry {
t.Fatalf("expected Registry to match")
}
if cfg.FlushInterval != 5*time.Second {
t.Fatalf("expected FlushInterval 5s, got %v", cfg.FlushInterval)
}
// 2. Verify graphite.Once flushes Counter and Gauge metrics to a Graphite TCP server
ln, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("failed to start mock Graphite TCP listener: %v", err)
}
defer ln.Close()
serverAddr := ln.Addr().(*net.TCPAddr)
receivedLines := make([]string, 0)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
conn, err := ln.Accept()
if err != nil {
return
}
defer conn.Close()
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
receivedLines = append(receivedLines, scanner.Text())
}
}()
counter := metrics.GetOrRegisterCounter("requests.total", registry)
counter.Inc(42)
gauge := metrics.GetOrRegisterGauge("active.workers", registry)
gauge.Update(10)
serverCfg := NewConfig(serverAddr, registry, "csx.metrics", 1*time.Second)
if err := FlushOnce(serverCfg); err != nil {
t.Fatalf("FlushOnce failed: %v", err)
}
wg.Wait()
if len(receivedLines) == 0 {
t.Fatalf("expected metric lines to be received, got none")
}
var foundCounter, foundGauge bool
for _, l := range receivedLines {
if strings.HasPrefix(l, "csx.metrics.requests.total.count 42 ") {
foundCounter = true
}
if strings.HasPrefix(l, "csx.metrics.active.workers.value 10 ") {
foundGauge = true
}
}
if !foundCounter {
t.Fatalf("expected counter metric line 'csx.metrics.requests.total.count 42 <ts>', received lines: %v", receivedLines)
}
if !foundGauge {
t.Fatalf("expected gauge metric line 'csx.metrics.active.workers.value 10 <ts>', received lines: %v", receivedLines)
}
// 3. Verify graphite.Once returns an error when the TCP address is unreachable
closedLn, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatalf("failed to listen temporarily: %v", err)
}
closedAddr := closedLn.Addr().(*net.TCPAddr)
closedLn.Close() // immediately close to make port unreachable
unreachableCfg := NewConfig(closedAddr, registry, "csx.metrics", 1*time.Second)
if err := FlushOnce(unreachableCfg); err == nil {
t.Fatalf("expected FlushOnce to return error for unreachable address, got nil")
}
}
{"case":{"caseId":"case:sha256:fdb59031dcd9e75c48471c03338ef118556215d2e6a130c337a7c2b465d7858a","contract":["graphite.Config defines exporter settings with Addr, Registry, and Prefix","graphite.Once flushes Counter and Gauge metrics to a Graphite TCP server","graphite.Once returns an error when the TCP address is unreachable"],"goal":"verify pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432","kind":"HOW","packages":["pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432"],"schemaVersion":1,"symbols":["graphite.Config","graphite.Once"]},"contractCommand":["go","test","./..."],"environment":{"arch":"amd64","compiler":"go","compilerVersion":"1.26.6","distro":"ubuntu","ecosystem":"golang","language":"go","languageVersion":"1.26.6","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/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432"],"schemaVersion":1,"subject":"pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432","symbols":["graphite.Config","graphite.Once"],"verifierAdapter":"golang@1"}
module example.com/sample
go 1.26.6
require (
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9
)
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432 h1:M5QgkYacWj0Xs8MhpIK/5uwU02icXpEoSo9sM2aRCps=
github.com/cyberdelia/go-metrics-graphite v0.0.0-20161219230853-39f87cc3b432/go.mod h1:xwIwAxMvYnVrGJPe2FKx5prTrnAjGOD8zvDOnxnrrkM=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
package sample
import (
"net"
"time"
graphite "github.com/cyberdelia/go-metrics-graphite"
"github.com/rcrowley/go-metrics"
)
// NewConfig creates a new Graphite exporter Config.
func NewConfig(addr *net.TCPAddr, registry metrics.Registry, prefix string, flushInterval time.Duration) graphite.Config {
return graphite.Config{
Addr: addr,
Registry: registry,
FlushInterval: flushInterval,
DurationUnit: time.Millisecond,
Prefix: prefix,
Percentiles: []float64{0.5, 0.75, 0.95, 0.99},
}
}
// FlushOnce performs a single metrics flush to Graphite.
func FlushOnce(cfg graphite.Config) error {
return graphite.Once(cfg)
}
{
"schemaVersion": 1,
"goal": "verify pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/cyberdelia/go-metrics-graphite@v0.0.0-20161219230853-39f87cc3b432"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
오리진 시더
익명