Skip to content

Commit bc204d5

Browse files
authored
Merge branch 'main' into cijothomas/hashfloat
2 parents fcdb592 + 66b00d6 commit bc204d5

File tree

11 files changed

+73
-47
lines changed

11 files changed

+73
-47
lines changed

.github/workflows/ci.yml

+13
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ jobs:
138138
env:
139139
CARGO_INCREMENTAL: '0'
140140
RUSTDOCFLAGS: -Dwarnings
141+
semver: # This job uses the latest published crate as baseline for comparison.
142+
runs-on: ubuntu-latest
143+
name: semver
144+
steps:
145+
- uses: actions/checkout@v4
146+
with:
147+
submodules: true
148+
- name: Install stable
149+
uses: dtolnay/rust-toolchain@stable
150+
with:
151+
components: rustfmt
152+
- name: cargo-semver-checks
153+
uses: obi1kenobi/cargo-semver-checks-action@v2.3
141154
coverage:
142155
continue-on-error: true
143156
runs-on: ubuntu-latest

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ members = [
77
"examples/*",
88
"stress",
99
]
10-
# Any deleted crates with remaining README
11-
exclude = []
10+
# Crates temporarily excluded from the workspace
11+
exclude = ["opentelemetry-prometheus"]
1212
resolver = "2"
1313

1414
[profile.bench]

opentelemetry-sdk/src/metrics/data/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<T: fmt::Debug + Send + Sync + 'static> Aggregation for Sum<T> {
9797
pub struct DataPoint<T> {
9898
/// Attributes is the set of key value pairs that uniquely identify the
9999
/// time series.
100-
pub attributes: AttributeSet,
100+
pub attributes: Vec<KeyValue>,
101101
/// The time when the time series was started.
102102
pub start_time: Option<SystemTime>,
103103
/// The time when the time series was recorded.
@@ -143,7 +143,7 @@ impl<T: fmt::Debug + Send + Sync + 'static> Aggregation for Histogram<T> {
143143
#[derive(Debug)]
144144
pub struct HistogramDataPoint<T> {
145145
/// The set of key value pairs that uniquely identify the time series.
146-
pub attributes: AttributeSet,
146+
pub attributes: Vec<KeyValue>,
147147
/// The time when the time series was started.
148148
pub start_time: SystemTime,
149149
/// The time when the time series was recorded.

opentelemetry-sdk/src/metrics/internal/aggregate.rs

+10-22
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ mod tests {
226226
let (measure, agg) = AggregateBuilder::<u64>::new(None, None).last_value();
227227
let mut a = Gauge {
228228
data_points: vec![DataPoint {
229-
attributes: AttributeSet::from(&[KeyValue::new("a", 1)][..]),
229+
attributes: vec![KeyValue::new("a", 1)],
230230
start_time: Some(SystemTime::now()),
231231
time: Some(SystemTime::now()),
232232
value: 1u64,
@@ -241,10 +241,7 @@ mod tests {
241241
assert_eq!(count, 1);
242242
assert!(new_agg.is_none());
243243
assert_eq!(a.data_points.len(), 1);
244-
assert_eq!(
245-
a.data_points[0].attributes,
246-
AttributeSet::from(&new_attributes[..])
247-
);
244+
assert_eq!(a.data_points[0].attributes, new_attributes.to_vec());
248245
assert_eq!(a.data_points[0].value, 2);
249246
}
250247

@@ -256,14 +253,14 @@ mod tests {
256253
let mut a = Sum {
257254
data_points: vec![
258255
DataPoint {
259-
attributes: AttributeSet::from(&[KeyValue::new("a1", 1)][..]),
256+
attributes: vec![KeyValue::new("a1", 1)],
260257
start_time: Some(SystemTime::now()),
261258
time: Some(SystemTime::now()),
262259
value: 1u64,
263260
exemplars: vec![],
264261
},
265262
DataPoint {
266-
attributes: AttributeSet::from(&[KeyValue::new("a2", 2)][..]),
263+
attributes: vec![KeyValue::new("a2", 1)],
267264
start_time: Some(SystemTime::now()),
268265
time: Some(SystemTime::now()),
269266
value: 2u64,
@@ -287,10 +284,7 @@ mod tests {
287284
assert_eq!(a.temporality, temporality);
288285
assert!(a.is_monotonic);
289286
assert_eq!(a.data_points.len(), 1);
290-
assert_eq!(
291-
a.data_points[0].attributes,
292-
AttributeSet::from(&new_attributes[..])
293-
);
287+
assert_eq!(a.data_points[0].attributes, new_attributes.to_vec());
294288
assert_eq!(a.data_points[0].value, 3);
295289
}
296290
}
@@ -302,14 +296,14 @@ mod tests {
302296
let mut a = Sum {
303297
data_points: vec![
304298
DataPoint {
305-
attributes: AttributeSet::from(&[KeyValue::new("a1", 1)][..]),
299+
attributes: vec![KeyValue::new("a1", 1)],
306300
start_time: Some(SystemTime::now()),
307301
time: Some(SystemTime::now()),
308302
value: 1u64,
309303
exemplars: vec![],
310304
},
311305
DataPoint {
312-
attributes: AttributeSet::from(&[KeyValue::new("a2", 2)][..]),
306+
attributes: vec![KeyValue::new("a2", 1)],
313307
start_time: Some(SystemTime::now()),
314308
time: Some(SystemTime::now()),
315309
value: 2u64,
@@ -333,10 +327,7 @@ mod tests {
333327
assert_eq!(a.temporality, temporality);
334328
assert!(a.is_monotonic);
335329
assert_eq!(a.data_points.len(), 1);
336-
assert_eq!(
337-
a.data_points[0].attributes,
338-
AttributeSet::from(&new_attributes[..])
339-
);
330+
assert_eq!(a.data_points[0].attributes, new_attributes.to_vec());
340331
assert_eq!(a.data_points[0].value, 3);
341332
}
342333
}
@@ -348,7 +339,7 @@ mod tests {
348339
.explicit_bucket_histogram(vec![1.0], true, true);
349340
let mut a = Histogram {
350341
data_points: vec![HistogramDataPoint {
351-
attributes: AttributeSet::from(&[KeyValue::new("a2", 2)][..]),
342+
attributes: vec![KeyValue::new("a1", 1)],
352343
start_time: SystemTime::now(),
353344
time: SystemTime::now(),
354345
count: 2,
@@ -374,10 +365,7 @@ mod tests {
374365
assert!(new_agg.is_none());
375366
assert_eq!(a.temporality, temporality);
376367
assert_eq!(a.data_points.len(), 1);
377-
assert_eq!(
378-
a.data_points[0].attributes,
379-
AttributeSet::from(&new_attributes[..])
380-
);
368+
assert_eq!(a.data_points[0].attributes, new_attributes.to_vec());
381369
assert_eq!(a.data_points[0].count, 1);
382370
assert_eq!(a.data_points[0].bounds, vec![1.0]);
383371
assert_eq!(a.data_points[0].bucket_counts, vec![0, 1]);

opentelemetry-sdk/src/metrics/internal/histogram.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::{collections::HashMap, sync::Mutex, time::SystemTime};
22

33
use crate::metrics::data::{self, Aggregation, Temporality};
44
use crate::{attributes::AttributeSet, metrics::data::HistogramDataPoint};
5+
use opentelemetry::KeyValue;
56
use opentelemetry::{global, metrics::MetricsError};
67

78
use super::{
@@ -165,7 +166,10 @@ impl<T: Number<T>> Histogram<T> {
165166

166167
for (a, b) in values.drain() {
167168
h.data_points.push(HistogramDataPoint {
168-
attributes: a,
169+
attributes: a
170+
.iter()
171+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
172+
.collect(),
169173
start_time: start,
170174
time: t,
171175
count: b.count,
@@ -236,7 +240,10 @@ impl<T: Number<T>> Histogram<T> {
236240
// overload the system.
237241
for (a, b) in values.iter() {
238242
h.data_points.push(HistogramDataPoint {
239-
attributes: a.clone(),
243+
attributes: a
244+
.iter()
245+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
246+
.collect(),
240247
start_time: start,
241248
time: t,
242249
count: b.count,

opentelemetry-sdk/src/metrics/internal/last_value.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
};
66

77
use crate::{attributes::AttributeSet, metrics::data::DataPoint};
8-
use opentelemetry::{global, metrics::MetricsError};
8+
use opentelemetry::{global, metrics::MetricsError, KeyValue};
99

1010
use super::{
1111
aggregate::{is_under_cardinality_limit, STREAM_OVERFLOW_ATTRIBUTE_SET},
@@ -66,7 +66,10 @@ impl<T: Number<T>> LastValue<T> {
6666

6767
for (attrs, value) in values.drain() {
6868
dest.push(DataPoint {
69-
attributes: attrs,
69+
attributes: attrs
70+
.iter()
71+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
72+
.collect(),
7073
time: Some(value.timestamp),
7174
value: value.value,
7275
start_time: None,

opentelemetry-sdk/src/metrics/internal/sum.rs

+22-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::sync::atomic::{AtomicBool, Ordering};
2+
use std::vec;
23
use std::{
34
collections::{hash_map::Entry, HashMap},
45
sync::Mutex,
@@ -7,6 +8,7 @@ use std::{
78

89
use crate::attributes::AttributeSet;
910
use crate::metrics::data::{self, Aggregation, DataPoint, Temporality};
11+
use opentelemetry::KeyValue;
1012
use opentelemetry::{global, metrics::MetricsError};
1113

1214
use super::{
@@ -131,7 +133,7 @@ impl<T: Number<T>> Sum<T> {
131133
.swap(false, Ordering::AcqRel)
132134
{
133135
s_data.data_points.push(DataPoint {
134-
attributes: AttributeSet::default(),
136+
attributes: vec![],
135137
start_time: Some(prev_start),
136138
time: Some(t),
137139
value: self.value_map.no_attribute_value.get_and_reset_value(),
@@ -141,7 +143,10 @@ impl<T: Number<T>> Sum<T> {
141143

142144
for (attrs, value) in values.drain() {
143145
s_data.data_points.push(DataPoint {
144-
attributes: attrs,
146+
attributes: attrs
147+
.iter()
148+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
149+
.collect(),
145150
start_time: Some(prev_start),
146151
time: Some(t),
147152
value,
@@ -201,7 +206,7 @@ impl<T: Number<T>> Sum<T> {
201206
.load(Ordering::Acquire)
202207
{
203208
s_data.data_points.push(DataPoint {
204-
attributes: AttributeSet::default(),
209+
attributes: vec![],
205210
start_time: Some(prev_start),
206211
time: Some(t),
207212
value: self.value_map.no_attribute_value.get_value(),
@@ -215,7 +220,10 @@ impl<T: Number<T>> Sum<T> {
215220
// overload the system.
216221
for (attrs, value) in values.iter() {
217222
s_data.data_points.push(DataPoint {
218-
attributes: attrs.clone(),
223+
attributes: attrs
224+
.iter()
225+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
226+
.collect(),
219227
start_time: Some(prev_start),
220228
time: Some(t),
221229
value: *value,
@@ -297,7 +305,7 @@ impl<T: Number<T>> PrecomputedSum<T> {
297305
.swap(false, Ordering::AcqRel)
298306
{
299307
s_data.data_points.push(DataPoint {
300-
attributes: AttributeSet::default(),
308+
attributes: vec![],
301309
start_time: Some(prev_start),
302310
time: Some(t),
303311
value: self.value_map.no_attribute_value.get_and_reset_value(),
@@ -312,7 +320,10 @@ impl<T: Number<T>> PrecomputedSum<T> {
312320
new_reported.insert(attrs.clone(), value);
313321
}
314322
s_data.data_points.push(DataPoint {
315-
attributes: attrs.clone(),
323+
attributes: attrs
324+
.iter()
325+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
326+
.collect(),
316327
start_time: Some(prev_start),
317328
time: Some(t),
318329
value: delta,
@@ -379,7 +390,7 @@ impl<T: Number<T>> PrecomputedSum<T> {
379390
.load(Ordering::Acquire)
380391
{
381392
s_data.data_points.push(DataPoint {
382-
attributes: AttributeSet::default(),
393+
attributes: vec![],
383394
start_time: Some(prev_start),
384395
time: Some(t),
385396
value: self.value_map.no_attribute_value.get_value(),
@@ -394,7 +405,10 @@ impl<T: Number<T>> PrecomputedSum<T> {
394405
new_reported.insert(attrs.clone(), *value);
395406
}
396407
s_data.data_points.push(DataPoint {
397-
attributes: attrs.clone(),
408+
attributes: attrs
409+
.iter()
410+
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()))
411+
.collect(),
398412
start_time: Some(prev_start),
399413
time: Some(t),
400414
value: delta,

opentelemetry-sdk/src/metrics/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ mod tests {
166166
if datapoint
167167
.attributes
168168
.iter()
169-
.any(|(k, v)| k.as_str() == "key1" && v.as_str() == "value1")
169+
.any(|kv| kv.key.as_str() == "key1" && kv.value.as_str() == "value1")
170170
{
171171
data_point1 = Some(datapoint);
172172
}
@@ -184,7 +184,7 @@ mod tests {
184184
if datapoint
185185
.attributes
186186
.iter()
187-
.any(|(k, v)| k.as_str() == "key1" && v.as_str() == "value2")
187+
.any(|kv| kv.key.as_str() == "key1" && kv.value.as_str() == "value2")
188188
{
189189
data_point1 = Some(datapoint);
190190
}
@@ -1000,7 +1000,7 @@ mod tests {
10001000
datapoint
10011001
.attributes
10021002
.iter()
1003-
.any(|(k, v)| k.as_str() == key && v.as_str() == value)
1003+
.any(|kv| kv.key.as_str() == key && kv.value.as_str() == value)
10041004
})
10051005
}
10061006

opentelemetry-stdout/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Export telemetry signals to stdout.
2-
//! This exporter is designed for debugging and learning purposes. It is not
2+
//! <div class="warning">This exporter is designed for debugging and learning purposes. It is not
33
//! recommended for use in production environments. The output format might not be
44
//! exhaustive and is subject to change at any time.
5+
//! </div>
56
//!
67
//! # Examples
78
//!

opentelemetry-stdout/src/metrics/transform.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<T: Into<DataValue> + Copy> From<&data::Sum<T>> for Sum {
230230
#[derive(Serialize, Debug, Clone)]
231231
#[serde(rename_all = "camelCase")]
232232
struct DataPoint {
233-
attributes: AttributeSet,
233+
attributes: Vec<KeyValue>,
234234
#[serde(serialize_with = "as_opt_human_readable")]
235235
start_time: Option<SystemTime>,
236236
#[serde(serialize_with = "as_opt_human_readable")]
@@ -253,7 +253,7 @@ fn is_zero_u8(v: &u8) -> bool {
253253
impl<T: Into<DataValue> + Copy> From<&data::DataPoint<T>> for DataPoint {
254254
fn from(value: &data::DataPoint<T>) -> Self {
255255
DataPoint {
256-
attributes: AttributeSet::from(&value.attributes),
256+
attributes: value.attributes.iter().map(Into::into).collect(),
257257
start_time_unix_nano: value.start_time,
258258
time_unix_nano: value.time,
259259
start_time: value.start_time,
@@ -284,7 +284,7 @@ impl<T: Into<DataValue> + Copy> From<&data::Histogram<T>> for Histogram {
284284
#[derive(Serialize, Debug, Clone)]
285285
#[serde(rename_all = "camelCase")]
286286
struct HistogramDataPoint {
287-
attributes: AttributeSet,
287+
attributes: Vec<KeyValue>,
288288
#[serde(serialize_with = "as_unix_nano")]
289289
start_time_unix_nano: SystemTime,
290290
#[serde(serialize_with = "as_unix_nano")]
@@ -306,7 +306,7 @@ struct HistogramDataPoint {
306306
impl<T: Into<DataValue> + Copy> From<&data::HistogramDataPoint<T>> for HistogramDataPoint {
307307
fn from(value: &data::HistogramDataPoint<T>) -> Self {
308308
HistogramDataPoint {
309-
attributes: AttributeSet::from(&value.attributes),
309+
attributes: value.attributes.iter().map(Into::into).collect(),
310310
start_time_unix_nano: value.start_time,
311311
time_unix_nano: value.time,
312312
start_time: value.start_time,

scripts/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if rustup component add clippy; then
1616
"opentelemetry-appender-log"
1717
"opentelemetry-appender-tracing"
1818
"opentelemetry-otlp"
19-
"opentelemetry-prometheus"
19+
# "opentelemetry-prometheus" - temporarily exlude Prometheus from CI.
2020
"opentelemetry-proto"
2121
"opentelemetry-sdk"
2222
"opentelemetry-semantic-conventions"

0 commit comments

Comments
 (0)