From a5cfef8b2827b4679bd6c26e12064e12ceff4cbe Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Sun, 11 Feb 2024 18:33:58 -0800 Subject: [PATCH 01/13] more changes --- opentelemetry-sdk/src/resource/mod.rs | 162 ++++++++++++++------------ 1 file changed, 89 insertions(+), 73 deletions(-) diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index 79ce0122eb..9383873c71 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -34,13 +34,22 @@ use opentelemetry::{Key, KeyValue, Value}; use std::borrow::Cow; use std::collections::{hash_map, HashMap}; use std::ops::Deref; +use std::sync::Arc; use std::time::Duration; +/// Inner structure of `Resource` holding the actual data. +/// This structure is designed to be shared among `Resource` instances via `Arc`. +#[derive(Debug, Clone, PartialEq)] +struct ResourceInner { + attrs: HashMap, + schema_url: Option>, +} + /// An immutable representation of the entity producing telemetry as attributes. +/// Utilizes `Arc` for efficient sharing and cloning. #[derive(Clone, Debug, PartialEq)] pub struct Resource { - attrs: HashMap, - schema_url: Option>, + inner: Arc, } impl Default for Resource { @@ -58,10 +67,13 @@ impl Default for Resource { impl Resource { /// Creates an empty resource. + /// This is the basic constructor that initializes a resource with no attributes and no schema URL. pub fn empty() -> Self { - Self { - attrs: Default::default(), - schema_url: None, + Resource { + inner: Arc::new(ResourceInner { + attrs: HashMap::new(), + schema_url: None, + }), } } @@ -70,13 +82,17 @@ impl Resource { /// Values are de-duplicated by key, and the first key-value pair with a non-empty string value /// will be retained pub fn new>(kvs: T) -> Self { - let mut resource = Resource::empty(); - - for kv in kvs.into_iter() { - resource.attrs.insert(kv.key, kv.value); + let mut attrs = HashMap::new(); + for kv in kvs { + attrs.insert(kv.key, kv.value); } - resource + Resource { + inner: Arc::new(ResourceInner { + attrs, + schema_url: None, + }), + } } /// Create a new `Resource` from a key value pairs and [schema url]. @@ -93,7 +109,13 @@ impl Resource { S: Into>, { let mut resource = Self::new(kvs); - resource.schema_url = Some(schema_url.into()); + let new_inner = ResourceInner { + attrs: Arc::make_mut(&mut resource.inner).attrs.clone(), + schema_url: Some(schema_url.into()), + }; + + resource.inner = Arc::new(new_inner); + resource } @@ -105,8 +127,11 @@ impl Resource { for detector in detectors { let detected_res = detector.detect(timeout); for (key, value) in detected_res.into_iter() { - // using insert instead of merge to avoid clone. - resource.attrs.insert(key, value); + // This call ensures that if the Arc is not uniquely owned, + // the data is cloned before modification, preserving safety. + // If the Arc is uniquely owned, it simply returns a mutable reference to the data. + let inner = Arc::make_mut(&mut resource.inner); + inner.attrs.insert(key, value); } } @@ -129,66 +154,53 @@ impl Resource { /// /// [Schema url]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.9.0/specification/schemas/overview.md#schema-url pub fn merge>(&self, other: T) -> Self { - if self.attrs.is_empty() { - return other.clone(); + let mut combined_attrs = self.inner.attrs.clone(); + for (k, v) in other.inner.attrs.iter() { + combined_attrs.insert(k.clone(), v.clone()); } - if other.attrs.is_empty() { - return self.clone(); + // Resolve the schema URL according to the precedence rules + let combined_schema_url = match (&self.inner.schema_url, &other.inner.schema_url) { + // If both resources have a schema URL and it's the same, use it + (Some(url1), Some(url2)) if url1 == url2 => Some(url1.clone()), + // If `self` does not have a schema URL, use `other`'s (even if it's None) + (None, _) => other.inner.schema_url.clone(), + // In all other cases (including if `other` is None), use `self`'s schema URL + _ => self.inner.schema_url.clone(), + }; + + Resource { + inner: Arc::new(ResourceInner { + attrs: combined_attrs, + schema_url: combined_schema_url, + }), } - - let mut resource = Resource::empty(); - - // attrs from self take the less priority, even when the new value is empty. - for (k, v) in self.attrs.iter() { - resource.attrs.insert(k.clone(), v.clone()); - } - for (k, v) in other.attrs.iter() { - resource.attrs.insert(k.clone(), v.clone()); - } - - if self.schema_url == other.schema_url { - resource.schema_url = self.schema_url.clone(); - } else if self.schema_url.is_none() { - // if the other resource has schema url, use it. - if other.schema_url.is_some() { - resource.schema_url = other.schema_url.clone(); - } - // else empty schema url. - } else { - // if self has schema url, use it. - if other.schema_url.is_none() { - resource.schema_url = self.schema_url.clone(); - } - } - - resource } /// Return the [schema url] of the resource. If the resource does not have a schema url, return `None`. /// /// [schema url]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.9.0/specification/schemas/overview.md#schema-url pub fn schema_url(&self) -> Option<&str> { - self.schema_url.as_ref().map(|s| s.as_ref()) + self.inner.schema_url.as_ref().map(|s| s.as_ref()) } /// Returns the number of attributes for this resource pub fn len(&self) -> usize { - self.attrs.len() + self.inner.attrs.len() } /// Returns `true` if the resource contains no attributes. pub fn is_empty(&self) -> bool { - self.attrs.is_empty() + self.inner.attrs.is_empty() } /// Gets an iterator over the attributes of this resource, sorted by key. pub fn iter(&self) -> Iter<'_> { - self.into_iter() + Iter(self.inner.attrs.iter()) } /// Retrieve the value from resource associate with given key. pub fn get(&self, key: Key) -> Option { - self.attrs.get(&key).cloned() + self.inner.attrs.get(&key).cloned() } } @@ -209,8 +221,11 @@ impl IntoIterator for Resource { type IntoIter = IntoIter; fn into_iter(self) -> Self::IntoIter { - IntoIter(self.attrs.into_iter()) - } + // Extract the HashMap from the Arc safely upon consuming the Resource + let inner = Arc::try_unwrap(self.inner) + .ok() + .expect("Resource into_iter failed due to multiple Arc references"); + IntoIter(inner.attrs.into_iter()) } } /// An iterator over the entries of a `Resource`. @@ -230,7 +245,7 @@ impl<'a> IntoIterator for &'a Resource { type IntoIter = Iter<'a>; fn into_iter(self) -> Self::IntoIter { - Iter(self.attrs.iter()) + Iter(self.inner.attrs.iter()) } } @@ -264,13 +279,10 @@ mod tests { let mut expected_attrs = HashMap::new(); expected_attrs.insert(Key::new("a"), Value::from("final")); - assert_eq!( - Resource::new(args_with_dupe_keys), - Resource { - attrs: expected_attrs, - schema_url: None, - } - ); + let resource = Resource::new(args_with_dupe_keys); + let resource_inner = Arc::try_unwrap(resource.inner).expect("Failed to unwrap Arc"); + assert_eq!(resource_inner.attrs, expected_attrs); + assert_eq!(resource_inner.schema_url, None); } #[test] @@ -293,13 +305,14 @@ mod tests { expected_attrs.insert(Key::new("c"), Value::from("c-value")); expected_attrs.insert(Key::new("d"), Value::from("")); - assert_eq!( - resource_a.merge(&resource_b), - Resource { + let expected_resource = Resource { + inner: Arc::new(ResourceInner { attrs: expected_attrs, - schema_url: None, - } - ); + schema_url: None, // Assuming schema_url handling if needed + }), + }; + + assert_eq!(resource_a.merge(&resource_b), expected_resource); } #[test] @@ -317,16 +330,18 @@ mod tests { (None, None, None), ]; - for (schema_url, other_schema_url, expect_schema_url) in test_cases.into_iter() { - let mut resource = Resource::new(vec![KeyValue::new("key", "")]); - resource.schema_url = schema_url.map(Into::into); + for (schema_url_a, schema_url_b, expected_schema_url) in test_cases.into_iter() { + let resource_a = Resource::from_schema_url(vec![KeyValue::new("key", "")], schema_url_a.unwrap_or("")); + let resource_b = Resource::from_schema_url(vec![KeyValue::new("key", "")], schema_url_b.unwrap_or("")); - let mut other_resource = Resource::new(vec![KeyValue::new("key", "")]); - other_resource.schema_url = other_schema_url.map(Into::into); + let merged_resource = resource_a.merge(&resource_b); + let result_schema_url = merged_resource.schema_url(); assert_eq!( - resource.merge(&other_resource).schema_url, - expect_schema_url.map(Into::into) + result_schema_url.map(|s| s as &str), + expected_schema_url, + "Merging schema_url_a {:?} with schema_url_b {:?} did not yield expected result {:?}", + schema_url_a, schema_url_b, expected_schema_url ); } @@ -334,7 +349,7 @@ mod tests { let resource = Resource::from_schema_url(vec![], "http://schema/a"); let other_resource = Resource::new(vec![KeyValue::new("key", "")]); - assert_eq!(resource.merge(&other_resource).schema_url, None); + assert_eq!(resource.merge(&other_resource).schema_url(), None); } #[test] @@ -366,3 +381,4 @@ mod tests { ) } } + \ No newline at end of file From 14eaea09492959cb73f01a51f8bc0f1aca798c50 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Sun, 11 Feb 2024 21:23:42 -0800 Subject: [PATCH 02/13] remove owned IntoIter for Resource --- opentelemetry-sdk/src/resource/mod.rs | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index 9383873c71..50ee280ce6 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -131,7 +131,7 @@ impl Resource { // the data is cloned before modification, preserving safety. // If the Arc is uniquely owned, it simply returns a mutable reference to the data. let inner = Arc::make_mut(&mut resource.inner); - inner.attrs.insert(key, value); + inner.attrs.insert(Key::new(key.clone()), Value::from(value.clone())); } } @@ -204,29 +204,6 @@ impl Resource { } } -/// An owned iterator over the entries of a `Resource`. -#[derive(Debug)] -pub struct IntoIter(hash_map::IntoIter); - -impl Iterator for IntoIter { - type Item = (Key, Value); - - fn next(&mut self) -> Option { - self.0.next() - } -} - -impl IntoIterator for Resource { - type Item = (Key, Value); - type IntoIter = IntoIter; - - fn into_iter(self) -> Self::IntoIter { - // Extract the HashMap from the Arc safely upon consuming the Resource - let inner = Arc::try_unwrap(self.inner) - .ok() - .expect("Resource into_iter failed due to multiple Arc references"); - IntoIter(inner.attrs.into_iter()) } -} /// An iterator over the entries of a `Resource`. #[derive(Debug)] From ce05eea965273ae5340e56be31fa83bae220080c Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 12 Feb 2024 00:23:22 -0800 Subject: [PATCH 03/13] fix unit test --- opentelemetry-sdk/src/resource/mod.rs | 48 +++++++++++++++++++-------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index 50ee280ce6..32cefcd1a7 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -108,10 +108,17 @@ impl Resource { KV: IntoIterator, S: Into>, { + let schema_url_str = schema_url.into(); + let normalized_schema_url = if schema_url_str.is_empty() { + None + } else { + Some(schema_url_str) + }; + let mut resource = Self::new(kvs); let new_inner = ResourceInner { attrs: Arc::make_mut(&mut resource.inner).attrs.clone(), - schema_url: Some(schema_url.into()), + schema_url: normalized_schema_url, }; resource.inner = Arc::new(new_inner); @@ -127,11 +134,13 @@ impl Resource { for detector in detectors { let detected_res = detector.detect(timeout); for (key, value) in detected_res.into_iter() { - // This call ensures that if the Arc is not uniquely owned, + // This call ensures that if the Arc is not uniquely owned, // the data is cloned before modification, preserving safety. // If the Arc is uniquely owned, it simply returns a mutable reference to the data. let inner = Arc::make_mut(&mut resource.inner); - inner.attrs.insert(Key::new(key.clone()), Value::from(value.clone())); + inner + .attrs + .insert(Key::new(key.clone()), value.clone()); } } @@ -154,6 +163,12 @@ impl Resource { /// /// [Schema url]: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.9.0/specification/schemas/overview.md#schema-url pub fn merge>(&self, other: T) -> Self { + if self.is_empty() { + return other.clone(); + } + if other.is_empty() { + return self.clone(); + } let mut combined_attrs = self.inner.attrs.clone(); for (k, v) in other.inner.attrs.iter() { combined_attrs.insert(k.clone(), v.clone()); @@ -162,12 +177,15 @@ impl Resource { let combined_schema_url = match (&self.inner.schema_url, &other.inner.schema_url) { // If both resources have a schema URL and it's the same, use it (Some(url1), Some(url2)) if url1 == url2 => Some(url1.clone()), - // If `self` does not have a schema URL, use `other`'s (even if it's None) - (None, _) => other.inner.schema_url.clone(), - // In all other cases (including if `other` is None), use `self`'s schema URL - _ => self.inner.schema_url.clone(), + // If both resources have a schema URL but they are not the same, the schema URL will be empty + (Some(_), Some(_)) => None, + // If this resource does not have a schema URL, and the other resource has a schema URL, it will be used + (None, Some(url)) => Some(url.clone()), + // If this resource has a schema URL, it will be used (covers case 1 and any other cases where `self` has a schema URL) + (Some(url), _) => Some(url.clone()), + // If both resources do not have a schema URL, the schema URL will be empty + (None, None) => None, }; - Resource { inner: Arc::new(ResourceInner { attrs: combined_attrs, @@ -204,7 +222,6 @@ impl Resource { } } - /// An iterator over the entries of a `Resource`. #[derive(Debug)] pub struct Iter<'a>(hash_map::Iter<'a, Key, Value>); @@ -288,7 +305,7 @@ mod tests { schema_url: None, // Assuming schema_url handling if needed }), }; - + assert_eq!(resource_a.merge(&resource_b), expected_resource); } @@ -308,8 +325,14 @@ mod tests { ]; for (schema_url_a, schema_url_b, expected_schema_url) in test_cases.into_iter() { - let resource_a = Resource::from_schema_url(vec![KeyValue::new("key", "")], schema_url_a.unwrap_or("")); - let resource_b = Resource::from_schema_url(vec![KeyValue::new("key", "")], schema_url_b.unwrap_or("")); + let resource_a = Resource::from_schema_url( + vec![KeyValue::new("key", "")], + schema_url_a.unwrap_or(""), + ); + let resource_b = Resource::from_schema_url( + vec![KeyValue::new("key", "")], + schema_url_b.unwrap_or(""), + ); let merged_resource = resource_a.merge(&resource_b); let result_schema_url = merged_resource.schema_url(); @@ -358,4 +381,3 @@ mod tests { ) } } - \ No newline at end of file From 74302eff649c1915223deeb7b439e903889b1f8f Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 12 Feb 2024 08:10:04 -0800 Subject: [PATCH 04/13] fix lint --- opentelemetry-sdk/src/resource/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index 32cefcd1a7..1898418e76 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -138,9 +138,7 @@ impl Resource { // the data is cloned before modification, preserving safety. // If the Arc is uniquely owned, it simply returns a mutable reference to the data. let inner = Arc::make_mut(&mut resource.inner); - inner - .attrs - .insert(Key::new(key.clone()), value.clone()); + inner.attrs.insert(Key::new(key.clone()), value.clone()); } } From bf58b9d54265aa53919dfb94a2f83880d310bf67 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 12 Feb 2024 08:55:01 -0800 Subject: [PATCH 05/13] fix clippy --- opentelemetry-otlp/tests/integration_test/src/asserter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-otlp/tests/integration_test/src/asserter.rs b/opentelemetry-otlp/tests/integration_test/src/asserter.rs index 82ed94608d..47af933a83 100644 --- a/opentelemetry-otlp/tests/integration_test/src/asserter.rs +++ b/opentelemetry-otlp/tests/integration_test/src/asserter.rs @@ -19,7 +19,7 @@ impl TraceAsserter { self.assert_resource_span_eq(&self.results, &self.expected); } - fn assert_resource_span_eq(&self, results: &Vec, expected: &Vec) { + fn assert_resource_span_eq(&self, results: &[ResourceSpans], expected: &[ResourceSpans]) { let mut results_spans = Vec::new(); let mut expected_spans = Vec::new(); From 8fd9f7b82ed7bbe9357ce859d15cf457be854d70 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Mon, 12 Feb 2024 22:35:41 +0000 Subject: [PATCH 06/13] add resource attributes to benchmark --- opentelemetry-sdk/benches/log.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index 9b66ad0447..7a03ac520e 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -7,10 +7,11 @@ use criterion::{criterion_group, criterion_main, Criterion}; use opentelemetry::logs::{AnyValue, LogRecord, LogResult, Logger, LoggerProvider as _, Severity}; use opentelemetry::trace::Tracer; use opentelemetry::trace::TracerProvider as _; -use opentelemetry::Key; +use opentelemetry::{Key, KeyValue}; use opentelemetry_sdk::export::logs::{LogData, LogExporter}; -use opentelemetry_sdk::logs::LoggerProvider; +use opentelemetry_sdk::logs::{Config, LoggerProvider}; use opentelemetry_sdk::trace::{config, Sampler, TracerProvider}; +use opentelemetry_sdk::Resource; #[derive(Debug)] struct VoidExporter; @@ -27,6 +28,12 @@ fn log_benchmark_group(c: &mut Criterion, name: &str, f: F) group.bench_function("no-context", |b| { let provider = LoggerProvider::builder() + .with_config(Config::default().with_resource(Resource::new(vec![ + KeyValue::new("service.name", "my-service"), + KeyValue::new("service.version", "1.0.0"), + KeyValue::new("service.environment", "production"), + KeyValue::new("service.instance.id", "1234"), + ]))) .with_simple_exporter(VoidExporter) .build(); @@ -38,6 +45,12 @@ fn log_benchmark_group(c: &mut Criterion, name: &str, f: F) group.bench_function("with-context", |b| { let provider = LoggerProvider::builder() .with_simple_exporter(VoidExporter) + .with_config(Config::default().with_resource(Resource::new(vec![ + KeyValue::new("service.name", "my-service"), + KeyValue::new("service.version", "1.0.0"), + KeyValue::new("service.environment", "production"), + KeyValue::new("service.instance.id", "1234"), + ]))) .build(); let logger = provider.logger("with-context"); From 9168ec9a636348471a5bdcb30f15db63de7c00e5 Mon Sep 17 00:00:00 2001 From: Lalit Kumar Bhasin Date: Tue, 13 Feb 2024 11:05:52 -0800 Subject: [PATCH 07/13] move make_mut before loop --- opentelemetry-sdk/src/resource/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index 1898418e76..c005f4d0df 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -133,11 +133,11 @@ impl Resource { let mut resource = Resource::empty(); for detector in detectors { let detected_res = detector.detect(timeout); + // This call ensures that if the Arc is not uniquely owned, + // the data is cloned before modification, preserving safety. + // If the Arc is uniquely owned, it simply returns a mutable reference to the data. + let inner = Arc::make_mut(&mut resource.inner); for (key, value) in detected_res.into_iter() { - // This call ensures that if the Arc is not uniquely owned, - // the data is cloned before modification, preserving safety. - // If the Arc is uniquely owned, it simply returns a mutable reference to the data. - let inner = Arc::make_mut(&mut resource.inner); inner.attrs.insert(Key::new(key.clone()), value.clone()); } } From 6b5706815be7888bb76f1c410546bf359de3fbe4 Mon Sep 17 00:00:00 2001 From: Lalit Date: Wed, 14 Feb 2024 17:21:13 -0800 Subject: [PATCH 08/13] add changelog --- opentelemetry-sdk/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 7bc06fea6d..ecf32273a7 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -8,6 +8,9 @@ - [#1471](https://github.com/open-telemetry/opentelemetry-rust/pull/1471) Configure batch log record processor via [`OTEL_BLRP_*`](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor) environment variables and via `OtlpLogPipeline::with_batch_config` - [#1503](https://github.com/open-telemetry/opentelemetry-rust/pull/1503) Make the documentation for In-Memory exporters visible. +- [#1526](https://github.com/open-telemetry/opentelemetry-rust/pull/1526) +Optimize Resource Sharing Across Exporters with Arc Implementation + ### Changed - **Breaking** From cc50ea41f0a5307e1a990daaf4c1f756c2c080e3 Mon Sep 17 00:00:00 2001 From: Lalit Date: Wed, 14 Feb 2024 17:25:54 -0800 Subject: [PATCH 09/13] review comment --- opentelemetry-sdk/src/resource/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index c005f4d0df..f43fe1c1e0 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -114,16 +114,16 @@ impl Resource { } else { Some(schema_url_str) }; - - let mut resource = Self::new(kvs); - let new_inner = ResourceInner { - attrs: Arc::make_mut(&mut resource.inner).attrs.clone(), - schema_url: normalized_schema_url, - }; - - resource.inner = Arc::new(new_inner); - - resource + let mut attrs = HashMap::new(); + for kv in kvs { + attrs.insert(kv.key, kv.value); + } + Resource { + inner: Arc::new(ResourceInner { + attrs, + schema_url: normalized_schema_url, + }), + } } /// Create a new `Resource` from resource detectors. From 09def74d72d5647eb93ca3147b2948b0a41f686d Mon Sep 17 00:00:00 2001 From: Lalit Date: Wed, 14 Feb 2024 17:28:35 -0800 Subject: [PATCH 10/13] leftover commit --- opentelemetry-sdk/benches/log.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index 7a03ac520e..277af66e36 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -28,12 +28,6 @@ fn log_benchmark_group(c: &mut Criterion, name: &str, f: F) group.bench_function("no-context", |b| { let provider = LoggerProvider::builder() - .with_config(Config::default().with_resource(Resource::new(vec![ - KeyValue::new("service.name", "my-service"), - KeyValue::new("service.version", "1.0.0"), - KeyValue::new("service.environment", "production"), - KeyValue::new("service.instance.id", "1234"), - ]))) .with_simple_exporter(VoidExporter) .build(); From d892cdc5301c3ca931018d3a2cf2977874ca3b54 Mon Sep 17 00:00:00 2001 From: Lalit Date: Wed, 14 Feb 2024 17:29:52 -0800 Subject: [PATCH 11/13] more leftover commit --- opentelemetry-sdk/benches/log.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index 277af66e36..1910185769 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -39,12 +39,6 @@ fn log_benchmark_group(c: &mut Criterion, name: &str, f: F) group.bench_function("with-context", |b| { let provider = LoggerProvider::builder() .with_simple_exporter(VoidExporter) - .with_config(Config::default().with_resource(Resource::new(vec![ - KeyValue::new("service.name", "my-service"), - KeyValue::new("service.version", "1.0.0"), - KeyValue::new("service.environment", "production"), - KeyValue::new("service.instance.id", "1234"), - ]))) .build(); let logger = provider.logger("with-context"); From c1471b3be090a3568257afcab28b7417ceede45b Mon Sep 17 00:00:00 2001 From: Lalit Date: Wed, 14 Feb 2024 17:31:04 -0800 Subject: [PATCH 12/13] more leftover commit..last --- opentelemetry-sdk/benches/log.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/opentelemetry-sdk/benches/log.rs b/opentelemetry-sdk/benches/log.rs index 1910185769..9b66ad0447 100644 --- a/opentelemetry-sdk/benches/log.rs +++ b/opentelemetry-sdk/benches/log.rs @@ -7,11 +7,10 @@ use criterion::{criterion_group, criterion_main, Criterion}; use opentelemetry::logs::{AnyValue, LogRecord, LogResult, Logger, LoggerProvider as _, Severity}; use opentelemetry::trace::Tracer; use opentelemetry::trace::TracerProvider as _; -use opentelemetry::{Key, KeyValue}; +use opentelemetry::Key; use opentelemetry_sdk::export::logs::{LogData, LogExporter}; -use opentelemetry_sdk::logs::{Config, LoggerProvider}; +use opentelemetry_sdk::logs::LoggerProvider; use opentelemetry_sdk::trace::{config, Sampler, TracerProvider}; -use opentelemetry_sdk::Resource; #[derive(Debug)] struct VoidExporter; From 79d189659646f8dd238fd0a41aeac72187f1b20d Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 15 Feb 2024 12:08:41 -0500 Subject: [PATCH 13/13] Update opentelemetry-sdk/CHANGELOG.md --- opentelemetry-sdk/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-sdk/CHANGELOG.md b/opentelemetry-sdk/CHANGELOG.md index 7dc46f2497..91814f20ef 100644 --- a/opentelemetry-sdk/CHANGELOG.md +++ b/opentelemetry-sdk/CHANGELOG.md @@ -9,7 +9,7 @@ - [#1503](https://github.com/open-telemetry/opentelemetry-rust/pull/1503) Make the documentation for In-Memory exporters visible. - [#1526](https://github.com/open-telemetry/opentelemetry-rust/pull/1526) -Optimize Resource Sharing Across Exporters with Arc Implementation +Performance Improvement : Creating Spans and LogRecords are now faster, by avoiding expensive cloning of `Resource` for every Span/LogRecord. ### Changed