iet-telemetry
Defines bounded operation identities and recording that compiles to a no-op by default.
iet-telemetrycontractsTelemetry contractsHow to use it
iet-telemetry records operation timings and lifecycle outcomes under a bounded, implementation-owned identity, and provides TelemetryConfig/Profile for exporter settings. Operation::record wraps a future, Stage wraps a blocking section, and Noop is a concrete no-op recorder; enabled() gates all work behind the recording feature and an accepting subscriber.
// examples/htmx-starter/crates/project-impl-timescale/src/service.rs
use Operation;
// Static vocabulary only: component/name/operation, never customer IDs or cache keys.
let result = new
.record
.await?;
- Use
.lifecycle(future)when you want start/finish/cancel logging even without metric recording; a droppedStagerecordscancelled. - With the
recordingfeature off,record/lifecycleforward the future directly: no clock read, span, or subscriber lookup.
How it works
Operation::record wraps the caller's future, and when recording is compiled in and enabled it opens a Stage that emits fw_operation_active, completion counters, and a duration histogram through tracing.
sequenceDiagram
participant C as "Caller"
participant O as "Operation"
participant E as "enabled"
participant S as "Stage"
participant T as "tracing events"
C->>O: "new component name operation"
C->>O: "record future"
O->>E: "recording_compiled"
alt enabled
O->>S: "start"
S->>T: "fw_operation_active"
O->>S: "finish result"
S->>T: "duration and outcome"
end
O-->>C: "Result"Core contract
This page is the crate reference. For the framework-wide runtime and trait model, read Architecture.
What it implements
- Core contracts and primitives; see the public API below.
What's inside
Modules
src/config.rssrc/lib.rs
Public API
(root)
pub fn enabled() -> bool- const
fn - struct
Operation pub fn record_sync<T, E>(self, action: impl FnOnce() -> Result<T, E>) -> Result<T, E>— Blocking operations keep concrete dispatch and cancellation/error accounting.- const
fn - const
fn pub fn start(self) -> Stage- struct
Noop - struct
Stage— Stack-owned timer; cancellation is recorded if dropped before completion. pub fn new(name: &'static str) -> Selfpub fn operation(identity: Operation) -> Selfpub fn finish<T, E>(mut self, result: &Result<T, E>)pub fn finish_outcome(mut self, outcome: &'static str)
config
- enum
HistogramConfig pub fn valid(&self) -> bool- enum
Profile - struct
TelemetryConfig pub fn profile(profile: Profile) -> Selfpub fn validate(&self) -> AppResult<()>
Impl map
Default for HistogramConfigFromStr for ProfileDefault for TelemetryConfigConfiguration for TelemetryConfigDrop for LifecycleCompletionDrop for Stage
Depends on
External crates: tracing
Cargo features
default— (no dependencies)recording— (no dependencies)
Used by
iet-auth-acliet-auth-acl-timescaleiet-auth-basiciet-auth-basic-timescaleiet-auth-login-htmx-axumiet-auth-profiles-timescaleiet-auth-rbaciet-auth-rbac-timescaleiet-auth-revocations-timescaleiet-auth-session-cacheiet-auth-session-jwtiet-auth-session-opaqueiet-auth-session-timescaleiet-cache-memoryiet-db-timescaleiet-http-axumiet-rate-limitiet-runtime-tokioiet-telemetry-otel
In this repository
examples/htmx-starter
Source: crates/core/iet-telemetry