diff --git a/CHANGELOG.md b/CHANGELOG.md index 29220c3..adc7bd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.2] - 2026-02-02 + +### Added + +- Option to disable early mode in admin settings (Metrics tab) +- Support for `WP_PROMETHEUS_DISABLE_EARLY_MODE` environment variable +- Early mode status display in settings + +### Changed + +- Early mode can now be disabled for users who need the `wp_prometheus_collect_metrics` hook for custom metrics +- Updated translations with new early mode strings (English and German) + ## [0.4.1] - 2026-02-02 ### Fixed diff --git a/CLAUDE.md b/CLAUDE.md index f6c518f..8fadf55 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -291,6 +291,24 @@ add_action( 'wp_prometheus_collect_metrics', function( $collector ) { ## Session History +### 2026-02-02 - Early Mode Toggle (v0.4.2) + +- Added option to disable early mode for users who need extensibility +- Implementation: + - Added `wp_prometheus_disable_early_mode` WordPress option + - Added `WP_PROMETHEUS_DISABLE_EARLY_MODE` environment variable support + - Option check in `wp_prometheus_early_metrics_check()` before early interception + - Environment variable accepts `1`, `true`, `yes`, `on` (case-insensitive) +- Admin UI in Metrics tab: + - "Early Mode" section with description of functionality + - Checkbox to disable early metrics interception + - Environment override notice when env var is set + - Current status indicator showing early mode state +- **Key Learning**: Balancing compatibility vs extensibility + - Early mode fixes memory issues but disables `wp_prometheus_collect_metrics` hook + - Users with custom metrics need the hook, so early mode must be optional + - Default remains enabled (safe) with explicit opt-out for advanced users + ### 2026-02-02 - Plugin Compatibility Fix (v0.4.1) - Fixed memory exhaustion (1GB limit) when wp-fedistream (Twig-based) plugin is active diff --git a/languages/wp-prometheus-de_CH.mo b/languages/wp-prometheus-de_CH.mo index 94f2636..0ec05dd 100644 Binary files a/languages/wp-prometheus-de_CH.mo and b/languages/wp-prometheus-de_CH.mo differ diff --git a/languages/wp-prometheus-de_CH.po b/languages/wp-prometheus-de_CH.po index aa79840..4dd24e4 100644 --- a/languages/wp-prometheus-de_CH.po +++ b/languages/wp-prometheus-de_CH.po @@ -3,7 +3,7 @@ # This file is distributed under the GPL v2 or later. msgid "" msgstr "" -"Project-Id-Version: WP Prometheus 0.4.0\n" +"Project-Id-Version: WP Prometheus 0.4.2\n" "Report-Msgid-Bugs-To: https://src.bundespruefstelle.ch/magdev/wp-prometheus/issues\n" "POT-Creation-Date: 2026-02-02T00:00:00+00:00\n" "PO-Revision-Date: 2026-02-02T00:00:00+00:00\n" @@ -879,3 +879,43 @@ msgstr "APCu funktioniert. Speicher: %s belegt." #: src/Metrics/StorageFactory.php msgid "APCu fetch operation returned unexpected value." msgstr "APCu-Abrufoperation hat unerwarteten Wert zurueckgegeben." + +#: src/Admin/Settings.php +msgid "Early Mode" +msgstr "Fruehzeitiger Modus" + +#: src/Admin/Settings.php +msgid "Early mode intercepts /metrics requests before full WordPress initialization. This prevents memory exhaustion issues caused by some plugins (e.g., Twig-based themes/plugins) but disables the wp_prometheus_collect_metrics hook for custom metrics." +msgstr "Der fruehzeitige Modus faengt /metrics-Anfragen vor der vollstaendigen WordPress-Initialisierung ab. Dies verhindert Speichererschoepfungsprobleme, die durch einige Plugins verursacht werden (z.B. Twig-basierte Themes/Plugins), deaktiviert jedoch den wp_prometheus_collect_metrics-Hook fuer benutzerdefinierte Metriken." + +#: src/Admin/Settings.php +msgid "Early mode is configured via WP_PROMETHEUS_DISABLE_EARLY_MODE environment variable. Admin settings will be ignored." +msgstr "Der fruehzeitige Modus ist ueber die Umgebungsvariable WP_PROMETHEUS_DISABLE_EARLY_MODE konfiguriert. Admin-Einstellungen werden ignoriert." + +#: src/Admin/Settings.php +msgid "Disable Early Mode" +msgstr "Fruehzeitigen Modus deaktivieren" + +#: src/Admin/Settings.php +msgid "Disable early metrics interception" +msgstr "Fruehzeitige Metriken-Abfangung deaktivieren" + +#: src/Admin/Settings.php +msgid "When disabled, metrics are collected through normal WordPress template loading. This enables the wp_prometheus_collect_metrics hook for custom metrics but may cause issues with some plugins." +msgstr "Wenn deaktiviert, werden Metriken ueber das normale WordPress-Template-Laden erfasst. Dies aktiviert den wp_prometheus_collect_metrics-Hook fuer benutzerdefinierte Metriken, kann jedoch Probleme mit einigen Plugins verursachen." + +#: src/Admin/Settings.php +msgid "Early mode is active (this request was served via early interception)" +msgstr "Fruehzeitiger Modus ist aktiv (diese Anfrage wurde ueber fruehzeitige Abfangung verarbeitet)" + +#: src/Admin/Settings.php +msgid "Early mode is disabled" +msgstr "Fruehzeitiger Modus ist deaktiviert" + +#: src/Admin/Settings.php +msgid "Early mode is enabled (active for /metrics requests)" +msgstr "Fruehzeitiger Modus ist aktiviert (aktiv fuer /metrics-Anfragen)" + +#: src/Admin/Settings.php +msgid "Clear all accumulated runtime metric data (HTTP requests, database queries). This is useful for testing or starting fresh." +msgstr "Alle gesammelten Laufzeit-Metrikdaten loeschen (HTTP-Anfragen, Datenbank-Abfragen). Dies ist nuetzlich zum Testen oder fuer einen Neuanfang." diff --git a/languages/wp-prometheus.pot b/languages/wp-prometheus.pot index 52a8a1c..2e86aa8 100644 --- a/languages/wp-prometheus.pot +++ b/languages/wp-prometheus.pot @@ -2,7 +2,7 @@ # This file is distributed under the GPL v2 or later. msgid "" msgstr "" -"Project-Id-Version: WP Prometheus 0.4.0\n" +"Project-Id-Version: WP Prometheus 0.4.2\n" "Report-Msgid-Bugs-To: https://src.bundespruefstelle.ch/magdev/wp-prometheus/issues\n" "POT-Creation-Date: 2026-02-02T00:00:00+00:00\n" "MIME-Version: 1.0\n" @@ -876,3 +876,43 @@ msgstr "" #: src/Metrics/StorageFactory.php msgid "APCu fetch operation returned unexpected value." msgstr "" + +#: src/Admin/Settings.php +msgid "Early Mode" +msgstr "" + +#: src/Admin/Settings.php +msgid "Early mode intercepts /metrics requests before full WordPress initialization. This prevents memory exhaustion issues caused by some plugins (e.g., Twig-based themes/plugins) but disables the wp_prometheus_collect_metrics hook for custom metrics." +msgstr "" + +#: src/Admin/Settings.php +msgid "Early mode is configured via WP_PROMETHEUS_DISABLE_EARLY_MODE environment variable. Admin settings will be ignored." +msgstr "" + +#: src/Admin/Settings.php +msgid "Disable Early Mode" +msgstr "" + +#: src/Admin/Settings.php +msgid "Disable early metrics interception" +msgstr "" + +#: src/Admin/Settings.php +msgid "When disabled, metrics are collected through normal WordPress template loading. This enables the wp_prometheus_collect_metrics hook for custom metrics but may cause issues with some plugins." +msgstr "" + +#: src/Admin/Settings.php +msgid "Early mode is active (this request was served via early interception)" +msgstr "" + +#: src/Admin/Settings.php +msgid "Early mode is disabled" +msgstr "" + +#: src/Admin/Settings.php +msgid "Early mode is enabled (active for /metrics requests)" +msgstr "" + +#: src/Admin/Settings.php +msgid "Clear all accumulated runtime metric data (HTTP requests, database queries). This is useful for testing or starting fresh." +msgstr "" diff --git a/src/Admin/Settings.php b/src/Admin/Settings.php index 8ee4167..0761488 100644 --- a/src/Admin/Settings.php +++ b/src/Admin/Settings.php @@ -118,6 +118,12 @@ class Settings { 'sanitize_callback' => array( $this, 'sanitize_metrics' ), ) ); + register_setting( 'wp_prometheus_metrics_settings', 'wp_prometheus_disable_early_mode', array( + 'type' => 'boolean', + 'sanitize_callback' => 'rest_sanitize_boolean', + 'default' => false, + ) ); + // Auth token section. add_settings_section( 'wp_prometheus_auth_section', @@ -420,6 +426,66 @@ class Settings {

+ +
+ + render_early_mode_section(); ?> + +

+

+ +

+ + +
+ +

+
+ + + + + + + + + + + +