Skip to content

Commit ef45ca7

Browse files
refactor: replace get_ref with get for resource retrieval
1 parent e5d29d9 commit ef45ca7

File tree

6 files changed

+57
-60
lines changed

6 files changed

+57
-60
lines changed

opentelemetry-sdk/src/logs/logger_provider.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -428,44 +428,44 @@ mod tests {
428428
assert_eq!(
429429
processor
430430
.resource()
431-
.get_ref(&Key::from_static_str(resource_key))
431+
.get(&Key::from_static_str(resource_key))
432432
.map(|v| v.to_string()),
433433
expect.map(|s| s.to_string())
434434
);
435435

436436
assert_eq!(
437437
exporter
438438
.resource()
439-
.get_ref(&Key::from_static_str(resource_key))
439+
.get(&Key::from_static_str(resource_key))
440440
.map(|v| v.to_string()),
441441
expect.map(|s| s.to_string())
442442
);
443443
};
444444
let assert_telemetry_resource =
445445
|processor: &TestProcessorForResource, exporter: &TestExporterForResource| {
446446
assert_eq!(
447-
processor.resource().get_ref(&TELEMETRY_SDK_LANGUAGE.into()),
448-
Some(&Value::from("rust"))
447+
processor.resource().get(&TELEMETRY_SDK_LANGUAGE.into()),
448+
Some(Value::from("rust"))
449449
);
450450
assert_eq!(
451-
processor.resource().get_ref(&TELEMETRY_SDK_NAME.into()),
452-
Some(&Value::from("opentelemetry"))
451+
processor.resource().get(&TELEMETRY_SDK_NAME.into()),
452+
Some(Value::from("opentelemetry"))
453453
);
454454
assert_eq!(
455-
processor.resource().get_ref(&TELEMETRY_SDK_VERSION.into()),
456-
Some(&Value::from(env!("CARGO_PKG_VERSION")))
455+
processor.resource().get(&TELEMETRY_SDK_VERSION.into()),
456+
Some(Value::from(env!("CARGO_PKG_VERSION")))
457457
);
458458
assert_eq!(
459-
exporter.resource().get_ref(&TELEMETRY_SDK_LANGUAGE.into()),
460-
Some(&Value::from("rust"))
459+
exporter.resource().get(&TELEMETRY_SDK_LANGUAGE.into()),
460+
Some(Value::from("rust"))
461461
);
462462
assert_eq!(
463-
exporter.resource().get_ref(&TELEMETRY_SDK_NAME.into()),
464-
Some(&Value::from("opentelemetry"))
463+
exporter.resource().get(&TELEMETRY_SDK_NAME.into()),
464+
Some(Value::from("opentelemetry"))
465465
);
466466
assert_eq!(
467-
exporter.resource().get_ref(&TELEMETRY_SDK_VERSION.into()),
468-
Some(&Value::from(env!("CARGO_PKG_VERSION")))
467+
exporter.resource().get(&TELEMETRY_SDK_VERSION.into()),
468+
Some(Value::from(env!("CARGO_PKG_VERSION")))
469469
);
470470
};
471471

@@ -876,16 +876,16 @@ mod tests {
876876
let resource = builder.resource.unwrap();
877877

878878
assert_eq!(
879-
resource.get_ref(&Key::from_static_str("key1")),
880-
Some(&Value::from("value1"))
879+
resource.get(&Key::from_static_str("key1")),
880+
Some(Value::from("value1"))
881881
);
882882
assert_eq!(
883-
resource.get_ref(&Key::from_static_str("key2")),
884-
Some(&Value::from("value2"))
883+
resource.get(&Key::from_static_str("key2")),
884+
Some(Value::from("value2"))
885885
);
886886
assert_eq!(
887-
resource.get_ref(&Key::from_static_str("key3")),
888-
Some(&Value::from("value3"))
887+
resource.get(&Key::from_static_str("key3")),
888+
Some(Value::from("value3"))
889889
);
890890
assert_eq!(resource.schema_url(), Some("http://example.com"));
891891
}

opentelemetry-sdk/src/metrics/meter_provider.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ mod tests {
429429
assert_eq!(
430430
provider.inner.pipes.0[0]
431431
.resource
432-
.get_ref(&Key::from_static_str(resource_key))
432+
.get(&Key::from_static_str(resource_key))
433433
.map(|v| v.to_string()),
434434
expect.map(|s| s.to_string())
435435
);
@@ -438,20 +438,20 @@ mod tests {
438438
assert_eq!(
439439
provider.inner.pipes.0[0]
440440
.resource
441-
.get_ref(&TELEMETRY_SDK_LANGUAGE.into()),
442-
Some(&Value::from("rust"))
441+
.get(&TELEMETRY_SDK_LANGUAGE.into()),
442+
Some(Value::from("rust"))
443443
);
444444
assert_eq!(
445445
provider.inner.pipes.0[0]
446446
.resource
447-
.get_ref(&TELEMETRY_SDK_NAME.into()),
448-
Some(&Value::from("opentelemetry"))
447+
.get(&TELEMETRY_SDK_NAME.into()),
448+
Some(Value::from("opentelemetry"))
449449
);
450450
assert_eq!(
451451
provider.inner.pipes.0[0]
452452
.resource
453-
.get_ref(&TELEMETRY_SDK_VERSION.into()),
454-
Some(&Value::from(env!("CARGO_PKG_VERSION")))
453+
.get(&TELEMETRY_SDK_VERSION.into()),
454+
Some(Value::from(env!("CARGO_PKG_VERSION")))
455455
);
456456
};
457457

@@ -716,16 +716,16 @@ mod tests {
716716
let resource = builder.resource.unwrap();
717717

718718
assert_eq!(
719-
resource.get_ref(&Key::from_static_str("key1")),
720-
Some(&Value::from("value1"))
719+
resource.get(&Key::from_static_str("key1")),
720+
Some(Value::from("value1"))
721721
);
722722
assert_eq!(
723-
resource.get_ref(&Key::from_static_str("key2")),
724-
Some(&Value::from("value2"))
723+
resource.get(&Key::from_static_str("key2")),
724+
Some(Value::from("value2"))
725725
);
726726
assert_eq!(
727-
resource.get_ref(&Key::from_static_str("key3")),
728-
Some(&Value::from("value3"))
727+
resource.get(&Key::from_static_str("key3")),
728+
Some(Value::from("value3"))
729729
);
730730
assert_eq!(resource.schema_url(), Some("http://example.com"));
731731
}

opentelemetry-sdk/src/resource/env.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ mod tests {
138138
// Ensure no env var set
139139
let no_env = SdkProvidedResourceDetector.detect();
140140
assert_eq!(
141-
no_env.get_ref(&Key::from_static_str(crate::resource::SERVICE_NAME)),
142-
Some(&Value::from("unknown_service")),
141+
no_env.get(&Key::from_static_str(crate::resource::SERVICE_NAME)),
142+
Some(Value::from("unknown_service")),
143143
);
144144

145145
temp_env::with_var(OTEL_SERVICE_NAME, Some("test service"), || {
146146
let with_service = SdkProvidedResourceDetector.detect();
147147
assert_eq!(
148-
with_service.get_ref(&Key::from_static_str(crate::resource::SERVICE_NAME)),
149-
Some(&Value::from("test service")),
148+
with_service.get(&Key::from_static_str(crate::resource::SERVICE_NAME)),
149+
Some(Value::from("test service")),
150150
)
151151
});
152152

@@ -156,8 +156,8 @@ mod tests {
156156
|| {
157157
let with_service = SdkProvidedResourceDetector.detect();
158158
assert_eq!(
159-
with_service.get_ref(&Key::from_static_str(crate::resource::SERVICE_NAME)),
160-
Some(&Value::from("test service1")),
159+
with_service.get(&Key::from_static_str(crate::resource::SERVICE_NAME)),
160+
Some(Value::from("test service1")),
161161
)
162162
},
163163
);
@@ -171,8 +171,8 @@ mod tests {
171171
|| {
172172
let with_service = SdkProvidedResourceDetector.detect();
173173
assert_eq!(
174-
with_service.get_ref(&Key::from_static_str(crate::resource::SERVICE_NAME)),
175-
Some(&Value::from("test service"))
174+
with_service.get(&Key::from_static_str(crate::resource::SERVICE_NAME)),
175+
Some(Value::from("test service"))
176176
);
177177
},
178178
);

opentelemetry-sdk/src/trace/provider.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ mod tests {
577577
provider
578578
.config()
579579
.resource
580-
.get_ref(&Key::from_static_str(resource_key))
580+
.get(&Key::from_static_str(resource_key))
581581
.map(|v| v.to_string()),
582582
expect.map(|s| s.to_string())
583583
);
@@ -587,22 +587,19 @@ mod tests {
587587
provider
588588
.config()
589589
.resource
590-
.get_ref(&TELEMETRY_SDK_LANGUAGE.into()),
591-
Some(&Value::from("rust"))
590+
.get(&TELEMETRY_SDK_LANGUAGE.into()),
591+
Some(Value::from("rust"))
592592
);
593593
assert_eq!(
594-
provider
595-
.config()
596-
.resource
597-
.get_ref(&TELEMETRY_SDK_NAME.into()),
598-
Some(&Value::from("opentelemetry"))
594+
provider.config().resource.get(&TELEMETRY_SDK_NAME.into()),
595+
Some(Value::from("opentelemetry"))
599596
);
600597
assert_eq!(
601598
provider
602599
.config()
603600
.resource
604-
.get_ref(&TELEMETRY_SDK_VERSION.into()),
605-
Some(&Value::from(env!("CARGO_PKG_VERSION")))
601+
.get(&TELEMETRY_SDK_VERSION.into()),
602+
Some(Value::from(env!("CARGO_PKG_VERSION")))
606603
);
607604
};
608605

@@ -762,16 +759,16 @@ mod tests {
762759
.into_owned();
763760

764761
assert_eq!(
765-
resource.get_ref(&Key::from_static_str("key1")),
766-
Some(&Value::from("value1"))
762+
resource.get(&Key::from_static_str("key1")),
763+
Some(Value::from("value1"))
767764
);
768765
assert_eq!(
769-
resource.get_ref(&Key::from_static_str("key2")),
770-
Some(&Value::from("value2"))
766+
resource.get(&Key::from_static_str("key2")),
767+
Some(Value::from("value2"))
771768
);
772769
assert_eq!(
773-
resource.get_ref(&Key::from_static_str("key3")),
774-
Some(&Value::from("value3"))
770+
resource.get(&Key::from_static_str("key3")),
771+
Some(Value::from("value3"))
775772
);
776773
assert_eq!(resource.schema_url(), Some("http://example.com"));
777774
}

opentelemetry-sdk/src/trace/span_processor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,8 @@ mod tests {
13611361
exported_resource
13621362
.as_ref()
13631363
.unwrap()
1364-
.get_ref(&Key::new("service.name")),
1365-
Some(&Value::from("test_service"))
1364+
.get(&Key::new("service.name")),
1365+
Some(Value::from("test_service"))
13661366
);
13671367
}
13681368

stress/src/logs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl LogExporter for NoopExporter {
6868

6969
fn set_resource(&mut self, res: &Resource) {
7070
self.service_name = res
71-
.get_ref(&Key::from_static_str("service.name"))
71+
.get(&Key::from_static_str("service.name"))
7272
.map(|v| v.to_string());
7373
}
7474
}

0 commit comments

Comments
 (0)