Beispiel
tracing 0.1.41: tracing
Verifiziertes Beispiel für cargo tracing 0.1.41: tracing. Der Vertrag lief auf rust 1 · linux alpine/x64 · docker und bestand.
sha256:3f20bcdc9865e3868a09832c438b081a7ce7a0cdc248430a3c16c5ae55e2cc47
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-03 |
Fall
HOW- Ziel
- verify tracing in pkg:cargo/tracing@0.1.41
- Pakete
- Symbole
-
- tracing
- Erstellt
- 2026-11-03T03:46:41Z
Contract
- tracing::Span::current().is_disabled() returns true when no subscriber is active
- tracing::subscriber::with_default installs a custom tracing::Subscriber implementation for the closure scope
- tracing::span!(Level::INFO, "request", status = 200) creates a span and Span::enter() triggers Subscriber::enter and Subscriber::exit on drop
- tracing::info! dispatches an Event to Subscriber::event while tracing::trace! is filtered out by Subscriber::enabled
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 = "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",
]
[[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.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
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"
publish = false
[dependencies]
tracing = "=0.1.41"
[[test]]
name = "contract"
path = "test/contract.rs"
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 in pkg:cargo/tracing@0.1.41
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/tracing@0.1.41
Demonstrate these symbols/APIs:
- tracing
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:0862133fc42fac27251e4d92e1a981d2acdd9953d0f5779350f97949b9d2237a","contract":["tracing::Span::current().is_disabled() returns true when no subscriber is active","tracing::subscriber::with_default installs a custom tracing::Subscriber implementation for the closure scope","tracing::span!(Level::INFO, \"request\", status = 200) creates a span and Span::enter() triggers Subscriber::enter and Subscriber::exit on drop","tracing::info! dispatches an Event to Subscriber::event while tracing::trace! is filtered out by Subscriber::enabled"],"goal":"verify tracing in pkg:cargo/tracing@0.1.41","kind":"HOW","packages":["pkg:cargo/tracing@0.1.41"],"schemaVersion":1,"symbols":["tracing"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/tracing@0.1.41"],"schemaVersion":1,"subject":"pkg:cargo/tracing@0.1.41","symbols":["tracing"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify tracing in pkg:cargo/tracing@0.1.41",
"kind": "HOW",
"packages": [
"pkg:cargo/tracing@0.1.41"
],
"symbols": [
"tracing"
]
}
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
use std::sync::Arc;
use tracing::span::{Attributes, Id, Record};
use tracing::{Event, Level, Metadata, Subscriber};
pub struct CountingSubscriber {
next_id: AtomicU64,
pub span_count: AtomicUsize,
pub enter_count: AtomicUsize,
pub exit_count: AtomicUsize,
pub event_count: AtomicUsize,
}
impl CountingSubscriber {
pub fn new() -> Self {
Self {
next_id: AtomicU64::new(1),
span_count: AtomicUsize::new(0),
enter_count: AtomicUsize::new(0),
exit_count: AtomicUsize::new(0),
event_count: AtomicUsize::new(0),
}
}
}
impl Default for CountingSubscriber {
fn default() -> Self {
Self::new()
}
}
impl Subscriber for CountingSubscriber {
fn enabled(&self, metadata: &Metadata<'_>) -> bool {
*metadata.level() <= Level::DEBUG
}
fn new_span(&self, _span: &Attributes<'_>) -> Id {
self.span_count.fetch_add(1, Ordering::SeqCst);
let id = self.next_id.fetch_add(1, Ordering::SeqCst);
Id::from_u64(id)
}
fn record(&self, _span: &Id, _values: &Record<'_>) {}
fn record_follows_from(&self, _span: &Id, _follows: &Id) {}
fn event(&self, _event: &Event<'_>) {
self.event_count.fetch_add(1, Ordering::SeqCst);
}
fn enter(&self, _span: &Id) {
self.enter_count.fetch_add(1, Ordering::SeqCst);
}
fn exit(&self, _span: &Id) {
self.exit_count.fetch_add(1, Ordering::SeqCst);
}
}
pub fn run_verification() -> (usize, usize, usize, usize, bool) {
let subscriber = Arc::new(CountingSubscriber::new());
let disabled_outside = tracing::Span::current().is_disabled();
tracing::subscriber::with_default(subscriber.clone(), || {
let span = tracing::span!(Level::INFO, "request", status = 200);
let _guard = span.enter();
tracing::info!(target: "app", "handled request");
tracing::trace!("filtered out trace event");
});
(
subscriber.span_count.load(Ordering::SeqCst),
subscriber.enter_count.load(Ordering::SeqCst),
subscriber.exit_count.load(Ordering::SeqCst),
subscriber.event_count.load(Ordering::SeqCst),
disabled_outside,
)
}
use sample::run_verification;
fn main() {
let (spans, enters, exits, events, disabled_outside) = run_verification();
assert!(disabled_outside, "Span::current() must be disabled when no subscriber is set");
assert_eq!(spans, 1, "expected 1 span created");
assert_eq!(enters, 1, "expected 1 span entered");
assert_eq!(exits, 1, "expected 1 span exited");
assert_eq!(events, 1, "expected 1 event recorded (INFO allowed, TRACE filtered out)");
}
use sample::run_verification;
#[test]
fn contract_tracing_span_and_event_lifecycle() {
let (spans, enters, exits, events, disabled_outside) = run_verification();
assert!(disabled_outside);
assert_eq!(spans, 1);
assert_eq!(enters, 1);
assert_eq!(exits, 1);
assert_eq!(events, 1);
}
Ursprungs-Seeder
anonym