mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
improve usage of Resource
* Extract into reusable function (we'll need this later) * Merge the values we want to override over the defaults, instead of dropping the defaults completely * Don't unnecessarily allocate (the `vec![]` usage is gone)
This commit is contained in:
parent
c64a474954
commit
94fda7c875
1 changed files with 10 additions and 6 deletions
|
|
@ -36,12 +36,8 @@ pub(crate) fn init(config: &Config) -> Result<Guard, error::Observability> {
|
||||||
let tracer = opentelemetry_otlp::new_pipeline()
|
let tracer = opentelemetry_otlp::new_pipeline()
|
||||||
.tracing()
|
.tracing()
|
||||||
.with_trace_config(
|
.with_trace_config(
|
||||||
opentelemetry_sdk::trace::config().with_resource(
|
opentelemetry_sdk::trace::config()
|
||||||
Resource::new(vec![KeyValue::new(
|
.with_resource(standard_resource()),
|
||||||
"service.name",
|
|
||||||
env!("CARGO_PKG_NAME"),
|
|
||||||
)]),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.with_exporter(opentelemetry_otlp::new_exporter().tonic())
|
.with_exporter(opentelemetry_otlp::new_exporter().tonic())
|
||||||
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
|
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
|
||||||
|
|
@ -81,3 +77,11 @@ pub(crate) fn init(config: &Config) -> Result<Guard, error::Observability> {
|
||||||
flame_guard,
|
flame_guard,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct the standard [`Resource`] value to use for this service
|
||||||
|
fn standard_resource() -> Resource {
|
||||||
|
Resource::default().merge(&Resource::new([KeyValue::new(
|
||||||
|
"service.name",
|
||||||
|
env!("CARGO_PKG_NAME"),
|
||||||
|
)]))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue