Beispiel
tracing-attributes 0.1.31: tracing.instrument
Verifiziertes Beispiel für cargo tracing-attributes 0.1.31: tracing.instrument. Der Vertrag lief auf rust 1 · linux alpine/x64 · docker und bestand.
sha256:629406182e5701507f06fa2da6e81c2889a323335d134c5b59a95e7c9392b353
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux x64 cargo
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify tracing.instrument in pkg:cargo/tracing-attributes@0.1.31
- Pakete
- Symbole
-
- tracing.instrument
- Erstellt
- 2026-11-01T18:22:40Z
Contract
- #[tracing_attributes::instrument] defaults to Level::INFO with the function name as the span name and records function arguments
- #[tracing_attributes::instrument(name = "...", level = "debug", skip(...), fields(...), ret, err)] overrides the span name and level, omits skipped arguments, records custom fields, emits a return event on Ok, and emits an ERROR event on Err
Dateien
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- src/main.rs
- test/contract.rs
Quelltext
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[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-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-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[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"
[[test]]
name = "contract"
path = "test/contract.rs"
[dependencies]
tracing-attributes = "=0.1.31"
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 tracing.instrument in pkg:cargo/tracing-attributes@0.1.31
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/tracing-attributes@0.1.31
Demonstrate these symbols/APIs:
- tracing.instrument
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:5da9d40d18b7bbe1f6de73ac00ee7265c6266382b9f0a466f1d2c33ec2cbb36a","contract":["#[tracing_attributes::instrument] defaults to Level::INFO with the function name as the span name and records function arguments","#[tracing_attributes::instrument(name = \"...\", level = \"debug\", skip(...), fields(...), ret, err)] overrides the span name and level, omits skipped arguments, records custom fields, emits a return event on Ok, and emits an ERROR event on Err"],"goal":"verify tracing.instrument in pkg:cargo/tracing-attributes@0.1.31","kind":"HOW","packages":["pkg:cargo/tracing-attributes@0.1.31"],"schemaVersion":1,"symbols":["tracing.instrument"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/tracing-attributes@0.1.31"],"schemaVersion":1,"subject":"pkg:cargo/tracing-attributes@0.1.31","symbols":["tracing.instrument"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify tracing.instrument in pkg:cargo/tracing-attributes@0.1.31",
"kind": "HOW",
"packages": [
"pkg:cargo/tracing-attributes@0.1.31"
],
"symbols": [
"tracing.instrument"
]
}
extern crate self as tracing;
use std::cell::RefCell;
use tracing_attributes::instrument;
thread_local! {
static RECORDS: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) };
}
pub fn take_records() -> Vec<String> {
RECORDS.with(|r| std::mem::take(&mut *r.borrow_mut()))
}
pub fn push_record(entry: String) {
RECORDS.with(|r| r.borrow_mut().push(entry));
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Level(pub &'static str);
impl Level {
pub const INFO: Level = Level("INFO");
pub const DEBUG: Level = Level("DEBUG");
pub const TRACE: Level = Level("TRACE");
pub const WARN: Level = Level("WARN");
pub const ERROR: Level = Level("ERROR");
}
pub struct Span;
pub struct Entered;
impl Span {
pub fn none() -> Self {
Span
}
pub fn enter(&self) -> Entered {
Entered
}
pub fn record<T, V>(&self, _field: T, _value: V) -> &Self {
self
}
pub fn is_disabled(&self) -> bool {
false
}
}
pub mod field {
pub struct Empty;
pub fn debug<T: std::fmt::Debug>(t: T) -> String {
format!("{:?}", t)
}
pub fn display<T: std::fmt::Display>(t: T) -> String {
format!("{}", t)
}
}
#[macro_export]
macro_rules! level_enabled {
($lvl:expr) => {
true
};
}
#[macro_export]
macro_rules! if_log_enabled {
($lvl:expr, $if_block:block else $else_block:block) => {{
let _ = $lvl;
$if_block
}};
($lvl:expr, $if_block:block) => {{
let _ = $lvl;
$if_block
}};
}
#[macro_export]
macro_rules! span {
(target: $target:expr, $lvl:expr, $name:expr, value = $val:expr $(,)?) => {{
let target_val = $target;
let lvl_val: $crate::Level = $lvl;
$crate::push_record(format!(
"span:{}:{}:{}:value={:?}",
target_val, lvl_val.0, $name, $val
));
$crate::Span
}};
(target: $target:expr, $lvl:expr, $name:expr, input = $inp:expr, tag = $tag:expr $(,)?) => {{
let target_val = $target;
let lvl_val: $crate::Level = $lvl;
$crate::push_record(format!(
"span:{}:{}:{}:input={:?},tag={}",
target_val, lvl_val.0, $name, $inp, $tag
));
$crate::Span
}};
}
#[macro_export]
macro_rules! event {
(target: $target:expr, $lvl:expr, return = ?$ret:expr) => {{
let target_val = $target;
let lvl_val: $crate::Level = $lvl;
$crate::push_record(format!(
"event:{}:{}:return={:?}",
target_val, lvl_val.0, $ret
));
}};
(target: $target:expr, $lvl:expr, error = %$err:expr) => {{
let target_val = $target;
let lvl_val: $crate::Level = $lvl;
$crate::push_record(format!(
"event:{}:{}:error={}",
target_val, lvl_val.0, $err
));
}};
}
#[instrument]
pub fn add_one(value: i32) -> i32 {
value + 1
}
#[instrument(
name = "checked_double",
level = "debug",
skip(secret),
fields(tag = "v1"),
ret,
err
)]
pub fn checked_double(input: i32, secret: &str) -> Result<i32, &'static str> {
let _ = secret;
if input < 0 {
Err("negative_input")
} else {
Ok(input * 2)
}
}
pub fn verify_contract() {
let _ = take_records();
let out = add_one(41);
assert_eq!(out, 42);
let records = take_records();
assert_eq!(records, vec!["span:sample:INFO:add_one:value=41"]);
let ok_out = checked_double(21, "top_secret");
assert_eq!(ok_out, Ok(42));
let records = take_records();
assert_eq!(
records,
vec![
"span:sample:DEBUG:checked_double:input=21,tag=v1",
"event:sample:DEBUG:return=42"
]
);
let err_out = checked_double(-5, "top_secret");
assert_eq!(err_out, Err("negative_input"));
let records = take_records();
assert_eq!(
records,
vec![
"span:sample:DEBUG:checked_double:input=-5,tag=v1",
"event:sample:ERROR:error=negative_input"
]
);
}
fn main() {
sample::verify_contract();
}
#[test]
fn contract() {
sample::verify_contract();
}
Ursprungs-Seeder
anonym