Exemplo
go.opentelemetry.io/otel/log v0.19.0: Kind
Amostra verificada para golang go.opentelemetry.io/otel/log v0.19.0: Kind. O contrato rodou em go 1.26 · linux debian/x64 · docker e passou.
sha256:8cfd3d9a788d5e1283839eb43a5b0bbd3b4d58ff7317f081c9912e8b811fd0a1
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
go 1.26 linux 24 · ubuntu · glibc 2.39 x64 go 1.26 go go
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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-01 |
Caso
HOW- Objetivo
- verify go.opentelemetry.io/otel/log.Kind in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0
- Símbolos
-
- go.opentelemetry.io/otel/log.Kind
- Ambiente
- go 1.26
- Criado
- 2026-09-01T05:28:45Z
Contrato
- Kind constants correctly represent distinct OpenTelemetry log value types
- Value.Kind returns KindEmpty for uninitialized zero-value log Value
- Value.Kind returns KindBool, KindFloat64, KindInt64, and KindString for scalar log values
- Value.Kind returns KindBytes, KindSlice, and KindMap for structured log values
- Kind.String returns canonical type name string for each Kind variant
- InspectValueKind and CategorizeAttributes inspect and categorize attributes by Kind
Arquivos
- PROMPT.md
- csx.json
- go.mod
- go.sum
- kind.go
- spec.json
- test/contract_test.go
Código-fonte
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/log.Kind in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/go.opentelemetry.io/otel/log@v0.19.0
Demonstrate these symbols/APIs:
- go.opentelemetry.io/otel/log.Kind
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.
{"case":{"caseId":"case:sha256:93ba5680a3251aee12aca7c0e982f1e54c485859e7ddc372947cd1d9f81ccde8","contract":["Kind constants correctly represent distinct OpenTelemetry log value types","Value.Kind returns KindEmpty for uninitialized zero-value log Value","Value.Kind returns KindBool, KindFloat64, KindInt64, and KindString for scalar log values","Value.Kind returns KindBytes, KindSlice, and KindMap for structured log values","Kind.String returns canonical type name string for each Kind variant","InspectValueKind and CategorizeAttributes inspect and categorize attributes by Kind"],"goal":"verify go.opentelemetry.io/otel/log.Kind in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0","kind":"HOW","packages":["pkg:golang/go.opentelemetry.io/otel/log@v0.19.0"],"schemaVersion":1,"symbols":["go.opentelemetry.io/otel/log.Kind"]},"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/log@v0.19.0"],"schemaVersion":1,"subject":"pkg:golang/go.opentelemetry.io/otel/log@v0.19.0","symbols":["go.opentelemetry.io/otel/log.Kind"],"verifierAdapter":"golang@1"}
module example.com/otel-log-kind
go 1.26.6
require go.opentelemetry.io/otel/log v0.19.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
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/trace v1.43.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/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.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
go.opentelemetry.io/otel/log v0.19.0 h1:KUZs/GOsw79TBBMfDWsXS+KZ4g2Ckzksd1ymzsIEbo4=
go.opentelemetry.io/otel/log v0.19.0/go.mod h1:5DQYeGmxVIr4n0/BcJvF4upsraHjg6vudJJpnkL6Ipk=
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
package sample
import (
"encoding/hex"
"fmt"
"strings"
"go.opentelemetry.io/otel/log"
)
// ValueKindSummary describes a structured log value and its Kind.
type ValueKindSummary struct {
Kind log.Kind
KindName string
Description string
}
// InspectValueKind inspects the Kind of a log.Value and returns a ValueKindSummary.
func InspectValueKind(v log.Value) ValueKindSummary {
k := v.Kind()
summary := ValueKindSummary{
Kind: k,
KindName: k.String(),
}
switch k {
case log.KindEmpty:
summary.Description = "empty"
case log.KindBool:
summary.Description = fmt.Sprintf("bool:%t", v.AsBool())
case log.KindFloat64:
summary.Description = fmt.Sprintf("float64:%g", v.AsFloat64())
case log.KindInt64:
summary.Description = fmt.Sprintf("int64:%d", v.AsInt64())
case log.KindString:
summary.Description = fmt.Sprintf("string:%s", v.AsString())
case log.KindBytes:
summary.Description = fmt.Sprintf("bytes:0x%s", hex.EncodeToString(v.AsBytes()))
case log.KindSlice:
items := v.AsSlice()
summary.Description = fmt.Sprintf("slice:len=%d", len(items))
case log.KindMap:
entries := v.AsMap()
summary.Description = fmt.Sprintf("map:len=%d", len(entries))
default:
summary.Description = fmt.Sprintf("unknown(%d)", int(k))
}
return summary
}
// CategorizeAttributes counts occurrences of each log.Kind in a slice of KeyValues.
func CategorizeAttributes(kvs []log.KeyValue) map[log.Kind]int {
counts := make(map[log.Kind]int)
for _, kv := range kvs {
counts[kv.Value.Kind()]++
}
return counts
}
// FormatAttributeByKind formats a KeyValue based on its value Kind.
func FormatAttributeByKind(kv log.KeyValue) string {
k := kv.Value.Kind()
switch k {
case log.KindEmpty:
return fmt.Sprintf("%s=<empty>", kv.Key)
case log.KindBool:
return fmt.Sprintf("%s=%t (bool)", kv.Key, kv.Value.AsBool())
case log.KindFloat64:
return fmt.Sprintf("%s=%.2f (float64)", kv.Key, kv.Value.AsFloat64())
case log.KindInt64:
return fmt.Sprintf("%s=%d (int64)", kv.Key, kv.Value.AsInt64())
case log.KindString:
return fmt.Sprintf("%s=%q (string)", kv.Key, kv.Value.AsString())
case log.KindBytes:
return fmt.Sprintf("%s=[%d bytes]", kv.Key, len(kv.Value.AsBytes()))
case log.KindSlice:
var elems []string
for _, elem := range kv.Value.AsSlice() {
elems = append(elems, InspectValueKind(elem).Description)
}
return fmt.Sprintf("%s=[%s] (slice)", kv.Key, strings.Join(elems, ", "))
case log.KindMap:
var pairs []string
for _, entry := range kv.Value.AsMap() {
pairs = append(pairs, FormatAttributeByKind(entry))
}
return fmt.Sprintf("%s={%s} (map)", kv.Key, strings.Join(pairs, ", "))
default:
return fmt.Sprintf("%s=<unknown kind %d>", kv.Key, int(k))
}
}
{
"schemaVersion": 1,
"goal": "verify go.opentelemetry.io/otel/log.Kind in pkg:golang/go.opentelemetry.io/otel/log@v0.19.0",
"kind": "HOW",
"packages": [
"pkg:golang/go.opentelemetry.io/otel/log@v0.19.0"
],
"symbols": [
"go.opentelemetry.io/otel/log.Kind"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
package test
import (
"testing"
sample "example.com/otel-log-kind"
"go.opentelemetry.io/otel/log"
)
func TestLogKindContract(t *testing.T) {
// 1. Kind constants correctly represent distinct OpenTelemetry log value types
kinds := []log.Kind{
log.KindEmpty,
log.KindBool,
log.KindFloat64,
log.KindInt64,
log.KindString,
log.KindBytes,
log.KindSlice,
log.KindMap,
}
seen := make(map[log.Kind]bool)
for _, k := range kinds {
if seen[k] {
t.Fatalf("duplicate Kind constant value: %d", k)
}
seen[k] = true
}
// 2. Value.Kind returns KindEmpty for uninitialized zero-value log Value
var emptyVal log.Value
if got := emptyVal.Kind(); got != log.KindEmpty {
t.Fatalf("expected zero Value.Kind() to be KindEmpty, got %v", got)
}
if !emptyVal.Empty() {
t.Fatal("expected zero Value.Empty() to be true")
}
// 3. Value.Kind returns KindBool, KindFloat64, KindInt64, and KindString for scalar log values
boolVal := log.BoolValue(true)
if got := boolVal.Kind(); got != log.KindBool {
t.Fatalf("expected KindBool, got %v", got)
}
if got := boolVal.AsBool(); got != true {
t.Fatalf("expected bool value true, got %v", got)
}
floatVal := log.Float64Value(2.718)
if got := floatVal.Kind(); got != log.KindFloat64 {
t.Fatalf("expected KindFloat64, got %v", got)
}
if got := floatVal.AsFloat64(); got != 2.718 {
t.Fatalf("expected float64 value 2.718, got %v", got)
}
intVal := log.Int64Value(42)
if got := intVal.Kind(); got != log.KindInt64 {
t.Fatalf("expected KindInt64, got %v", got)
}
if got := intVal.AsInt64(); got != 42 {
t.Fatalf("expected int64 value 42, got %v", got)
}
strVal := log.StringValue("status:ok")
if got := strVal.Kind(); got != log.KindString {
t.Fatalf("expected KindString, got %v", got)
}
if got := strVal.AsString(); got != "status:ok" {
t.Fatalf("expected string value %q, got %q", "status:ok", got)
}
// 4. Value.Kind returns KindBytes, KindSlice, and KindMap for structured log values
rawBytes := []byte{0xde, 0xad, 0xbe, 0xef}
bytesVal := log.BytesValue(rawBytes)
if got := bytesVal.Kind(); got != log.KindBytes {
t.Fatalf("expected KindBytes, got %v", got)
}
if got := bytesVal.AsBytes(); string(got) != string(rawBytes) {
t.Fatalf("bytes content mismatch")
}
sliceVal := log.SliceValue(log.Int64Value(1), log.Int64Value(2), log.Int64Value(3))
if got := sliceVal.Kind(); got != log.KindSlice {
t.Fatalf("expected KindSlice, got %v", got)
}
if got := len(sliceVal.AsSlice()); got != 3 {
t.Fatalf("expected slice length 3, got %d", got)
}
mapVal := log.MapValue(
log.String("service", "payment"),
log.Int("version", 2),
)
if got := mapVal.Kind(); got != log.KindMap {
t.Fatalf("expected KindMap, got %v", got)
}
if got := len(mapVal.AsMap()); got != 2 {
t.Fatalf("expected map length 2, got %d", got)
}
// 5. Kind.String returns canonical type name string for each Kind variant
expectedNames := map[log.Kind]string{
log.KindEmpty: "Empty",
log.KindBool: "Bool",
log.KindFloat64: "Float64",
log.KindInt64: "Int64",
log.KindString: "String",
log.KindBytes: "Bytes",
log.KindSlice: "Slice",
log.KindMap: "Map",
}
for k, expectedName := range expectedNames {
if got := k.String(); got != expectedName {
t.Fatalf("Kind.String() for %d mismatch: got %q, want %q", int(k), got, expectedName)
}
}
// 6. InspectValueKind and CategorizeAttributes inspect and categorize attributes by Kind
attrs := []log.KeyValue{
log.String("event", "user_login"),
log.Int64("user_id", 1001),
log.Bool("success", true),
log.Float64("latency_ms", 12.34),
log.Bytes("payload_hash", []byte{0x01, 0x02}),
log.Slice("tags", log.StringValue("auth"), log.StringValue("web")),
log.Map("metadata", log.String("ip", "127.0.0.1")),
log.Empty("optional_field"),
}
counts := sample.CategorizeAttributes(attrs)
for _, k := range kinds {
if counts[k] != 1 {
t.Fatalf("expected count 1 for kind %v (%s), got %d", k, k.String(), counts[k])
}
}
summary := sample.InspectValueKind(log.StringValue("test_val"))
if summary.Kind != log.KindString || summary.KindName != "String" || summary.Description != "string:test_val" {
t.Fatalf("unexpected InspectValueKind summary: %+v", summary)
}
formatted := sample.FormatAttributeByKind(log.Int64("retries", 3))
if formatted != "retries=3 (int64)" {
t.Fatalf("unexpected formatted attribute: %q", formatted)
}
}
Seeder de origem
anônimo