Skip to content

Commit 0033f64

Browse files
authored
Merge branch 'main' into utpilla/Update-OTLP-Exporter-Trace-Pipeline
2 parents cc4a9c0 + ac741c2 commit 0033f64

File tree

22 files changed

+250
-425
lines changed

22 files changed

+250
-425
lines changed

.cspell.json

+7
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
"Cijo",
3333
"clippy",
3434
"codecov",
35+
"datapoint",
3536
"deque",
3637
"Dirkjan",
38+
"EPYC",
3739
"hasher",
3840
"isahc",
3941
"Isobel",
@@ -43,6 +45,9 @@
4345
"Lalit",
4446
"LIBCLANG",
4547
"msrv",
48+
"mykey",
49+
"myvalue",
50+
"nocapture",
4651
"Ochtman",
4752
"opentelemetry",
4853
"OTLP",
@@ -53,8 +58,10 @@
5358
"runtimes",
5459
"rustc",
5560
"shoppingcart",
61+
"struct",
5662
"Tescher",
5763
"tracerprovider",
64+
"updown",
5865
"Zhongyang",
5966
"zipkin"
6067
],

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ debug = 1
1919
async-std = "1.10"
2020
async-trait = "0.1"
2121
bytes = "1"
22-
env_logger = { version = "0.10", default-features = false } # env_logger requires a newer MSRV
2322
futures-core = "0.3"
2423
futures-executor = "0.3"
2524
futures-util = { version = "0.3", default-features = false }

examples/metrics-advanced/src/main.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use opentelemetry::global;
2-
use opentelemetry::metrics::Unit;
32
use opentelemetry::Key;
43
use opentelemetry::KeyValue;
54
use opentelemetry_sdk::metrics::{
@@ -15,7 +14,7 @@ fn init_meter_provider() -> opentelemetry_sdk::metrics::SdkMeterProvider {
1514
Some(
1615
Stream::new()
1716
.name("my_histogram_renamed")
18-
.unit(Unit::new("milliseconds")),
17+
.unit("milliseconds"),
1918
)
2019
} else {
2120
None
@@ -76,7 +75,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
7675
// using view.
7776
let histogram = meter
7877
.f64_histogram("my_histogram")
79-
.with_unit(Unit::new("ms"))
78+
.with_unit("ms")
8079
.with_description("My histogram example description")
8180
.init();
8281

@@ -114,7 +113,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
114113
// use a custom set of boundaries, and min/max values will not be recorded.
115114
let histogram2 = meter
116115
.f64_histogram("my_second_histogram")
117-
.with_unit(Unit::new("ms"))
116+
.with_unit("ms")
118117
.with_description("My histogram example description")
119118
.init();
120119

examples/metrics-basic/src/main.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use opentelemetry::global;
2-
use opentelemetry::metrics::Unit;
32
use opentelemetry::KeyValue;
43
use opentelemetry_sdk::metrics::{PeriodicReader, SdkMeterProvider};
54
use opentelemetry_sdk::{runtime, Resource};
@@ -47,7 +46,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
4746
let _observable_counter = meter
4847
.u64_observable_counter("my_observable_counter")
4948
.with_description("My observable counter example description")
50-
.with_unit(Unit::new("myunit"))
49+
.with_unit("myunit")
5150
.with_callback(|observer| {
5251
observer.observe(
5352
100,
@@ -75,7 +74,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
7574
let _observable_up_down_counter = meter
7675
.i64_observable_up_down_counter("my_observable_updown_counter")
7776
.with_description("My observable updown counter example description")
78-
.with_unit(Unit::new("myunit"))
77+
.with_unit("myunit")
7978
.with_callback(|observer| {
8079
observer.observe(
8180
100,
@@ -108,7 +107,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
108107
let gauge = meter
109108
.f64_gauge("my_gauge")
110109
.with_description("A gauge set to 1.0")
111-
.with_unit(Unit::new("myunit"))
110+
.with_unit("myunit")
112111
.init();
113112

114113
gauge.record(
@@ -123,7 +122,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
123122
let _observable_gauge = meter
124123
.f64_observable_gauge("my_observable_gauge")
125124
.with_description("An observable gauge set to 1.0")
126-
.with_unit(Unit::new("myunit"))
125+
.with_unit("myunit")
127126
.with_callback(|observer| {
128127
observer.observe(
129128
1.0,

opentelemetry-otlp/examples/basic-otlp-http/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use once_cell::sync::Lazy;
22
use opentelemetry::{
33
global,
4-
metrics::{MetricsError, Unit},
4+
metrics::MetricsError,
55
trace::{TraceContextExt, TraceError, Tracer, TracerProvider as _},
66
Key, KeyValue,
77
};
@@ -128,7 +128,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
128128
let counter = meter
129129
.u64_counter("test_counter")
130130
.with_description("a simple counter for demo purposes.")
131-
.with_unit(Unit::new("my_unit"))
131+
.with_unit("my_unit")
132132
.init();
133133
for _ in 0..10 {
134134
counter.add(1, &[KeyValue::new("test_key", "test_value")]);

opentelemetry-otlp/examples/basic-otlp/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use once_cell::sync::Lazy;
22
use opentelemetry::global;
33
use opentelemetry::logs::LogError;
4-
use opentelemetry::metrics::{MetricsError, Unit};
4+
use opentelemetry::metrics::MetricsError;
55
use opentelemetry::trace::{TraceError, TracerProvider};
66
use opentelemetry::{
77
trace::{TraceContextExt, Tracer},
@@ -129,7 +129,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
129129
let counter = meter
130130
.u64_counter("test_counter")
131131
.with_description("a simple counter for demo purposes.")
132-
.with_unit(Unit::new("my_unit"))
132+
.with_unit("my_unit")
133133
.init();
134134
for _ in 0..10 {
135135
counter.add(1, &[KeyValue::new("test_key", "test_value")]);

opentelemetry-proto/src/transform/metrics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub mod tonic {
148148
TonicMetric {
149149
name: metric.name.to_string(),
150150
description: metric.description.to_string(),
151-
unit: metric.unit.as_str().to_string(),
151+
unit: metric.unit.to_string(),
152152
metadata: vec![], // internal and currently unused
153153
data: metric.data.as_any().try_into().ok(),
154154
}

opentelemetry-sdk/CHANGELOG.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
must now use `.with_resource(RESOURCE::default())` to configure Resource on
1111
logger provider.
1212
- Removed dependency on `ordered-float`.
13+
- Removed `XrayIdGenerator`, which was marked deprecated since 0.21.3. Use
14+
[`opentelemetry-aws`](https://crates.io/crates/opentelemetry-aws), version
15+
0.10.0 or newer.
1316

1417
- **Breaking** [1726](https://github.com/open-telemetry/opentelemetry-rust/pull/1726)
1518
Update `LogProcessor::emit() method to take mutable reference to LogData. This is breaking
16-
change for LogProcessor developers. If the processor needs to invoke the exporter
17-
asynchronously, it should clone the data to ensure it can be safely processed without
19+
change for LogProcessor developers. If the processor needs to invoke the exporter
20+
asynchronously, it should clone the data to ensure it can be safely processed without
1821
lifetime issues. Any changes made to the log data before cloning in this method will be
1922
reflected in the next log processor in the chain, as well as to the exporter.
2023
- **Breaking** [1726](https://github.com/open-telemetry/opentelemetry-rust/pull/1726)
21-
Update `LogExporter::export() method to accept a batch of log data, which can be either a
22-
reference or owned `LogData`. If the exporter needs to process the log data
23-
asynchronously, it should clone the log data to ensure it can be safely processed without
24-
lifetime issues.
24+
Update `LogExporter::export() method to accept a batch of log data, which can be either a
25+
reference or owned`LogData`. If the exporter needs to process the log data
26+
asynchronously, it should clone the log data to ensure it can be safely processed without
27+
lifetime issues.
2528

2629
## v0.23.0
2730

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{any, borrow::Cow, fmt, time::SystemTime};
44

5-
use opentelemetry::{metrics::Unit, KeyValue};
5+
use opentelemetry::KeyValue;
66

77
use crate::{instrumentation::Scope, Resource};
88

@@ -38,7 +38,7 @@ pub struct Metric {
3838
/// The description of the instrument, which can be used in documentation.
3939
pub description: Cow<'static, str>,
4040
/// The unit in which the instrument reports.
41-
pub unit: Unit,
41+
pub unit: Cow<'static, str>,
4242
/// The aggregated data from an instrument.
4343
pub data: Box<dyn Aggregation>,
4444
}

opentelemetry-sdk/src/metrics/instrument.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{any::Any, borrow::Cow, collections::HashSet, hash::Hash, marker, sync:
33
use opentelemetry::{
44
metrics::{
55
AsyncInstrument, MetricsError, Result, SyncCounter, SyncGauge, SyncHistogram,
6-
SyncUpDownCounter, Unit,
6+
SyncUpDownCounter,
77
},
88
Key, KeyValue,
99
};
@@ -69,7 +69,7 @@ pub struct Instrument {
6969
/// The functional group of the instrument.
7070
pub kind: Option<InstrumentKind>,
7171
/// Unit is the unit of measurement recorded by the instrument.
72-
pub unit: Unit,
72+
pub unit: Cow<'static, str>,
7373
/// The instrumentation that created the instrument.
7474
pub scope: Scope,
7575
}
@@ -93,8 +93,8 @@ impl Instrument {
9393
}
9494

9595
/// Set the instrument unit.
96-
pub fn unit(mut self, unit: Unit) -> Self {
97-
self.unit = unit;
96+
pub fn unit(mut self, unit: impl Into<Cow<'static, str>>) -> Self {
97+
self.unit = unit.into();
9898
self
9999
}
100100

@@ -109,7 +109,7 @@ impl Instrument {
109109
self.name == ""
110110
&& self.description == ""
111111
&& self.kind.is_none()
112-
&& self.unit.as_str() == ""
112+
&& self.unit == ""
113113
&& self.scope == Scope::default()
114114
}
115115

@@ -134,7 +134,7 @@ impl Instrument {
134134
}
135135

136136
pub(crate) fn matches_unit(&self, other: &Instrument) -> bool {
137-
self.unit.as_str() == "" || self.unit == other.unit
137+
self.unit.is_empty() || self.unit.as_ref() == other.unit.as_ref()
138138
}
139139

140140
pub(crate) fn matches_scope(&self, other: &Instrument) -> bool {
@@ -171,7 +171,7 @@ pub struct Stream {
171171
/// Describes the purpose of the data.
172172
pub description: Cow<'static, str>,
173173
/// the unit of measurement recorded.
174-
pub unit: Unit,
174+
pub unit: Cow<'static, str>,
175175
/// Aggregation the stream uses for an instrument.
176176
pub aggregation: Option<Aggregation>,
177177
/// An allow-list of attribute keys that will be preserved for the stream.
@@ -201,8 +201,8 @@ impl Stream {
201201
}
202202

203203
/// Set the stream unit.
204-
pub fn unit(mut self, unit: Unit) -> Self {
205-
self.unit = unit;
204+
pub fn unit(mut self, unit: impl Into<Cow<'static, str>>) -> Self {
205+
self.unit = unit.into();
206206
self
207207
}
208208

@@ -233,7 +233,7 @@ pub(crate) struct InstrumentId {
233233
/// Defines the functional group of the instrument.
234234
pub(crate) kind: InstrumentKind,
235235
/// The unit of measurement recorded.
236-
pub(crate) unit: Unit,
236+
pub(crate) unit: Cow<'static, str>,
237237
/// Number is the underlying data type of the instrument.
238238
pub(crate) number: Cow<'static, str>,
239239
}
@@ -306,7 +306,7 @@ pub(crate) struct IdInner {
306306
/// The functional group of the instrument.
307307
kind: InstrumentKind,
308308
/// The unit of measurement recorded by the instrument.
309-
pub(crate) unit: Unit,
309+
pub(crate) unit: Cow<'static, str>,
310310
/// The instrumentation that created the instrument.
311311
scope: Scope,
312312
}
@@ -337,7 +337,7 @@ impl<T> Observable<T> {
337337
kind: InstrumentKind,
338338
name: Cow<'static, str>,
339339
description: Cow<'static, str>,
340-
unit: Unit,
340+
unit: Cow<'static, str>,
341341
measures: Vec<Arc<dyn Measure<T>>>,
342342
) -> Self {
343343
Self {

0 commit comments

Comments
 (0)