Christopher Poile and Jesse Hallam
65500cc820
MM Build 2025 - Skadoosh - Serve plugin metrics to standard /metrics endpoint ( #34678 )
...
* gather plugin metrics and serve on /metrics
* tests
* fix recent conflicts from master
* fix linting
* address review feedback: feature flag, route guard, and unit tests for plugin metrics
- Add PluginMetricsCollection feature flag (default true) to allow disabling plugin metric collection without a deploy
- Only wrap the /metrics handler with plugin metric collection (not arbitrary plugin routes, which would cause double-listing)
- Extract wrapping logic into wrapMetricsHandler for clarity
- Add unit tests for addPluginLabelToMetrics covering no-label, existing-label, comments, empty lines, and multiple metrics cases
* fix integration tests to use /metrics route so wrapMetricsHandler runs
* switch addPluginLabelToMetrics to use expfmt for correct label injection
Replace string manipulation with expfmt parse→mutate→re-encode, which
correctly handles all metric types, timestamps, and malformed input.
Output is normalized: blank lines are dropped and TYPE headers are
injected for undeclared metrics. Update unit tests accordingly.
* refine addPluginLabelToMetrics: log warnings, drop sort, use assert.Contains
- Log a warning (instead of silently discarding) on parse or encode errors,
returning empty string in both cases
- Remove name sorting — metric family order is irrelevant to Prometheus scrapers
- Switch unit test assertions to assert.Contains per line so tests are
order-independent
* replace strPtr helper with model.NewPointer
* fix gofmt: remove extra blank line
* replace existing plugin_id label instead of appending a duplicate
If a plugin already exports a plugin_id label, overwrite it rather than
appending a second one, which would produce invalid Prometheus output.
Add test coverage for the replace path.
* add missing test coverage per mattermost-build feedback
- Unit test: malformed input returns empty string without panicking
- Integration: PluginMetricsCollection=false excludes plugin metrics
- Integration: plugin returning non-200 status excluded from response
- Integration: plugin returning empty body excluded from response
* rename PluginMetricsCollection to AggregatePluginMetrics, default false
---------
Co-authored-by: Jesse Hallam <jesse@mattermost.com >
2026-04-22 15:04:13 +00:00
..
2023-05-10 13:07:02 -03:00
2026-04-16 04:02:12 +03:00
2026-04-16 04:02:12 +03:00
2026-04-16 04:02:12 +03:00
2025-11-11 15:24:42 -05:00
2025-11-11 15:24:42 -05:00
2026-03-30 16:20:47 +00:00
2026-03-30 16:20:47 +00:00
2023-05-10 13:07:02 -03:00
2026-04-16 00:48:43 +02:00
2025-07-18 12:54:51 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2024-06-22 23:08:55 +02:00
2023-05-10 13:07:02 -03:00
2025-11-11 15:24:42 -05:00
2025-11-11 15:24:42 -05:00
2026-01-26 17:05:34 -05:00
2026-02-09 18:32:26 -05:00
2024-10-29 13:29:53 +01:00
2025-03-31 10:44:34 +02:00
2024-08-06 09:15:00 +05:30
2025-01-10 17:33:12 -07:00
2024-03-26 08:43:25 -06:00
2023-05-10 13:07:02 -03:00
2023-06-11 10:54:35 +05:30
2025-08-05 12:07:24 +03:00
2025-02-09 21:38:29 -07:00
2025-03-31 10:44:34 +02:00
2025-11-04 12:09:11 +01:00
2023-06-13 14:08:36 +05:30
2023-10-11 10:13:36 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-09-05 08:06:16 -07:00
2026-04-15 01:41:33 -04:00
2026-03-10 16:37:21 +01:00
2026-03-10 16:37:21 +01:00
2025-05-15 11:33:08 +02:00
2023-05-10 13:07:02 -03:00
2026-04-14 09:00:59 -04:00
2023-05-10 13:07:02 -03:00
2026-01-20 17:46:17 +01:00
2023-05-10 13:07:02 -03:00
2026-04-14 09:00:59 -04:00
2026-01-29 14:26:47 +00:00
2026-01-29 14:26:47 +00:00
2026-03-10 16:37:21 +01:00
2026-04-16 00:48:43 +02:00
2025-07-15 12:58:18 -04:00
2023-05-10 13:07:02 -03:00
2024-03-22 10:44:38 +01:00
2023-08-10 09:40:49 +05:30
2026-02-09 18:32:26 -05:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-03-31 10:44:34 +02:00
2023-05-10 13:07:02 -03:00
2024-04-04 13:44:03 +02:00
2023-05-10 13:07:02 -03:00
2026-03-10 16:37:21 +01:00
2026-03-10 16:37:21 +01:00
2026-03-06 13:39:48 +01:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2026-03-06 13:39:48 +01:00
2023-05-10 13:07:02 -03:00
2023-10-11 10:13:36 +02:00
2025-03-31 10:44:34 +02:00
2026-04-16 16:42:50 +05:00
2026-04-16 16:42:50 +05:00
2025-10-13 12:24:01 +05:30
2025-10-13 12:24:01 +05:30
2026-03-06 21:15:01 -05:00
2026-03-06 21:15:01 -05:00
2026-03-06 21:15:01 -05:00
2025-11-13 12:00:54 +01:00
2026-04-13 08:13:58 -07:00
2024-03-04 15:53:55 -07:00
2025-06-09 15:41:07 -04:00
2023-05-10 13:07:02 -03:00
2025-12-11 07:59:50 +01:00
2025-08-05 09:09:07 -04:00
2023-10-17 11:57:35 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-03-31 10:44:34 +02:00
2026-01-20 17:46:17 +01:00
2023-05-10 13:07:02 -03:00
2026-04-22 15:04:13 +00:00
2023-06-30 20:12:56 +05:30
2023-05-10 13:07:02 -03:00
2024-03-12 08:36:05 -06:00
2026-02-16 17:10:39 +01:00
2023-07-19 13:01:39 -07:00
2026-04-08 16:49:43 -03:00
2026-04-08 16:49:43 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2024-04-12 19:41:50 +02:00
2023-05-10 13:07:02 -03:00
2025-03-31 10:44:34 +02:00
2025-03-31 10:44:34 +02:00
2025-03-31 10:44:34 +02:00
2025-03-31 10:44:34 +02:00
2023-05-10 13:07:02 -03:00
2026-03-10 16:37:21 +01:00
2023-05-10 13:07:02 -03:00
2026-03-26 17:19:15 -06:00
2026-03-26 17:19:15 -06:00
2024-08-06 09:15:00 +05:30
2025-03-31 10:44:34 +02:00
2024-06-17 12:07:05 -04:00
2026-02-02 15:52:42 -05:00
2025-06-16 16:19:33 -04:00
2025-05-02 11:34:46 +05:30
2026-01-26 17:05:34 -05:00
2026-03-10 10:31:10 -04:00
2026-02-09 16:26:14 +02:00
2026-02-09 16:26:14 +02:00
2025-12-11 14:04:43 -05:00
2026-03-25 13:41:33 +00:00
2025-10-27 13:16:59 -03:00
2025-10-27 13:16:59 -03:00
2026-01-29 14:26:47 +00:00
2025-03-31 10:44:34 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2026-03-10 16:37:21 +01:00
2026-03-10 16:37:21 +01:00
2025-01-10 16:56:02 -05:00
2024-11-29 11:24:35 +05:30
2026-03-25 13:41:33 +00:00
2023-05-10 13:07:02 -03:00
2026-04-16 00:48:43 +02:00
2023-05-10 13:07:02 -03:00
2025-12-08 20:41:29 +00:00
2023-11-11 19:33:28 +05:30
2026-02-19 01:06:08 +00:00
2026-02-19 01:06:08 +00:00
2025-11-19 09:50:25 -05:00
2025-11-11 17:43:37 +00:00
2025-12-10 08:31:53 +02:00
2025-03-31 10:44:34 +02:00
2024-08-06 09:15:00 +05:30
2025-03-31 10:44:34 +02:00
2023-05-10 13:07:02 -03:00
2026-03-10 16:37:21 +01:00
2025-11-18 08:52:05 +01:00
2026-03-25 13:41:33 +00:00
2023-05-10 13:07:02 -03:00
2023-12-11 10:27:51 +01:00
2026-04-16 00:48:43 +02:00
2023-05-10 13:07:02 -03:00
2024-11-01 06:30:25 -07:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2024-04-11 11:10:25 -04:00
2023-05-10 13:07:02 -03:00
2026-02-16 17:10:39 +01:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-06-16 02:30:21 +02:00
2023-06-15 08:23:56 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-12-11 07:59:50 +01:00
2026-04-16 04:02:12 +03:00
2025-11-17 09:02:19 -07:00
2025-03-31 10:44:34 +02:00
2026-03-27 10:36:35 +01:00
2026-03-27 16:29:06 +01:00
2024-07-25 15:57:23 -04:00
2026-04-20 12:46:36 +02:00
2023-05-10 13:07:02 -03:00
2026-03-26 07:54:50 +00:00
2026-02-06 16:21:51 -05:00
2026-02-06 16:21:51 -05:00
2026-04-21 18:59:12 +00:00
2026-04-21 18:59:12 +00:00
2026-03-27 10:36:35 +01:00
2025-09-19 18:52:34 +00:00
2026-04-14 09:00:59 -04:00
2023-10-11 10:13:36 +02:00
2026-03-30 13:41:32 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2024-08-06 09:15:00 +05:30
2025-12-11 07:59:50 +01:00
2026-01-19 13:46:43 -05:00
2026-04-14 11:37:09 +02:00
2026-04-14 11:37:09 +02:00
2026-03-12 12:50:53 -04:00
2026-04-15 14:57:46 +00:00
2026-04-16 00:48:43 +02:00
2023-05-10 13:07:02 -03:00
2026-03-18 09:14:17 -07:00
2026-03-18 09:14:17 -07:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-03-31 10:44:34 +02:00
2024-11-21 13:47:48 +00:00
2024-11-21 13:47:48 +00:00
2023-05-10 13:07:02 -03:00
2023-06-07 10:15:33 -03:00
2023-06-07 10:15:33 -03:00
2023-09-08 11:00:48 -03:00
2023-06-07 10:15:33 -03:00
2024-09-24 12:02:19 +02:00
2023-10-03 09:51:07 -05:00
2025-04-14 13:07:50 +02:00
2023-05-10 13:07:02 -03:00
2026-04-14 11:37:09 +02:00
2026-03-10 16:37:21 +01:00
2026-03-10 16:37:21 +01:00
2025-11-12 13:00:51 +01:00
2025-02-25 16:20:00 -05:00
2023-05-10 13:07:02 -03:00
2026-04-21 10:52:10 +00:00
2025-03-31 10:44:34 +02:00
2026-03-09 14:07:44 -04:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2026-04-09 16:12:15 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2025-03-31 10:44:34 +02:00
2025-12-11 07:59:50 +01:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2024-08-29 14:06:41 +02:00
2024-11-14 16:57:15 +08:00
2025-11-20 14:06:23 +01:00
2023-05-10 13:07:02 -03:00
2026-02-25 10:18:51 -05:00
2026-02-25 10:18:51 -05:00
2023-05-10 13:07:02 -03:00
2025-03-31 10:44:34 +02:00
2024-11-01 06:30:25 -07:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2026-01-19 16:10:57 -05:00
2023-08-14 17:54:10 +02:00
2025-06-13 16:51:12 +02:00
2023-05-10 13:07:02 -03:00
2024-09-17 00:44:32 +02:00
2023-05-10 13:07:02 -03:00
2023-05-10 13:07:02 -03:00
2026-04-01 15:20:12 +00:00
2026-04-01 15:20:12 +00:00
2023-05-10 13:07:02 -03:00
2024-09-17 00:44:32 +02:00
2026-04-08 16:49:43 -03:00
2026-04-08 16:49:43 -03:00
2023-05-10 13:07:02 -03:00
2026-04-07 09:34:34 +03:00
2026-03-27 10:36:35 +01:00
2026-03-27 10:36:35 +01:00
2025-07-18 12:54:51 +02:00
2023-12-21 08:42:58 +05:30
2025-10-27 13:16:59 -03:00
2026-04-03 02:06:01 -04:00
2024-06-13 09:01:49 +02:00
2023-12-11 15:27:34 -05:00