Exemplo
tracing-attributes 0.1.31: tracing_attributes.instrument
Amostra verificada para cargo tracing-attributes 0.1.31: tracing_attributes.instrument. O contrato rodou em rust 1 · linux alpine/x64 · docker e passou.
sha256:0d267f78451552ef9110e6e60ba3197e77b12f5b907e2951241cf37733fbf1db
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
linux x64 rust cargo
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-01 |
Caso
HOW- Objetivo
- verify pkg:cargo/tracing-attributes@0.1.31
- Símbolos
-
- tracing_attributes.instrument
- Criado
- 2026-11-01T17:37:12Z
Contrato
- #[instrument(name = "custom_add", skip(ignored), fields(extra = "tag"))] creates a span named "custom_add" when the annotated function is invoked under a tracing Subscriber
- Arguments not listed in skip(...) (a = 10, b = 32) and static fields(extra = "tag") are recorded on the span, while skipped arguments (ignored) are omitted
- The instrumented function executes normally and returns the expected sum (42)
Arquivos
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
Código-fonte
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "sample"
version = "0.1.0"
dependencies = [
"tracing",
"tracing-attributes",
]
[[package]]
name = "syn"
version = "2.0.119"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tracing"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
dependencies = [
"once_cell",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[package]
name = "sample"
version = "0.1.0"
edition = "2021"
[dependencies]
tracing-attributes = "=0.1.31"
tracing = "=0.1.44"
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:cargo/tracing-attributes@0.1.31
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/tracing-attributes@0.1.31
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:879647fd99dcacd9bd515da040cfcc71de3236def3198b7769756d70fcb045a5","contract":["#[instrument(name = \"custom_add\", skip(ignored), fields(extra = \"tag\"))] creates a span named \"custom_add\" when the annotated function is invoked under a tracing Subscriber","Arguments not listed in skip(...) (a = 10, b = 32) and static fields(extra = \"tag\") are recorded on the span, while skipped arguments (ignored) are omitted","The instrumented function executes normally and returns the expected sum (42)"],"goal":"verify pkg:cargo/tracing-attributes@0.1.31","kind":"HOW","packages":["pkg:cargo/tracing-attributes@0.1.31","pkg:cargo/tracing@0.1.44"],"schemaVersion":1,"symbols":["tracing_attributes.instrument"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","language":"rust","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/tracing-attributes@0.1.31","pkg:cargo/tracing@0.1.44"],"schemaVersion":1,"subject":"pkg:cargo/tracing-attributes@0.1.31","symbols":["tracing_attributes.instrument"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/tracing-attributes@0.1.31",
"kind": "HOW",
"packages": [
"pkg:cargo/tracing-attributes@0.1.31"
]
}
use std::sync::{Arc, Mutex};
use tracing::field::{Field, Visit};
use tracing::span::{Attributes, Id, Record};
use tracing::{Event, Metadata, Subscriber};
use tracing_attributes::instrument;
struct FieldVisitor(Vec<(String, String)>);
impl Visit for FieldVisitor {
fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) {
self.0
.push((field.name().to_string(), format!("{:?}", value)));
}
}
struct RecordingSubscriber {
spans: Arc<Mutex<Vec<(String, Vec<(String, String)>)>>>,
}
impl Subscriber for RecordingSubscriber {
fn enabled(&self, _metadata: &Metadata<'_>) -> bool {
true
}
fn new_span(&self, span: &Attributes<'_>) -> Id {
let mut visitor = FieldVisitor(Vec::new());
span.record(&mut visitor);
let mut guard = self.spans.lock().unwrap();
guard.push((span.metadata().name().to_string(), visitor.0));
Id::from_u64(guard.len() as u64)
}
fn record(&self, _span: &Id, _values: &Record<'_>) {}
fn record_follows_from(&self, _span: &Id, _follows: &Id) {}
fn event(&self, _event: &Event<'_>) {}
fn enter(&self, _span: &Id) {}
fn exit(&self, _span: &Id) {}
}
#[instrument(name = "custom_add", skip(ignored), fields(extra = "tag"))]
fn add_values(a: i32, b: i32, ignored: &str) -> i32 {
let _ = ignored;
a + b
}
fn main() {
let spans = Arc::new(Mutex::new(Vec::new()));
let subscriber = RecordingSubscriber {
spans: Arc::clone(&spans),
};
tracing::subscriber::with_default(subscriber, || {
let sum = add_values(10, 32, "secret");
assert_eq!(sum, 42);
});
let recorded = spans.lock().unwrap();
assert_eq!(recorded.len(), 1);
let (ref name, ref fields) = recorded[0];
assert_eq!(name, "custom_add");
assert!(fields.iter().any(|(k, v)| k == "a" && v == "10"));
assert!(fields.iter().any(|(k, v)| k == "b" && v == "32"));
assert!(fields.iter().any(|(k, v)| k == "extra" && v == "\"tag\""));
assert!(!fields.iter().any(|(k, _)| k == "ignored"));
}
Seeder de origem
anônimo