Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ thiserror = "2.0.3"
comrak = { version = "0.48.0", default-features = false }
syntect = { version = "5.0.0", default-features = false, features = ["parsing", "html", "dump-load", "regex-onig"] }
toml = "0.9.2"
prometheus = { version = "0.14.0", default-features = false }
opentelemetry = "0.31.0"
opentelemetry-otlp = { version = "0.31.0", features = ["grpc-tonic", "metrics"] }
opentelemetry-resource-detectors = "0.10.0"
Expand Down
41 changes: 3 additions & 38 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# - release-rebuild-enqueuer
#
# optional profile: `metrics`:
# * `prometheus` -> configured prometheus instance
# * `opentelemetry` -> a debug opentelemetry receiver
#
# optional profile: `full`: all of the above.
Expand All @@ -44,12 +43,6 @@
# * docker-native for DB, S3, rustwide workspace, crates.io index
# * mounts for prefix
#
# * prometheus scrape config is set to collect from the web server, the
# registry watcher, and the build servers. Scraping is not dynamic, so
# the local prometheus server will try to fetch from all service
# instances (web, watcher, builder), and just error in case the specific
# server isn't accessible.

x-docker-cache: &docker-cache
# shared configuration to cache docker layers across CI runs.
# can just always be in in the `docker-compose.yml`, and will
Expand Down Expand Up @@ -119,9 +112,6 @@ x-builder: &builder
<<: *builder-environment
env_file:
- .docker.env
healthcheck:
<<: *healthcheck-interval
test: curl --silent --fail localhost:3000/about/metrics

x-registry-watcher: &registry-watcher
build:
Expand All @@ -144,9 +134,6 @@ x-registry-watcher: &registry-watcher
DOCSRS_MAX_QUEUED_REBUILDS: ${DOCSRS_MAX_QUEUED_REBUILDS:-10}
env_file:
- .docker.env
healthcheck:
<<: *healthcheck-interval
test: curl --silent --fail localhost:3000/about/metrics

services:
web:
Expand All @@ -166,7 +153,7 @@ services:
- .docker.env
healthcheck:
<<: *healthcheck-interval
test: curl --silent --fail localhost:3000/about/metrics
test: curl --silent --fail localhost:3000/
profiles:
- web
- full
Expand Down Expand Up @@ -275,28 +262,6 @@ services:
<<: *healthcheck-interval
test: mc ready local

prometheus:
build:
context: ./dockerfiles
dockerfile: ./Dockerfile-prometheus
<<: *docker-cache
ports:
- "127.0.0.1:9090:9090"
# we intentionally don't define depends_on here.
# While the scrapers are configured to fetch from eventually running
# web or build-servers, adding these as dependency would mean we can't
# test metrics just with a webserver.
# Prometheus will just scrape from the working endpoints, and skip/error
# on the broken ones.
healthcheck:
<<: *healthcheck-interval
test: promtool check healthy
profiles:
# we rarely need to test with actual prometheus, so always running
# it is a waste.
- metrics
- full

opentelemetry:
build:
context: ./dockerfiles
Expand All @@ -309,8 +274,8 @@ services:
test: curl --silent --fail http://localhost:13133/health

profiles:
# we rarely need to test with actual prometheus, so always running
# it is a waste.
# we rarely need to test with actual opentelemetry, so always
# running it is a waste.
- metrics
- full

Expand Down
2 changes: 0 additions & 2 deletions dockerfiles/Dockerfile-prometheus

This file was deleted.

2 changes: 1 addition & 1 deletion justfiles/services.just
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ compose-up-builder:
compose-up-watcher:
just compose-up watcher

# Launch prometheus server in the background
# Launch metrics collector in the background
[group('compose')]
compose-up-metrics:
just compose-up metrics
Expand Down
18 changes: 3 additions & 15 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::{Parser, Subcommand, ValueEnum};
use docs_rs::{
Config, Context, Index, PackageKind, RustwideBuilder,
db::{self, CrateId, Overrides, add_path_into_database, types::version::Version},
queue_rebuilds_faulty_rustdoc, start_background_metrics_webserver, start_web_server,
queue_rebuilds_faulty_rustdoc, start_web_server,
utils::{
ConfigName, daemon::start_background_service_metric_collector, get_config,
get_crate_pattern_and_priority, list_crate_priorities, queue_builder,
Expand Down Expand Up @@ -137,8 +137,6 @@ enum CommandLine {
},

StartRegistryWatcher {
#[arg(name = "SOCKET_ADDR", default_value = "0.0.0.0:3000")]
metric_server_socket_addr: SocketAddr,
/// Enable or disable the repository stats updater
#[arg(
long = "repository-stats-updater",
Expand All @@ -152,10 +150,7 @@ enum CommandLine {
queue_rebuilds: Toggle,
},

StartBuildServer {
#[arg(name = "SOCKET_ADDR", default_value = "0.0.0.0:3000")]
metric_server_socket_addr: SocketAddr,
},
StartBuildServer,

/// Starts the daemon
Daemon {
Expand Down Expand Up @@ -186,7 +181,6 @@ impl CommandLine {
match self {
Self::Build { subcommand } => subcommand.handle_args(ctx)?,
Self::StartRegistryWatcher {
metric_server_socket_addr,
repository_stats_updater,
cdn_invalidator,
queue_rebuilds,
Expand All @@ -205,18 +199,12 @@ impl CommandLine {
// metrics from the registry watcher, which should only run once, and all the time.
start_background_service_metric_collector(&ctx)?;

start_background_metrics_webserver(Some(metric_server_socket_addr), &ctx)?;

ctx.runtime.block_on(docs_rs::utils::watch_registry(
&ctx.async_build_queue,
&ctx.config,
))?;
}
Self::StartBuildServer {
metric_server_socket_addr,
} => {
start_background_metrics_webserver(Some(metric_server_socket_addr), &ctx)?;

Self::StartBuildServer => {
queue_builder(&ctx, RustwideBuilder::init(&ctx)?)?;
}
Self::StartWebServer { socket_addr } => {
Expand Down
15 changes: 1 addition & 14 deletions src/build_queue.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
BuildPackageSummary, Config, Context, Index, InstanceMetrics, RustwideBuilder,
BuildPackageSummary, Config, Context, Index, RustwideBuilder,
cdn::{self, CdnMetrics},
db::{
CrateId, Pool, delete_crate, delete_version,
Expand Down Expand Up @@ -70,7 +70,6 @@ pub struct AsyncBuildQueue {
config: Arc<Config>,
storage: Arc<AsyncStorage>,
pub(crate) db: Pool,
metrics: Arc<InstanceMetrics>,
queue_metrics: BuildQueueMetrics,
builder_metrics: Arc<BuilderMetrics>,
cdn_metrics: Arc<CdnMetrics>,
Expand All @@ -80,7 +79,6 @@ pub struct AsyncBuildQueue {
impl AsyncBuildQueue {
pub fn new(
db: Pool,
metrics: Arc<InstanceMetrics>,
config: Arc<Config>,
storage: Arc<AsyncStorage>,
cdn_metrics: Arc<CdnMetrics>,
Expand All @@ -90,7 +88,6 @@ impl AsyncBuildQueue {
max_attempts: config.build_attempts.into(),
config,
db,
metrics,
storage,
queue_metrics: BuildQueueMetrics::new(otel_meter_provider),
builder_metrics: Arc::new(BuilderMetrics::new(otel_meter_provider)),
Expand Down Expand Up @@ -427,7 +424,6 @@ impl AsyncBuildQueue {
"{}-{} added into build queue",
release.name, release.version
);
self.metrics.queued_builds.inc();
self.queue_metrics.queued_builds.add(1, &[]);
crates_added += 1;
}
Expand Down Expand Up @@ -637,12 +633,10 @@ impl BuildQueue {
let instant = Instant::now();
let res = f(&to_process);
let elapsed = instant.elapsed().as_secs_f64();
self.inner.metrics.build_time.observe(elapsed);
self.inner.builder_metrics.build_time.record(elapsed, &[]);
res
};

self.inner.metrics.total_builds.inc();
self.inner.builder_metrics.total_builds.add(1, &[]);

self.runtime.block_on(
Expand All @@ -665,7 +659,6 @@ impl BuildQueue {
)?;

if attempt >= self.inner.max_attempts {
self.inner.metrics.failed_builds.inc();
self.inner.builder_metrics.failed_builds.add(1, &[]);
}
Ok(())
Expand Down Expand Up @@ -1384,12 +1377,6 @@ mod tests {
})?;
assert!(!called, "there were still items in the queue");

// Ensure metrics were recorded correctly
let metrics = env.instance_metrics();
assert_eq!(metrics.total_builds.get(), 9);
assert_eq!(metrics.failed_builds.get(), 1);
assert_eq!(metrics.build_time.get_sample_count(), 9);

let collected_metrics = env.collected_metrics();

assert_eq!(
Expand Down
Loading
Loading