Skip to content

Commit

Permalink
resource: remove vec allocations for attributes (#2429)
Browse files Browse the repository at this point in the history
  • Loading branch information
pitoniak32 authored Dec 14, 2024
1 parent d2e179e commit b8380eb
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
//! .with_max_events_per_span(64)
//! .with_max_attributes_per_span(16)
//! .with_max_events_per_span(16)
//! .with_resource(Resource::builder_empty().with_attributes(vec![KeyValue::new("service.name", "example")]).build()),
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build()),
//! ).build();
//! global::set_tracer_provider(tracer_provider);
//! let tracer = global::tracer("tracer-name");
Expand All @@ -186,7 +186,7 @@
//!
//! let provider = opentelemetry_sdk::metrics::SdkMeterProvider::builder()
//! .with_reader(reader)
//! .with_resource(Resource::builder_empty().with_attributes(vec![KeyValue::new("service.name", "example")]).build())
//! .with_resource(Resource::builder_empty().with_attributes([KeyValue::new("service.name", "example")]).build())
//! .build();
//! # }
//!
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/logs/log_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ mod tests {
let user_provided_resource_config_provider = super::LoggerProvider::builder()
.with_resource(
Resource::builder()
.with_attributes(vec![
.with_attributes([
KeyValue::new("my-custom-key", "my-custom-value"),
KeyValue::new("my-custom-key2", "my-custom-value2"),
])
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/logs/log_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ mod tests {
.with_log_processor(processor)
.with_resource(
Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("k1", "v1"),
KeyValue::new("k2", "v3"),
KeyValue::new("k3", "v3"),
Expand All @@ -796,7 +796,7 @@ mod tests {
.with_log_processor(processor)
.with_resource(
Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("k1", "v1"),
KeyValue::new("k2", "v3"),
KeyValue::new("k3", "v3"),
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod tests {
fn logging_sdk_test() {
// Arrange
let resource = Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("k1", "v1"),
KeyValue::new("k2", "v2"),
KeyValue::new("k3", "v3"),
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/meter_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ mod tests {
.with_reader(reader4)
.with_resource(
Resource::builder()
.with_attributes(vec![
.with_attributes([
KeyValue::new("my-custom-key", "my-custom-value"),
KeyValue::new("my-custom-key2", "my-custom-value2"),
])
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/resource/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct SdkProvidedResourceDetector;
impl ResourceDetector for SdkProvidedResourceDetector {
fn detect(&self) -> Resource {
Resource::builder_empty()
.with_attributes(vec![KeyValue::new(
.with_attributes([KeyValue::new(
super::SERVICE_NAME,
env::var(OTEL_SERVICE_NAME)
.ok()
Expand Down Expand Up @@ -116,7 +116,7 @@ mod tests {
assert_eq!(
resource,
Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("key", "value"),
KeyValue::new("k", "v"),
KeyValue::new("a", "x"),
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-sdk/src/resource/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ mod tests {
#[test]
fn merge_resource_key_value_pairs() {
let resource_a = Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("a", ""),
KeyValue::new("b", "b-value"),
KeyValue::new("d", "d-value"),
Expand Down Expand Up @@ -452,7 +452,7 @@ mod tests {
assert_eq!(
resource,
Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("key", "value"),
KeyValue::new("k", "v"),
KeyValue::new("a", "x"),
Expand Down Expand Up @@ -519,7 +519,7 @@ mod tests {
.with_detector(Box::new(EnvResourceDetector::new()))
.with_service_name("testing_service")
.with_attribute(KeyValue::new("test1", "test_value"))
.with_attributes(vec![
.with_attributes([
KeyValue::new("test1", "test_value1"),
KeyValue::new("test2", "test_value2"),
])
Expand All @@ -528,7 +528,7 @@ mod tests {
assert_eq!(
resource,
Resource::builder_empty()
.with_attributes(vec![
.with_attributes([
KeyValue::new("key", "value"),
KeyValue::new("test1", "test_value1"),
KeyValue::new("test2", "test_value2"),
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/trace/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ mod tests {
let user_provided_resource_config_provider = super::TracerProvider::builder()
.with_resource(
Resource::builder()
.with_attributes(vec![
.with_attributes([
KeyValue::new("my-custom-key", "my-custom-value"),
KeyValue::new("my-custom-key2", "my-custom-value2"),
])
Expand Down

0 comments on commit b8380eb

Please sign in to comment.