Skip to content

Commit 4b53e38

Browse files
authored
Merge branch 'main' into utpilla/Fix-metrics-dedup
2 parents dde78cb + 7a074b5 commit 4b53e38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1721
-568
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resolver = "2"
1616
debug = 1
1717

1818
[workspace.dependencies]
19-
async-std = "1.10"
19+
async-std = "1.13"
2020
async-trait = "0.1"
2121
bytes = "1"
2222
criterion = "0.5"
@@ -42,7 +42,7 @@ temp-env = "0.3.6"
4242
thiserror = { version = "1", default-features = false }
4343
tonic = { version = "0.12", default-features = false }
4444
tonic-build = "0.12"
45-
tokio = { version = "~1.38.0", default-features = false } #1.39 needs msrv bump to rustc 1.70
45+
tokio = { version = "1", default-features = false }
4646
tokio-stream = "0.1.1"
4747
tracing = { version = "0.1", default-features = false }
4848
tracing-core = { version = "0.1", default-features = false }

opentelemetry-appender-tracing/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## vNext
44

5+
- [2101](https://github.com/open-telemetry/opentelemetry-rust/pull/2101) The `log` events emitted via the `tracing` pipeline using the `log-tracing` crate no longer include the target metadata as attributes. Exporters or backends that rely on this attribute should now access the target directly from the `LogRecord::target` field.
6+
7+
58
## v0.25.0
69

710
- Update `opentelemetry` dependency version to 0.25

opentelemetry-appender-tracing/src/layer.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ impl<'a, LR: LogRecord> EventVisitor<'a, LR> {
4444

4545
#[cfg(feature = "experimental_metadata_attributes")]
4646
fn visit_experimental_metadata(&mut self, meta: &Metadata) {
47-
self.log_record.add_attribute(
48-
Key::new("log.target"),
49-
AnyValue::from(meta.target().to_owned()),
50-
);
51-
5247
if let Some(module_path) = meta.module_path() {
5348
self.log_record.add_attribute(
5449
Key::new("code.namespace"),
@@ -164,6 +159,7 @@ where
164159
) {
165160
#[cfg(feature = "experimental_metadata_attributes")]
166161
let normalized_meta = event.normalized_metadata();
162+
167163
#[cfg(feature = "experimental_metadata_attributes")]
168164
let meta = normalized_meta.as_ref().unwrap_or_else(|| event.metadata());
169165

@@ -269,7 +265,7 @@ mod tests {
269265
#[cfg(not(feature = "experimental_metadata_attributes"))]
270266
assert_eq!(log.record.attributes_iter().count(), 3);
271267
#[cfg(feature = "experimental_metadata_attributes")]
272-
assert_eq!(log.record.attributes_iter().count(), 8);
268+
assert_eq!(log.record.attributes_iter().count(), 7);
273269
assert!(attributes_contains(
274270
&log.record,
275271
&Key::new("event_id"),
@@ -307,7 +303,7 @@ mod tests {
307303
.collect();
308304
assert!(attributes_key.contains(&Key::new("code.filepath")));
309305
assert!(attributes_key.contains(&Key::new("code.lineno")));
310-
assert!(attributes_key.contains(&Key::new("log.target")));
306+
assert!(!attributes_key.contains(&Key::new("log.target")));
311307
}
312308
}
313309

@@ -381,7 +377,7 @@ mod tests {
381377
#[cfg(not(feature = "experimental_metadata_attributes"))]
382378
assert_eq!(log.record.attributes_iter().count(), 3);
383379
#[cfg(feature = "experimental_metadata_attributes")]
384-
assert_eq!(log.record.attributes_iter().count(), 8);
380+
assert_eq!(log.record.attributes_iter().count(), 7);
385381
assert!(attributes_contains(
386382
&log.record,
387383
&Key::new("event_id"),
@@ -419,7 +415,7 @@ mod tests {
419415
.collect();
420416
assert!(attributes_key.contains(&Key::new("code.filepath")));
421417
assert!(attributes_key.contains(&Key::new("code.lineno")));
422-
assert!(attributes_key.contains(&Key::new("log.target")));
418+
assert!(!attributes_key.contains(&Key::new("log.target")));
423419
}
424420
}
425421

@@ -461,7 +457,7 @@ mod tests {
461457

462458
// Attributes can be polluted when we don't use this feature.
463459
#[cfg(feature = "experimental_metadata_attributes")]
464-
assert_eq!(log.record.attributes_iter().count(), 5);
460+
assert_eq!(log.record.attributes_iter().count(), 4);
465461

466462
#[cfg(feature = "experimental_metadata_attributes")]
467463
{
@@ -485,7 +481,7 @@ mod tests {
485481
.collect();
486482
assert!(attributes_key.contains(&Key::new("code.filepath")));
487483
assert!(attributes_key.contains(&Key::new("code.lineno")));
488-
assert!(attributes_key.contains(&Key::new("log.target")));
484+
assert!(!attributes_key.contains(&Key::new("log.target")));
489485
}
490486
}
491487

@@ -558,7 +554,7 @@ mod tests {
558554

559555
// Attributes can be polluted when we don't use this feature.
560556
#[cfg(feature = "experimental_metadata_attributes")]
561-
assert_eq!(log.record.attributes_iter().count(), 5);
557+
assert_eq!(log.record.attributes_iter().count(), 4);
562558

563559
#[cfg(feature = "experimental_metadata_attributes")]
564560
{
@@ -582,7 +578,7 @@ mod tests {
582578
.collect();
583579
assert!(attributes_key.contains(&Key::new("code.filepath")));
584580
assert!(attributes_key.contains(&Key::new("code.lineno")));
585-
assert!(attributes_key.contains(&Key::new("log.target")));
581+
assert!(!attributes_key.contains(&Key::new("log.target")));
586582
}
587583
}
588584
}

opentelemetry-http/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ mod reqwest {
8383
}
8484
}
8585

86+
#[cfg(not(target_arch = "wasm32"))]
8687
#[async_trait]
8788
impl HttpClient for reqwest::blocking::Client {
8889
async fn send(&self, request: Request<Vec<u8>>) -> Result<Response<Bytes>, HttpError> {

opentelemetry-otlp/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The logrecord event-name is added as an attribute only if the feature flag
2121

2222
- Add "metrics", "logs" to default features. With this, default feature list is
2323
"trace", "metrics" and "logs".
24-
- `OtlpMetricPipeline.build()` no longer invoke the
24+
- **Breaking** `OtlpMetricPipeline.build()` no longer invoke the
2525
`global::set_meter_provider`. User who setup the pipeline must do it
2626
themselves using `global::set_meter_provider(meter_provider.clone());`.
2727
- Add `with_resource` on `OtlpLogPipeline`, replacing the `with_config` method.

opentelemetry-otlp/src/exporter/http/mod.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Default for HttpConfig {
7878
/// ```
7979
/// # #[cfg(feature="metrics")]
8080
/// use opentelemetry_sdk::metrics::reader::{
81-
/// DefaultAggregationSelector, DefaultTemporalitySelector,
81+
/// DefaultTemporalitySelector,
8282
/// };
8383
///
8484
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -91,7 +91,6 @@ impl Default for HttpConfig {
9191
/// let metrics_exporter = opentelemetry_otlp::new_exporter()
9292
/// .http()
9393
/// .build_metrics_exporter(
94-
/// Box::new(DefaultAggregationSelector::new()),
9594
/// Box::new(DefaultTemporalitySelector::new()),
9695
/// )?;
9796
///
@@ -252,7 +251,6 @@ impl HttpExporterBuilder {
252251
#[cfg(feature = "metrics")]
253252
pub fn build_metrics_exporter(
254253
mut self,
255-
aggregation_selector: Box<dyn opentelemetry_sdk::metrics::reader::AggregationSelector>,
256254
temporality_selector: Box<dyn opentelemetry_sdk::metrics::reader::TemporalitySelector>,
257255
) -> opentelemetry::metrics::Result<crate::MetricsExporter> {
258256
use crate::{
@@ -267,11 +265,7 @@ impl HttpExporterBuilder {
267265
OTEL_EXPORTER_OTLP_METRICS_HEADERS,
268266
)?;
269267

270-
Ok(crate::MetricsExporter::new(
271-
client,
272-
temporality_selector,
273-
aggregation_selector,
274-
))
268+
Ok(crate::MetricsExporter::new(client, temporality_selector))
275269
}
276270
}
277271

opentelemetry-otlp/src/exporter/tonic/mod.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn resolve_compression(
9797
/// ```no_run
9898
/// # #[cfg(feature="metrics")]
9999
/// use opentelemetry_sdk::metrics::reader::{
100-
/// DefaultAggregationSelector, DefaultTemporalitySelector,
100+
/// DefaultTemporalitySelector,
101101
/// };
102102
///
103103
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -110,7 +110,6 @@ fn resolve_compression(
110110
/// let metrics_exporter = opentelemetry_otlp::new_exporter()
111111
/// .tonic()
112112
/// .build_metrics_exporter(
113-
/// Box::new(DefaultAggregationSelector::new()),
114113
/// Box::new(DefaultTemporalitySelector::new()),
115114
/// )?;
116115
///
@@ -332,7 +331,6 @@ impl TonicExporterBuilder {
332331
#[cfg(feature = "metrics")]
333332
pub fn build_metrics_exporter(
334333
self,
335-
aggregation_selector: Box<dyn opentelemetry_sdk::metrics::reader::AggregationSelector>,
336334
temporality_selector: Box<dyn opentelemetry_sdk::metrics::reader::TemporalitySelector>,
337335
) -> opentelemetry::metrics::Result<crate::MetricsExporter> {
338336
use crate::MetricsExporter;
@@ -347,11 +345,7 @@ impl TonicExporterBuilder {
347345

348346
let client = TonicMetricsClient::new(channel, interceptor, compression);
349347

350-
Ok(MetricsExporter::new(
351-
client,
352-
temporality_selector,
353-
aggregation_selector,
354-
))
348+
Ok(MetricsExporter::new(client, temporality_selector))
355349
}
356350

357351
/// Build a new tonic span exporter

opentelemetry-otlp/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
//! use opentelemetry::{global, KeyValue, trace::Tracer};
127127
//! use opentelemetry_sdk::{trace::{self, RandomIdGenerator, Sampler}, Resource};
128128
//! # #[cfg(feature = "metrics")]
129-
//! use opentelemetry_sdk::metrics::reader::{DefaultAggregationSelector, DefaultTemporalitySelector};
129+
//! use opentelemetry_sdk::metrics::reader::DefaultTemporalitySelector;
130130
//! use opentelemetry_otlp::{Protocol, WithExportConfig, ExportConfig};
131131
//! use std::time::Duration;
132132
//! # #[cfg(feature = "grpc-tonic")]
@@ -184,7 +184,6 @@
184184
//! .with_resource(Resource::new(vec![KeyValue::new("service.name", "example")]))
185185
//! .with_period(Duration::from_secs(3))
186186
//! .with_timeout(Duration::from_secs(10))
187-
//! .with_aggregation_selector(DefaultAggregationSelector::new())
188187
//! .with_temporality_selector(DefaultTemporalitySelector::new())
189188
//! .build();
190189
//! # }

opentelemetry-otlp/src/metric.rs

+4-31
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ use opentelemetry_sdk::{
1414
metrics::{
1515
data::{ResourceMetrics, Temporality},
1616
exporter::PushMetricsExporter,
17-
reader::{
18-
AggregationSelector, DefaultAggregationSelector, DefaultTemporalitySelector,
19-
TemporalitySelector,
20-
},
21-
Aggregation, InstrumentKind, PeriodicReader, SdkMeterProvider,
17+
reader::{DefaultTemporalitySelector, TemporalitySelector},
18+
InstrumentKind, PeriodicReader, SdkMeterProvider,
2219
},
2320
runtime::Runtime,
2421
Resource,
@@ -50,7 +47,6 @@ impl OtlpPipeline {
5047
{
5148
OtlpMetricPipeline {
5249
rt,
53-
aggregator_selector: None,
5450
temporality_selector: None,
5551
exporter_pipeline: NoExporterConfig(()),
5652
resource: None,
@@ -82,21 +78,19 @@ impl MetricsExporterBuilder {
8278
pub fn build_metrics_exporter(
8379
self,
8480
temporality_selector: Box<dyn TemporalitySelector>,
85-
aggregation_selector: Box<dyn AggregationSelector>,
8681
) -> Result<MetricsExporter> {
8782
match self {
8883
#[cfg(feature = "grpc-tonic")]
8984
MetricsExporterBuilder::Tonic(builder) => {
90-
builder.build_metrics_exporter(aggregation_selector, temporality_selector)
85+
builder.build_metrics_exporter(temporality_selector)
9186
}
9287
#[cfg(feature = "http-proto")]
9388
MetricsExporterBuilder::Http(builder) => {
94-
builder.build_metrics_exporter(aggregation_selector, temporality_selector)
89+
builder.build_metrics_exporter(temporality_selector)
9590
}
9691
#[cfg(not(any(feature = "http-proto", feature = "grpc-tonic")))]
9792
MetricsExporterBuilder::Unconfigured => {
9893
drop(temporality_selector);
99-
drop(aggregation_selector);
10094
Err(opentelemetry::metrics::MetricsError::Other(
10195
"no configured metrics exporter, enable `http-proto` or `grpc-tonic` feature to configure a metrics exporter".into(),
10296
))
@@ -125,7 +119,6 @@ impl From<HttpExporterBuilder> for MetricsExporterBuilder {
125119
/// runtime.
126120
pub struct OtlpMetricPipeline<RT, EB> {
127121
rt: RT,
128-
aggregator_selector: Option<Box<dyn AggregationSelector>>,
129122
temporality_selector: Option<Box<dyn TemporalitySelector>>,
130123
exporter_pipeline: EB,
131124
resource: Option<Resource>,
@@ -178,14 +171,6 @@ where
178171
pub fn with_delta_temporality(self) -> Self {
179172
self.with_temporality_selector(DeltaTemporalitySelector)
180173
}
181-
182-
/// Build with the given aggregation selector
183-
pub fn with_aggregation_selector<T: AggregationSelector + 'static>(self, selector: T) -> Self {
184-
OtlpMetricPipeline {
185-
aggregator_selector: Some(Box::new(selector)),
186-
..self
187-
}
188-
}
189174
}
190175

191176
impl<RT> OtlpMetricPipeline<RT, NoExporterConfig>
@@ -200,7 +185,6 @@ where
200185
OtlpMetricPipeline {
201186
exporter_pipeline: pipeline.into(),
202187
rt: self.rt,
203-
aggregator_selector: self.aggregator_selector,
204188
temporality_selector: self.temporality_selector,
205189
resource: self.resource,
206190
period: self.period,
@@ -218,8 +202,6 @@ where
218202
let exporter = self.exporter_pipeline.build_metrics_exporter(
219203
self.temporality_selector
220204
.unwrap_or_else(|| Box::new(DefaultTemporalitySelector::new())),
221-
self.aggregator_selector
222-
.unwrap_or_else(|| Box::new(DefaultAggregationSelector::new())),
223205
)?;
224206

225207
let mut builder = PeriodicReader::builder(exporter, self.rt);
@@ -295,7 +277,6 @@ pub trait MetricsClient: fmt::Debug + Send + Sync + 'static {
295277
pub struct MetricsExporter {
296278
client: Box<dyn MetricsClient>,
297279
temporality_selector: Box<dyn TemporalitySelector>,
298-
aggregation_selector: Box<dyn AggregationSelector>,
299280
}
300281

301282
impl Debug for MetricsExporter {
@@ -310,12 +291,6 @@ impl TemporalitySelector for MetricsExporter {
310291
}
311292
}
312293

313-
impl AggregationSelector for MetricsExporter {
314-
fn aggregation(&self, kind: InstrumentKind) -> Aggregation {
315-
self.aggregation_selector.aggregation(kind)
316-
}
317-
}
318-
319294
#[async_trait]
320295
impl PushMetricsExporter for MetricsExporter {
321296
async fn export(&self, metrics: &mut ResourceMetrics) -> Result<()> {
@@ -337,12 +312,10 @@ impl MetricsExporter {
337312
pub fn new(
338313
client: impl MetricsClient,
339314
temporality_selector: Box<dyn TemporalitySelector>,
340-
aggregation_selector: Box<dyn AggregationSelector>,
341315
) -> MetricsExporter {
342316
MetricsExporter {
343317
client: Box::new(client),
344318
temporality_selector,
345-
aggregation_selector,
346319
}
347320
}
348321
}

opentelemetry-otlp/tests/integration_test/expected/serialized_traces.json

+6
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112
"value": {
113113
"intValue": "100"
114114
}
115+
},
116+
{
117+
"key": "number/int",
118+
"value": {
119+
"intValue": "100"
120+
}
115121
}
116122
],
117123
"droppedAttributesCount": 0

opentelemetry-proto/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## vNext
44

5+
- Fix JSON serialization of `metrics::Exemplar` and `trace::span::Link` [#2069](https://github.com/open-telemetry/opentelemetry-rust/pull/2069)
6+
57
## v0.25.0
68
- Update `opentelemetry` dependency version to 0.25
79
- Update `opentelemetry_sdk` dependency version to 0.25

opentelemetry-proto/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ name = "grpc_build"
2424
path = "tests/grpc_build.rs"
2525

2626
[[test]]
27-
name = "json_deserialize"
28-
path = "tests/json_deserialize.rs"
27+
name = "json_serde"
28+
path = "tests/json_serde.rs"
2929

3030

3131
[features]

0 commit comments

Comments
 (0)