mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +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
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -888,7 +888,6 @@ dependencies = [
|
||||||
"lru-cache",
|
"lru-cache",
|
||||||
"nix",
|
"nix",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"once_cell",
|
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"opentelemetry-jaeger-propagator",
|
"opentelemetry-jaeger-propagator",
|
||||||
"opentelemetry-otlp",
|
"opentelemetry-otlp",
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,6 @@ image = { version = "0.25.2", default-features = false, features = ["jpeg", "png
|
||||||
jsonwebtoken = "9.3.0"
|
jsonwebtoken = "9.3.0"
|
||||||
lru-cache = "0.1.2"
|
lru-cache = "0.1.2"
|
||||||
num_cpus = "1.16.0"
|
num_cpus = "1.16.0"
|
||||||
once_cell = "1.19.0"
|
|
||||||
opentelemetry = "0.24.0"
|
opentelemetry = "0.24.0"
|
||||||
opentelemetry-jaeger-propagator = "0.3.0"
|
opentelemetry-jaeger-propagator = "0.3.0"
|
||||||
opentelemetry-otlp = "0.17.0"
|
opentelemetry-otlp = "0.17.0"
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ use std::{
|
||||||
fmt::{self, Display},
|
fmt::{self, Display},
|
||||||
net::{IpAddr, Ipv4Addr},
|
net::{IpAddr, Ipv4Addr},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
sync::LazyLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::federation::discovery::OldVerifyKey, OwnedServerName,
|
api::federation::discovery::OldVerifyKey, OwnedServerName,
|
||||||
|
|
@ -24,8 +24,8 @@ pub(crate) use env_filter_clone::EnvFilterClone;
|
||||||
use proxy::ProxyConfig;
|
use proxy::ProxyConfig;
|
||||||
|
|
||||||
/// The default configuration file path
|
/// The default configuration file path
|
||||||
pub(crate) static DEFAULT_PATH: Lazy<PathBuf> =
|
pub(crate) static DEFAULT_PATH: LazyLock<PathBuf> =
|
||||||
Lazy::new(|| [env!("CARGO_PKG_NAME"), "config.toml"].iter().collect());
|
LazyLock::new(|| [env!("CARGO_PKG_NAME"), "config.toml"].iter().collect());
|
||||||
|
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
//! Facilities for observing runtime behavior
|
//! Facilities for observing runtime behavior
|
||||||
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
|
#![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::{
|
use axum::{
|
||||||
extract::{MatchedPath, Request},
|
extract::{MatchedPath, Request},
|
||||||
|
|
@ -9,7 +14,6 @@ use axum::{
|
||||||
response::Response,
|
response::Response,
|
||||||
};
|
};
|
||||||
use http::Method;
|
use http::Method;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use opentelemetry::{metrics::MeterProvider, trace::TracerProvider, KeyValue};
|
use opentelemetry::{metrics::MeterProvider, trace::TracerProvider, KeyValue};
|
||||||
use opentelemetry_otlp::WithExportConfig;
|
use opentelemetry_otlp::WithExportConfig;
|
||||||
use opentelemetry_sdk::{
|
use opentelemetry_sdk::{
|
||||||
|
|
@ -34,7 +38,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Globally accessible metrics state
|
/// 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
|
/// Cleans up resources relating to observability when [`Drop`]ped
|
||||||
pub(crate) struct Guard {
|
pub(crate) struct Guard {
|
||||||
|
|
@ -385,8 +389,8 @@ impl Metrics {
|
||||||
/// Track HTTP metrics by converting this into an [`axum`] layer
|
/// Track HTTP metrics by converting this into an [`axum`] layer
|
||||||
pub(crate) async fn http_metrics_layer(req: Request, next: Next) -> Response {
|
pub(crate) async fn http_metrics_layer(req: Request, next: Next) -> Response {
|
||||||
/// Routes that should not be included in the metrics
|
/// Routes that should not be included in the metrics
|
||||||
static IGNORED_ROUTES: Lazy<HashSet<(&Method, &str)>> =
|
static IGNORED_ROUTES: LazyLock<HashSet<(&Method, &str)>> =
|
||||||
Lazy::new(|| [(&Method::GET, "/metrics")].into_iter().collect());
|
LazyLock::new(|| [(&Method::GET, "/metrics")].into_iter().collect());
|
||||||
|
|
||||||
let matched_path =
|
let matched_path =
|
||||||
req.extensions().get::<MatchedPath>().map(|x| x.as_str().to_owned());
|
req.extensions().get::<MatchedPath>().map(|x| x.as_str().to_owned());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue