mirror of
https://github.com/coturn/coturn.git
synced 2026-10-24 00:08:57 +03:00
## Summary The Prometheus exporter previously linked the [digitalocean/prometheus-client-c](https://github.com/digitalocean/prometheus-client-c) (`prom`) library, which is **no longer maintained**. This replaces it with a minimal, self-contained Prometheus client under `src/prometheus/` that is built straight from coturn's own sources and implements exactly the slice of the API coturn uses: counters, gauges, a single default registry, and the text-exposition serializer. The vendored client is **drop-in API-compatible**, so `prom_server.c` is unchanged. Histograms, summaries, custom registries and the upstream `promhttp` handler are intentionally omitted (coturn serves `/metrics` with its own libmicrohttpd handler). The exporter is now **always compiled in**; the runtime `--prometheus` flag still controls whether it starts. **libmicrohttpd** — actively maintained — is the only remaining external dependency and is now required by the build. ## Changes - **`src/prometheus/{prom.h,prom.c}`** — vendored client. Thread-safe (per-metric mutex on the increment path, read under lock in the bridge), label-aware, with proper Prometheus value/label escaping and clean integer formatting for counters. No deps beyond pthread/libc. - **CMake** — replace `find_package(Prometheus)` with required `find_package(MicroHTTPD)`; add `cmake/FindMicroHTTPD.cmake`; remove dead `cmake/FindPrometheus.cmake` and the `WITH_PROMETHEUS` option. - **`configure` / `Makefile.in`** — drop `-lprom`, compile the vendored source. - **Docker** (`debian`, `alpine`) and **CI** (`ubuntu-build-deps`, `mingw`) — remove the `prometheus-client-c` build/install steps; keep libmicrohttpd. - **`docs/Prometheus.md`** rewritten. - **`tests/test_prometheus.c`** — Unity tests for counter accumulation/monotonicity, gauge inc/dec, and label-value escaping. ## Validation - Full build green; all unit tests pass (incl. new `test_prometheus`); `clang-format-15` clean. - Live exporter scraped over HTTP — all `run_tests_prom.sh` scenarios (default / custom address / port / path, plus the negative case) pass. --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.4 KiB
CMake
41 lines
1.4 KiB
CMake
# Find libmicrohttpd.
|
|
#
|
|
# libmicrohttpd serves coturn's Prometheus /metrics endpoint. This module
|
|
# locates it.
|
|
#
|
|
# Set MicroHTTPD_DIR or MicroHTTPD_ROOT (variable or environment) to point at a
|
|
# non-standard install prefix.
|
|
#
|
|
# Defines on success:
|
|
# MicroHTTPD_FOUND - libmicrohttpd was found
|
|
# MicroHTTPD_INCLUDE_DIRS - include directories
|
|
# MicroHTTPD_LIBRARIES - libraries to link
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package(PkgConfig QUIET)
|
|
pkg_check_modules(PC_microhttpd QUIET libmicrohttpd)
|
|
|
|
find_path(MicroHTTPD_INCLUDE_DIR
|
|
NAMES microhttpd.h
|
|
HINTS ${MicroHTTPD_DIR} ${MicroHTTPD_ROOT} ${PC_microhttpd_INCLUDE_DIRS} /usr
|
|
PATHS $ENV{MicroHTTPD_DIR} $ENV{MicroHTTPD_ROOT}
|
|
PATH_SUFFIXES include
|
|
)
|
|
|
|
# vcpkg (Windows) installs the import library as "libmicrohttpd", so accept
|
|
# both that and the bare "microhttpd" used by *NIX distributions.
|
|
find_library(MicroHTTPD_LIBRARY
|
|
NAMES microhttpd libmicrohttpd microhttpd-dll libmicrohttpd-dll
|
|
HINTS ${MicroHTTPD_DIR} ${MicroHTTPD_ROOT} ${PC_microhttpd_LIBRARY_DIRS}
|
|
PATHS $ENV{MicroHTTPD_DIR} $ENV{MicroHTTPD_ROOT}
|
|
PATH_SUFFIXES lib ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
find_package_handle_standard_args(MicroHTTPD
|
|
REQUIRED_VARS MicroHTTPD_LIBRARY MicroHTTPD_INCLUDE_DIR)
|
|
|
|
set(MicroHTTPD_INCLUDE_DIRS ${MicroHTTPD_INCLUDE_DIR})
|
|
set(MicroHTTPD_LIBRARIES ${MicroHTTPD_LIBRARY})
|
|
|
|
mark_as_advanced(MicroHTTPD_INCLUDE_DIR MicroHTTPD_LIBRARY)
|