mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
drop dependency on once-cell
This commit is contained in:
parent
a550d8db1f
commit
e74c8687f5
4 changed files with 12 additions and 10 deletions
|
|
@ -1,7 +1,12 @@
|
|||
//! Facilities for observing runtime behavior
|
||||
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
|
||||
|
||||
use std::{collections::HashSet, fs::File, io::BufWriter, sync::Arc};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
fs::File,
|
||||
io::BufWriter,
|
||||
sync::{Arc, LazyLock},
|
||||
};
|
||||
|
||||
use axum::{
|
||||
extract::{MatchedPath, Request},
|
||||
|
|
@ -9,7 +14,6 @@ use axum::{
|
|||
response::Response,
|
||||
};
|
||||
use http::Method;
|
||||
use once_cell::sync::Lazy;
|
||||
use opentelemetry::{metrics::MeterProvider, trace::TracerProvider, KeyValue};
|
||||
use opentelemetry_otlp::WithExportConfig;
|
||||
use opentelemetry_sdk::{
|
||||
|
|
@ -34,7 +38,7 @@ use crate::{
|
|||
};
|
||||
|
||||
/// Globally accessible metrics state
|
||||
pub(crate) static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||
pub(crate) static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
||||
|
||||
/// Cleans up resources relating to observability when [`Drop`]ped
|
||||
pub(crate) struct Guard {
|
||||
|
|
@ -385,8 +389,8 @@ impl Metrics {
|
|||
/// Track HTTP metrics by converting this into an [`axum`] layer
|
||||
pub(crate) async fn http_metrics_layer(req: Request, next: Next) -> Response {
|
||||
/// Routes that should not be included in the metrics
|
||||
static IGNORED_ROUTES: Lazy<HashSet<(&Method, &str)>> =
|
||||
Lazy::new(|| [(&Method::GET, "/metrics")].into_iter().collect());
|
||||
static IGNORED_ROUTES: LazyLock<HashSet<(&Method, &str)>> =
|
||||
LazyLock::new(|| [(&Method::GET, "/metrics")].into_iter().collect());
|
||||
|
||||
let matched_path =
|
||||
req.extensions().get::<MatchedPath>().map(|x| x.as_str().to_owned());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue