Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update visibility of AttributeSet from pub to pub(crate) #2045

Merged
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
4 changes: 0 additions & 4 deletions opentelemetry-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ harness = false
name = "metrics_histogram"
harness = false

[[bench]]
name = "attribute_set"
harness = false

[[bench]]
name = "trace"
harness = false
Expand Down
40 changes: 0 additions & 40 deletions opentelemetry-sdk/benches/attribute_set.rs

This file was deleted.

27 changes: 3 additions & 24 deletions opentelemetry-sdk/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ use opentelemetry::{Key, KeyValue, Value};
/// This must implement [Hash], [PartialEq], and [Eq] so it may be used as
/// HashMap keys and other de-duplication methods.
#[derive(Clone, Default, Debug, PartialEq, Eq)]
pub struct AttributeSet(Vec<KeyValue>, u64);
pub(crate) struct AttributeSet(Vec<KeyValue>, u64);

impl From<&[KeyValue]> for AttributeSet {
fn from(values: &[KeyValue]) -> Self {
Expand Down Expand Up @@ -109,34 +109,13 @@ impl AttributeSet {
AttributeSet(values, hash)
}

/// Returns `true` if the set contains no elements.
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}

/// Retains only the attributes specified by the predicate.
pub fn retain<F>(&mut self, f: F)
where
F: Fn(&KeyValue) -> bool,
{
self.0.retain(|kv| f(kv));

// Recalculate the hash as elements are changed.
self.1 = calculate_hash(&self.0);
}

/// Iterate over key value pairs in the set
pub fn iter(&self) -> impl Iterator<Item = (&Key, &Value)> {
pub(crate) fn iter(&self) -> impl Iterator<Item = (&Key, &Value)> {
self.0.iter().map(|kv| (&kv.key, &kv.value))
}

/// Returns a slice of the key value pairs in the set
pub fn as_slice(&self) -> &[KeyValue] {
&self.0
}

/// Returns the underlying Vec of KeyValue pairs
pub fn into_vec(self) -> Vec<KeyValue> {
pub(crate) fn into_vec(self) -> Vec<KeyValue> {
self.0
}
}
Expand Down
Loading