@@ -77,11 +77,7 @@ pub use view::*;
77
77
// #[cfg(not(feature = "spec_unstable_metrics_views"))]
78
78
// pub(crate) use view::*;
79
79
80
- use std:: collections:: hash_map:: DefaultHasher ;
81
- use std:: collections:: HashSet ;
82
- use std:: hash:: { Hash , Hasher } ;
83
-
84
- use opentelemetry:: KeyValue ;
80
+ use std:: hash:: Hash ;
85
81
86
82
/// Defines the window that an aggregation was calculated over.
87
83
#[ derive( Debug , Copy , Clone , Default , PartialEq , Eq , Hash ) ]
@@ -106,60 +102,6 @@ pub enum Temporality {
106
102
LowMemory ,
107
103
}
108
104
109
- /// A unique set of attributes that can be used as instrument identifiers.
110
- ///
111
- /// This must implement [Hash], [PartialEq], and [Eq] so it may be used as
112
- /// HashMap keys and other de-duplication methods.
113
- #[ derive( Clone , Default , Debug , PartialEq , Eq ) ]
114
- pub ( crate ) struct AttributeSet ( Vec < KeyValue > , u64 ) ;
115
-
116
- impl From < & [ KeyValue ] > for AttributeSet {
117
- fn from ( values : & [ KeyValue ] ) -> Self {
118
- let mut seen_keys = HashSet :: with_capacity ( values. len ( ) ) ;
119
- let vec = values
120
- . iter ( )
121
- . rev ( )
122
- . filter_map ( |kv| {
123
- if seen_keys. insert ( kv. key . clone ( ) ) {
124
- Some ( kv. clone ( ) )
125
- } else {
126
- None
127
- }
128
- } )
129
- . collect :: < Vec < _ > > ( ) ;
130
-
131
- AttributeSet :: new ( vec)
132
- }
133
- }
134
-
135
- fn calculate_hash ( values : & [ KeyValue ] ) -> u64 {
136
- let mut hasher = DefaultHasher :: new ( ) ;
137
- values. iter ( ) . fold ( & mut hasher, |mut hasher, item| {
138
- item. hash ( & mut hasher) ;
139
- hasher
140
- } ) ;
141
- hasher. finish ( )
142
- }
143
-
144
- impl AttributeSet {
145
- fn new ( mut values : Vec < KeyValue > ) -> Self {
146
- values. sort_unstable_by ( |a, b| a. key . cmp ( & b. key ) ) ;
147
- let hash = calculate_hash ( & values) ;
148
- AttributeSet ( values, hash)
149
- }
150
-
151
- /// Returns the underlying Vec of KeyValue pairs
152
- pub ( crate ) fn into_vec ( self ) -> Vec < KeyValue > {
153
- self . 0
154
- }
155
- }
156
-
157
- impl Hash for AttributeSet {
158
- fn hash < H : Hasher > ( & self , state : & mut H ) {
159
- state. write_u64 ( self . 1 )
160
- }
161
- }
162
-
163
105
#[ cfg( all( test, feature = "testing" ) ) ]
164
106
mod tests {
165
107
use self :: data:: { DataPoint , HistogramDataPoint , ScopeMetrics } ;
0 commit comments