Skip to content

Commit 3d2bfc1

Browse files
connyaySushisource
authored andcommitted
fix bad resource attrs/merge
1 parent cbdd6b0 commit 3d2bfc1

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

core/src/telemetry/otel.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ pub fn build_otlp_metric_exporter(
130130
.with_temporality(metric_temporality_to_temporality(opts.metric_temporality))
131131
.build()?
132132
}
133-
OtlpProtocol::Http => opentelemetry_otlp::HttpExporterBuilder::default()
133+
OtlpProtocol::Http => opentelemetry_otlp::MetricExporter::builder()
134+
.with_http()
134135
.with_endpoint(opts.url.to_string())
135136
.with_headers(opts.headers)
136-
.build_metrics_exporter(metric_temporality_to_temporality(opts.metric_temporality))?,
137+
.with_temporality(metric_temporality_to_temporality(opts.metric_temporality))
138+
.build()?,
137139
};
138140
let reader = PeriodicReader::builder(exporter)
139141
.with_interval(opts.metric_periodicity)
@@ -301,20 +303,13 @@ fn default_resource_instance() -> &'static Resource {
301303
if resource.get(&Key::from("service.name")) == Some(Value::from("unknown_service")) {
302304
// otel spec recommends to leave service.name as unknown_service but we want to
303305
// maintain backwards compatability with existing library behaviour
304-
let compat = Resource::builder()
305-
.with_attribute(KeyValue::new("service.name", TELEM_SERVICE_NAME))
306-
.build();
307306
return Resource::builder_empty()
308307
.with_attributes(
309308
resource
310309
.iter()
311310
.map(|(k, v)| KeyValue::new(k.clone(), v.clone())),
312311
)
313-
.with_attributes(
314-
compat
315-
.iter()
316-
.map(|(k, v)| KeyValue::new(k.clone(), v.clone())),
317-
)
312+
.with_attribute(KeyValue::new("service.name", TELEM_SERVICE_NAME))
318313
.build();
319314
}
320315
resource
@@ -325,7 +320,9 @@ fn default_resource(override_values: &HashMap<String, String>) -> Resource {
325320
let override_kvs = override_values
326321
.iter()
327322
.map(|(k, v)| KeyValue::new(k.clone(), v.clone()));
328-
let override_resource = Resource::builder().with_attributes(override_kvs).build();
323+
let override_resource = Resource::builder_empty()
324+
.with_attributes(override_kvs)
325+
.build();
329326
Resource::builder_empty()
330327
.with_attributes(
331328
default_resource_instance()

0 commit comments

Comments
 (0)