From 08eb59be09aea3b72e73e1e5c99531e83da3c850 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 18 Jun 2026 12:46:18 +0200 Subject: [PATCH 1/2] feat: Add new `prometheus` feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: kleines Filmröllchen --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 6 +++--- CHANGELOG.md | 5 +++++ Dockerfile | 2 +- README.md | 1 + breakwater/Cargo.toml | 7 +++++-- breakwater/src/main.rs | 7 +++++-- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 060ed58..440ec50 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -195,10 +195,10 @@ jobs: command: build # ndi-sdk-sys (behind the ndi features) only supports Linux x86 (no aarch64) so far. # We already run the tests on x86 Linux with all features above. - args: --target=${{ matrix.target }} --features alpha,binary-set-pixel,binary-sync-pixels,egui,winit,vnc + args: --target=${{ matrix.target }} --features prometheus,alpha,binary-set-pixel,binary-sync-pixels,egui,winit,vnc # I couldn't get pkg-config to work on macOS and Windows, so we omit the vnc and ndi feature - if: runner.os == 'macOS' || runner.os == 'Windows' uses: actions-rs/cargo@v1 with: command: build - args: --target=${{ matrix.target }} --no-default-features --features alpha,binary-set-pixel,binary-sync-pixels,egui,winit + args: --target=${{ matrix.target }} --no-default-features --features prometheus,alpha,binary-set-pixel,binary-sync-pixels,egui,winit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 79c851c..1773593 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,7 +45,7 @@ jobs: - if: runner.os != 'Windows' name: Build binary (non Windows) # We don't want to e.g. set "-C target-cpu=native", so that the binary should run everywhere - run: RUSTFLAGS='' cargo build --release --target=${{ matrix.target }} --no-default-features --features egui + run: RUSTFLAGS='' cargo build --release --target=${{ matrix.target }} --no-default-features --features prometheus,egui,winit - if: runner.os == 'Windows' name: Build binary (Windows) # Windows is a joke :) @@ -55,7 +55,7 @@ jobs: # | ~~~~~~~~~~~~ # | The term 'RUSTFLAGS=' is not recognized as a name of a cmdlet, function, script file, or executable program. # | Check the spelling of the name, or if a path was included, verify that the path is correct and try again. - run: cargo build --release --target=${{ matrix.target }} --no-default-features --features egui + run: cargo build --release --target=${{ matrix.target }} --no-default-features --features prometheus,egui,winit - name: Rename binary file run: mv target/${{ matrix.target }}/release/breakwater${{ matrix.file-suffix }} breakwater-${{ matrix.target }}${{ matrix.file-suffix }} - name: Upload Release binaries @@ -68,7 +68,7 @@ jobs: - if: runner.os == 'Linux' name: Build binary with VNC support (Linux) # We don't want to e.g. set "-C target-cpu=native", so that the binary should run everywhere - run: RUSTFLAGS='' cargo build --release --target=${{ matrix.target }} --no-default-features --features egui,vnc + run: RUSTFLAGS='' cargo build --release --target=${{ matrix.target }} --no-default-features --features prometheus,egui,winit,vnc - if: runner.os == 'Linux' name: Rename binary file with VNC support run: mv target/${{ matrix.target }}/release/breakwater${{ matrix.file-suffix }} breakwater-with-vnc-support-${{ matrix.target }}${{ matrix.file-suffix }} diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a2de9..ccd4ccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Moved prometheus metric exposition behind the `prometheus` feature. + This allows you to build breakwater on platforms where the `prometheus` [currently](https://github.com/tikv/rust-prometheus/issues/565) fails to compile (e.g. 32 bit targets). + ### Changed - BREAKING: Refactor CLI arguments ([#89]). diff --git a/Dockerfile b/Dockerfile index a397ab7..9bd0a53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ COPY Arial.ttf . # Also we can always build with vnc server support as the docker image contains all needed dependencies in any case # While the "native-display" feature compiles successfully, we'd rather not offer the CLI option, as it might cause # users to think it should work (which it doesn't). So let's not enable that feature -RUN RUSTFLAGS='' cargo build --release --no-default-features --features vnc,binary-set-pixel +RUN RUSTFLAGS='' cargo build --release --no-default-features --features prometheus,vnc,binary-set-pixel FROM debian:bookworm-slim AS final RUN apt-get update && \ diff --git a/README.md b/README.md index efa88b4..74c582c 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ Breakwater also has some compile-time features for dependency or performance rea You can get the list of available features by looking at the [Cargo.toml](Cargo.toml). As of writing the following features are supported: +* `prometheus` (enabled by default): Enables the Prometheus metrics exporter. Can be disabled to support compilation on 32-bit targets. * `egui` (enabled by default): Enables an advanced customizable graphical frontend on your local system. Please note that this requires a graphical environment. * `winit` (enabled by default): Enables a minimalist graphical window on your local system. Please note that this requires a graphical environment. * `ndi` (disabled by default): Enables NDI video streaming. This requires the proprietary NDI SDK to be installed, see below. diff --git a/breakwater/Cargo.toml b/breakwater/Cargo.toml index 359c910..e6a2335 100644 --- a/breakwater/Cargo.toml +++ b/breakwater/Cargo.toml @@ -30,7 +30,7 @@ memadvise.workspace = true ndi-sdk-sys = { workspace = true, optional = true } number_prefix = { workspace = true, optional = true } page_size.workspace = true -prometheus_exporter.workspace = true +prometheus_exporter = { workspace = true, optional = true } rusttype = { workspace = true, optional = true } serde_json.workspace = true serde.workspace = true @@ -52,8 +52,11 @@ rstest.workspace = true # VNC and NDI require shared libraries to be installed, so we don't enable them by default # Yes, egui and winit require a graphical environment, but most people getting started with # breakwater will likely do that on a desktop, servers admins generally know what they are doing (tm). -default = ["egui", "winit"] +# default = ["prometheus", "egui", "winit"] +# Enables the Prometheus metrics exporter. Can be disabled to support compilation on 32-bit targets. +# See https://github.com/tikv/rust-prometheus/issues/565 +prometheus = ["dep:prometheus_exporter"] alpha = ["breakwater-parser/alpha"] binary-set-pixel = ["breakwater-parser/binary-set-pixel"] binary-sync-pixels = ["breakwater-parser/binary-sync-pixels"] diff --git a/breakwater/src/main.rs b/breakwater/src/main.rs index 3b6880c..ee083ea 100644 --- a/breakwater/src/main.rs +++ b/breakwater/src/main.rs @@ -8,13 +8,13 @@ use tokio::sync::{broadcast, mpsc}; use crate::{ cli_args::CliArgs, - prometheus_exporter::PrometheusExporter, sinks::start_sinks, statistics::{Statistics, StatisticsEvent, StatisticsInformationEvent, StatisticsSaveMode}, }; mod cli_args; mod connection_buffer; +#[cfg(feature = "prometheus")] mod prometheus_exporter; mod server; mod sinks; @@ -89,7 +89,8 @@ async fn main() -> eyre::Result<()> { .await .context("failed to start pixelflut server")?; - let mut prometheus_exporter = PrometheusExporter::new( + #[cfg(feature = "prometheus")] + let mut prometheus_exporter = prometheus_exporter::PrometheusExporter::new( &args.prometheus_listen_address, statistics_information_rx.resubscribe(), ) @@ -97,6 +98,7 @@ async fn main() -> eyre::Result<()> { let server_listener_thread = tokio::spawn(async move { server.start().await }); let statistics_thread = tokio::spawn(async move { statistics.run().await }); + #[cfg(feature = "prometheus")] let prometheus_exporter_thread = tokio::spawn(async move { prometheus_exporter.run().await }); let (sink_tasks, ffmpeg_thread_present) = start_sinks( @@ -110,6 +112,7 @@ async fn main() -> eyre::Result<()> { .await .context("failed to start sinks")?; + #[cfg(feature = "prometheus")] prometheus_exporter_thread.abort(); server_listener_thread.abort(); From 9cc7abdce58a5c2d6a4bf0581f2d4930ccb674a3 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Fri, 19 Jun 2026 23:59:13 +0200 Subject: [PATCH 2/2] fix default features --- Cargo.lock | 22 ++++++++++++++++------ breakwater/Cargo.toml | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0b6bed..3802727 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -540,6 +540,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40e38929add23cdf8a366df9b0e088953150724bcbe5fc330b0d8eb3b328eec8" +[[package]] +name = "build-rs" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe808acca98fccf920154ee7833e791bfb683299be4aae7ec222ddffad8cd4f8" +dependencies = [ + "unicode-ident", +] + [[package]] name = "built" version = "0.8.1" @@ -649,9 +658,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.64" +version = "1.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" dependencies = [ "find-msvc-tools", "jobserver", @@ -2616,11 +2625,12 @@ dependencies = [ [[package]] name = "ndi-sdk-sys" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a02d95591a221df31af7b4e35e2763242285ad17261cf6848080c09adc8bd856" +checksum = "61ca2ac70dc3297d69edf73eeefae55dab6e3371cac820de1aae3badc9d43744" dependencies = [ "bindgen 0.71.1", + "build-rs", "num", "num_enum", "regex", @@ -5021,9 +5031,9 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.32.12" +version = "0.32.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "563a85523cade2429938e790815fd7319062103b9f4a2dc806e9b53b95982d8f" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" dependencies = [ "bitflags 2.13.0", "wayland-backend", diff --git a/breakwater/Cargo.toml b/breakwater/Cargo.toml index e6a2335..1c85089 100644 --- a/breakwater/Cargo.toml +++ b/breakwater/Cargo.toml @@ -52,7 +52,7 @@ rstest.workspace = true # VNC and NDI require shared libraries to be installed, so we don't enable them by default # Yes, egui and winit require a graphical environment, but most people getting started with # breakwater will likely do that on a desktop, servers admins generally know what they are doing (tm). -# default = ["prometheus", "egui", "winit"] +default = ["prometheus", "egui", "winit"] # Enables the Prometheus metrics exporter. Can be disabled to support compilation on 32-bit targets. # See https://github.com/tikv/rust-prometheus/issues/565