Skip to content

Commit 3331bba

Browse files
authored
Merge branch 'main' into cijothomas/periodicreader-defaults
2 parents 45f1e36 + f513768 commit 3331bba

File tree

11 files changed

+57
-162
lines changed

11 files changed

+57
-162
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ reqwest = { version = "0.12", default-features = false }
3939
serde = { version = "1.0", default-features = false }
4040
serde_json = "1.0"
4141
temp-env = "0.3.6"
42-
thiserror = { version = "1", default-features = false }
42+
thiserror = { version = "2", default-features = false }
4343
tonic = { version = "0.12.3", default-features = false }
4444
tonic-build = "0.12"
4545
tokio = { version = "1", default-features = false }

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory contains some examples that should help you get start crates from
77
This example uses following crates from this repo:
88

99
- opentelemetry(log)
10-
- opentelemetry-appender-log
10+
- opentelemetry-appender-tracing
1111
- opentelemetry-stdout
1212

1313
Check this example if you want to understand *how to instrument logs using opentelemetry*.

examples/self-diagnostics/Cargo.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

examples/self-diagnostics/README.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

examples/self-diagnostics/src/main.rs

Lines changed: 0 additions & 73 deletions
This file was deleted.

opentelemetry-sdk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ rustdoc-args = ["--cfg", "docsrs"]
3535

3636
[dev-dependencies]
3737
criterion = { workspace = true, features = ["html_reports"] }
38+
rstest = "0.23.0"
3839
temp-env = { workspace = true }
3940

4041
[target.'cfg(not(target_os = "windows"))'.dev-dependencies]

opentelemetry-sdk/src/logs/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub type LogResult<T> = Result<T, LogError>;
1111
/// Errors returned by the log SDK.
1212
pub enum LogError {
1313
/// Export failed with the error returned by the exporter.
14-
#[error("Exporter {} encountered the following errors: {0}", .0.exporter_name())]
14+
#[error("Exporter {0} encountered the following errors: {name}", name = .0.exporter_name())]
1515
ExportFailed(Box<dyn ExportError>),
1616

1717
/// Export failed to finish after certain period and processor stopped the export.

opentelemetry-sdk/src/metrics/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub enum MetricError {
1818
#[error("Config error {0}")]
1919
Config(String),
2020
/// Fail to export metrics
21-
#[error("Metrics exporter {} failed with {0}", .0.exporter_name())]
21+
#[error("Metrics exporter {0} failed with {name}", name = .0.exporter_name())]
2222
ExportErr(Box<dyn ExportError>),
2323
/// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc.
2424
/// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics)

opentelemetry-sdk/src/resource/mod.rs

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ pub trait ResourceDetector {
263263

264264
#[cfg(test)]
265265
mod tests {
266+
use rstest::rstest;
267+
266268
use super::*;
267269

268270
#[test]
@@ -308,47 +310,55 @@ mod tests {
308310
assert_eq!(resource_a.merge(&resource_b), expected_resource);
309311
}
310312

311-
#[test]
312-
fn merge_resource_schema_url() {
313-
// if both resources contains key value pairs
314-
let test_cases = vec![
315-
(Some("http://schema/a"), None, Some("http://schema/a")),
316-
(Some("http://schema/a"), Some("http://schema/b"), None),
317-
(None, Some("http://schema/b"), Some("http://schema/b")),
318-
(
319-
Some("http://schema/a"),
320-
Some("http://schema/a"),
321-
Some("http://schema/a"),
322-
),
323-
(None, None, None),
324-
];
325-
326-
for (schema_url_a, schema_url_b, expected_schema_url) in test_cases.into_iter() {
327-
let resource_a = Resource::from_schema_url(
328-
vec![KeyValue::new("key", "")],
329-
schema_url_a.unwrap_or(""),
330-
);
331-
let resource_b = Resource::from_schema_url(
332-
vec![KeyValue::new("key", "")],
333-
schema_url_b.unwrap_or(""),
334-
);
335-
336-
let merged_resource = resource_a.merge(&resource_b);
337-
let result_schema_url = merged_resource.schema_url();
338-
339-
assert_eq!(
340-
result_schema_url.map(|s| s as &str),
341-
expected_schema_url,
342-
"Merging schema_url_a {:?} with schema_url_b {:?} did not yield expected result {:?}",
343-
schema_url_a, schema_url_b, expected_schema_url
344-
);
345-
}
346-
347-
// if only one resource contains key value pairs
348-
let resource = Resource::from_schema_url(vec![], "http://schema/a");
349-
let other_resource = Resource::new(vec![KeyValue::new("key", "")]);
313+
#[rstest]
314+
#[case(Some("http://schema/a"), None, Some("http://schema/a"))]
315+
#[case(Some("http://schema/a"), Some("http://schema/b"), None)]
316+
#[case(None, Some("http://schema/b"), Some("http://schema/b"))]
317+
#[case(
318+
Some("http://schema/a"),
319+
Some("http://schema/a"),
320+
Some("http://schema/a")
321+
)]
322+
#[case(None, None, None)]
323+
fn merge_resource_schema_url(
324+
#[case] schema_url_a: Option<&'static str>,
325+
#[case] schema_url_b: Option<&'static str>,
326+
#[case] expected_schema_url: Option<&'static str>,
327+
) {
328+
let resource_a =
329+
Resource::from_schema_url(vec![KeyValue::new("key", "")], schema_url_a.unwrap_or(""));
330+
let resource_b =
331+
Resource::from_schema_url(vec![KeyValue::new("key", "")], schema_url_b.unwrap_or(""));
332+
333+
let merged_resource = resource_a.merge(&resource_b);
334+
let result_schema_url = merged_resource.schema_url();
335+
336+
assert_eq!(
337+
result_schema_url.map(|s| s as &str),
338+
expected_schema_url,
339+
"Merging schema_url_a {:?} with schema_url_b {:?} did not yield expected result {:?}",
340+
schema_url_a,
341+
schema_url_b,
342+
expected_schema_url
343+
);
344+
}
350345

351-
assert_eq!(resource.merge(&other_resource).schema_url(), None);
346+
#[rstest]
347+
#[case(vec![], vec![KeyValue::new("key", "b")], "http://schema/a", None)]
348+
#[case(vec![KeyValue::new("key", "a")], vec![KeyValue::new("key", "b")], "http://schema/a", Some("http://schema/a"))]
349+
fn merge_resource_with_missing_attribtes(
350+
#[case] key_values_a: Vec<KeyValue>,
351+
#[case] key_values_b: Vec<KeyValue>,
352+
#[case] schema_url: &'static str,
353+
#[case] expected_schema_url: Option<&'static str>,
354+
) {
355+
let resource = Resource::from_schema_url(key_values_a, schema_url);
356+
let other_resource = Resource::new(key_values_b);
357+
358+
assert_eq!(
359+
resource.merge(&other_resource).schema_url(),
360+
expected_schema_url
361+
);
352362
}
353363

354364
#[test]

opentelemetry-sdk/src/trace/provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl Builder {
336336

337337
/// Specify the number of events to be recorded per span.
338338
pub fn with_max_events_per_span(mut self, max_events: u32) -> Self {
339-
self.config.span_limits.max_attributes_per_span = max_events;
339+
self.config.span_limits.max_events_per_span = max_events;
340340
self
341341
}
342342

0 commit comments

Comments
 (0)