Skip to content

Commit 9af0650

Browse files
committed
metrics: Remove legacy Prometheus metrics
OpenTelemetry now covers the server and worker metrics previously exposed through Prometheus. Remove the private endpoint, legacy instruments and request updates, endpoint configuration, and the unused Prometheus dependency while retaining the database snapshot used by the OpenTelemetry collector.
1 parent e94b989 commit 9af0650

17 files changed

Lines changed: 7 additions & 618 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ p256 = "=0.14.0"
147147
parking_lot = "=0.12.5"
148148
paste = "=1.0.15"
149149
postgres-native-tls = "=0.5.3"
150-
prometheus = { version = "=0.14.0", default-features = false }
151150
rand = "=0.10.2"
152151
regex = "=1.13.1"
153152
reqwest = { version = "=0.13.5", features = ["gzip", "json", "stream"] }

src/app.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::collections::HashMap;
66
use std::sync::Arc;
77

88
use crate::email::Emails;
9-
use crate::metrics::{InstanceMetrics, ServerMetrics, ServiceMetrics};
9+
use crate::metrics::ServerMetrics;
1010
use crate::rate_limiter::{LimitedAction, RateLimiter, RateLimiterConfig};
1111
use crate::storage::{Storage, StorageConfig};
1212
use axum::extract::{FromRef, FromRequestParts, State};
@@ -59,14 +59,6 @@ pub struct App {
5959
/// Storage backend for crate files and other large objects.
6060
pub storage: Arc<Storage>,
6161

62-
/// Metrics related to the service as a whole
63-
#[builder(default = ServiceMetrics::new().expect("could not initialize service metrics"))]
64-
pub service_metrics: ServiceMetrics,
65-
66-
/// Metrics related to this specific instance of the service
67-
#[builder(default = InstanceMetrics::new().expect("could not initialize instance metrics"))]
68-
pub instance_metrics: InstanceMetrics,
69-
7062
/// OpenTelemetry metrics recorded by the HTTP server
7163
pub metrics: ServerMetrics,
7264

@@ -195,12 +187,6 @@ impl App {
195187

196188
// Replica is not available, but primary might be available
197189
Err(error) => {
198-
let _ = self
199-
.instance_metrics
200-
.database_fallback_used
201-
.get_metric_with_label_values(&["follower"])
202-
.map(|metric| metric.inc());
203-
204190
self.metrics.db_fallback("replica");
205191

206192
warn!("Replica is unavailable, falling back to primary ({error})");
@@ -224,12 +210,6 @@ impl App {
224210

225211
// Primary is not available, but replica might be available
226212
Err(error) => {
227-
let _ = self
228-
.instance_metrics
229-
.database_fallback_used
230-
.get_metric_with_label_values(&["primary"])
231-
.map(|metric| metric.inc());
232-
233213
self.metrics.db_fallback("primary");
234214

235215
warn!("Primary is unavailable, falling back to replica ({error})");

src/config/metrics.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crates_io_env_vars::var;
2-
use secrecy::SecretString;
32

43
#[derive(Debug, Default)]
54
pub struct MetricsConfig {
@@ -8,24 +7,14 @@ pub struct MetricsConfig {
87
/// Selected when either `OTEL_EXPORTER_OTLP_ENDPOINT` or
98
/// `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` is present.
109
pub otlp_enabled: bool,
11-
12-
/// Authorization token needed to query the metrics endpoints. If missing,
13-
/// querying metrics is completely disabled.
14-
///
15-
/// Read from the `METRICS_AUTHORIZATION_TOKEN` environment variable.
16-
pub authorization_token: Option<SecretString>,
1710
}
1811

1912
impl MetricsConfig {
2013
pub fn from_env() -> anyhow::Result<Self> {
2114
let otlp_endpoint = var("OTEL_EXPORTER_OTLP_ENDPOINT")?;
2215
let metrics_endpoint = var("OTEL_EXPORTER_OTLP_METRICS_ENDPOINT")?;
2316
let otlp_enabled = otlp_endpoint.is_some() || metrics_endpoint.is_some();
24-
let authorization_token = var("METRICS_AUTHORIZATION_TOKEN")?.map(Into::into);
2517

26-
Ok(Self {
27-
otlp_enabled,
28-
authorization_token,
29-
})
18+
Ok(Self { otlp_enabled })
3019
}
3120
}

src/controllers.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub mod git;
88
pub mod github;
99
pub mod keyword;
1010
pub mod krate;
11-
pub mod metrics;
1211
pub mod session;
1312
pub mod site_metadata;
1413
pub mod summary;

src/controllers/metrics.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/metrics/instance.rs

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/metrics/macros.rs

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)