mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
bump otel to v0.24.0
Someone contributed opentelemetry-prometheus support for v0.24 and this version also doesn't put stupid requirements on the tokio version. This version of the OTel ecosystem also fixes an apparent bug with some hacks I plan on doing in the future...
This commit is contained in:
parent
c24f79b79b
commit
b0d1cc1b63
3 changed files with 110 additions and 218 deletions
|
|
@ -10,10 +10,7 @@ use axum::{
|
|||
};
|
||||
use http::Method;
|
||||
use once_cell::sync::Lazy;
|
||||
use opentelemetry::{
|
||||
metrics::{MeterProvider, Unit},
|
||||
KeyValue,
|
||||
};
|
||||
use opentelemetry::{metrics::MeterProvider, trace::TracerProvider, KeyValue};
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
use opentelemetry_sdk::{
|
||||
metrics::{new_view, Aggregation, Instrument, SdkMeterProvider, Stream},
|
||||
|
|
@ -168,10 +165,10 @@ pub(crate) fn init(
|
|||
if let Some(endpoint) = &config.observability.traces.endpoint {
|
||||
exporter = exporter.with_endpoint(endpoint);
|
||||
}
|
||||
let tracer = opentelemetry_otlp::new_pipeline()
|
||||
let tracer_provider = opentelemetry_otlp::new_pipeline()
|
||||
.tracing()
|
||||
.with_trace_config(
|
||||
opentelemetry_sdk::trace::config().with_resource(
|
||||
opentelemetry_sdk::trace::Config::default().with_resource(
|
||||
standard_resource(
|
||||
config.observability.traces.service_name.clone(),
|
||||
),
|
||||
|
|
@ -179,6 +176,18 @@ pub(crate) fn init(
|
|||
)
|
||||
.with_exporter(exporter)
|
||||
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
|
||||
|
||||
// The passed value sets the library name, and `""` seems to be
|
||||
// morally equivalent to passing `None`, which is probably fine
|
||||
// because what other library is there to use for this anyway?
|
||||
//
|
||||
// Prior to opentelemetry v0.24, this value was set for us by the
|
||||
// opentelemetry-otlp crate. Trying to automate getting the right
|
||||
// values doesn't seem worth it, as alluded to above.
|
||||
let tracer = tracer_provider.tracer("");
|
||||
|
||||
opentelemetry::global::set_tracer_provider(tracer_provider);
|
||||
|
||||
Ok((tracing_opentelemetry::layer().with_tracer(tracer), ()))
|
||||
},
|
||||
)?;
|
||||
|
|
@ -315,7 +324,7 @@ impl Metrics {
|
|||
|
||||
let http_requests_histogram = meter
|
||||
.f64_histogram(http_requests_histogram_name)
|
||||
.with_unit(Unit::new("seconds"))
|
||||
.with_unit("seconds")
|
||||
.with_description("Histogram of HTTP requests")
|
||||
.init();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue