Skip to content

Commit 15cc939

Browse files
nits
1 parent bb57437 commit 15cc939

1 file changed

Lines changed: 27 additions & 30 deletions

File tree

runtime/src/lib.rs

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ stability_scope!(BETA {
140140
/// running tasks.
141141
pub trait Runner {
142142
/// Context defines the environment available to tasks.
143-
/// Example of possible services provided by the context include:
144-
/// - [Clock] for time-based operations
145-
/// - [Network] for network operations
146-
/// - [Storage] for storage operations
147143
type Context;
148144

149145
/// Start running a root task.
@@ -166,31 +162,7 @@ stability_scope!(BETA {
166162
pub attributes: Vec<(String, String)>,
167163
}
168164

169-
/// Interface for creating supervised child contexts and carrying context identity.
170-
///
171-
/// # Mental Model: Identity, Metrics, and Tracing
172-
///
173-
/// A context carries multiple pieces of observability state. They compose
174-
/// freely, but they do not all feed into the same sinks:
175-
///
176-
/// - `label` (set by [`Supervisor::child`]): prefix applied to metrics
177-
/// registered with [`Metrics::register`]. It also populates the `name`
178-
/// field of runtime-internal task metrics (`runtime_tasks_spawned`,
179-
/// `runtime_tasks_running`).
180-
/// - `attributes` (set by [`Supervisor::with_attribute`]): Prometheus label
181-
/// dimensions on metrics registered with [`Metrics::register`]. They are
182-
/// also emitted as OpenTelemetry attributes on the per-task tracing span
183-
/// when [`Tracing::with_span`] is enabled. Runtime task metrics ignore
184-
/// attributes to keep their cardinality bounded.
185-
/// - `span` (set by [`Tracing::with_span`]): wraps the next spawned task in
186-
/// a `tracing` span populated from the current `label` and `attributes`.
187-
/// It never touches metrics.
188-
///
189-
/// | Builder | Registered metric name | Registered metric labels | Runtime task metrics | Tracing span |
190-
/// | --- | :---: | :---: | :---: | :---: |
191-
/// | `child` | prefix | - | `name` | `name` field when `with_span` is set |
192-
/// | `with_attribute` | - | label dimension | - | OTel attribute when `with_span` is set |
193-
/// | `with_span` | - | - | - | enables span creation |
165+
/// Interface to track task hierarchy and identity.
194166
pub trait Supervisor: Send + Sync + 'static {
195167
/// Return the current label prefix and attributes.
196168
fn name(&self) -> Name;
@@ -404,7 +376,7 @@ stability_scope!(BETA {
404376
}
405377
}
406378

407-
/// Interface to configure task spans.
379+
/// Interface to register task traces.
408380
pub trait Tracing: Supervisor {
409381
/// Return a context that wraps the next spawned task in a `tracing` span.
410382
///
@@ -464,6 +436,31 @@ stability_scope!(BETA {
464436
fn encode(&self) -> String;
465437
}
466438

439+
/// Interface for both [`Tracing`] and [`Metrics`].
440+
///
441+
/// A context carries multiple pieces of observability state. They compose
442+
/// freely, but they do not all feed into the same sinks:
443+
///
444+
/// - `label` (set by [`Supervisor::child`]): prefix applied to metrics
445+
/// registered with [`Metrics::register`]. It also populates the `name`
446+
/// field of runtime-internal task metrics (`runtime_tasks_spawned`,
447+
/// `runtime_tasks_running`).
448+
/// - `attributes` (set by [`Supervisor::with_attribute`]): Prometheus label
449+
/// dimensions on metrics registered with [`Metrics::register`]. They are
450+
/// also emitted as OpenTelemetry attributes on the per-task tracing span
451+
/// when [`Tracing::with_span`] is enabled. Runtime task metrics ignore
452+
/// attributes to keep their cardinality bounded.
453+
/// - `span` (set by [`Tracing::with_span`]): wraps the next spawned task in
454+
/// a `tracing` span populated from the current `label` and `attributes`.
455+
/// It never touches metrics.
456+
///
457+
/// | Builder | Registered metric name | Registered metric labels | Runtime task metrics | Tracing span |
458+
/// | --- | :---: | :---: | :---: | :---: |
459+
/// | `child` | prefix | - | `name` | `name` field when `with_span` is set |
460+
/// | `with_attribute` | - | label dimension | - | OTel attribute when `with_span` is set |
461+
/// | `with_span` | - | - | - | enables span creation |
462+
pub trait Observer: Tracing + Metrics {}
463+
467464
/// A direct (non-keyed) rate limiter using the provided [governor::clock::Clock] `C`.
468465
///
469466
/// This is a convenience type alias for creating single-entity rate limiters.

0 commit comments

Comments
 (0)