Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metrics-util/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- New layer -- `Router` -- for routing specific metrics to target downstream recorders.
- `Registry::clear` allows clearing all metrics from the registry.

### Changed
- Updated all deprecated usages of `crossbeam_epoch::Atomic<T>::compare_and_set` to `compare_exchange`.
Expand Down
12 changes: 12 additions & 0 deletions metrics-util/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ where
(hash, shard)
}

/// Removes all metrics from the registry.
///
/// This operation is eventually consistent: metrics will be removed piecemeal, and this method
/// does not ensure that callers will see the registry as entirely empty at any given point.
pub fn clear(&self) {
for shard in &self.shards {
for subshard in shard {
subshard.write().clear();
}
}
}

/// Perform an operation on a given key.
///
/// The `op` function will be called for the handle under the given `key`.
Expand Down