Skip to content

fix: report total threads as gauge (#2481)#2550

Merged
alexandre-daubois merged 1 commit into
php:mainfrom
ousamabenyounes:fix/issue-2481
Jul 22, 2026
Merged

fix: report total threads as gauge (#2481)#2550
alexandre-daubois merged 1 commit into
php:mainfrom
ousamabenyounes:fix/issue-2481

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Summary

Fix #2481

  • Register frankenphp_total_threads as a Prometheus gauge.
  • Report the current configured thread count with Set instead of accumulating with Add.
  • Update metric test expectations for the Caddy integration tests.

Test verification (RED -> GREEN)

RED, on main with only the new regression test added:

--- FAIL: TestPrometheusMetrics_TotalThreadsReportsCurrentValue (0.00s)
    metrics_test.go:40:
        Error:       Received unexpected error:
                     # HELP frankenphp_total_threads Total number of PHP threads
                    -# TYPE frankenphp_total_threads counter
                    -frankenphp_total_threads 5
                    +# TYPE frankenphp_total_threads gauge
                    +frankenphp_total_threads 2
FAIL

GREEN, after the fix:

ok  	command-line-arguments	0.009s

Additional targeted metrics run:

ok  	command-line-arguments	0.008s

Full local suite

Local environment notes:

  • The host does not have Go installed, so validation was run in Docker.
  • go test ./... in a plain Go container failed before tests because native PHP/watcher headers were absent.
  • go test -tags nowatcher ./... with php-dev reached native linking but failed because the minimal container lacked PHP link libraries.
  • After adding PHP link libraries, the focused root-package command passed:
ok  	github.com/dunglas/frankenphp	0.032s
  • The complete root-package run with the same native dependencies was killed by the container with exit code 137 before producing test results.

Files changed

File Change
metrics.go Change totalThreads from Counter to Gauge and use Set.
metrics_test.go Add regression coverage for type and current-value semantics.
caddy/caddy_test.go Update expected metric type to gauge.

Use a Prometheus gauge for frankenphp_total_threads so reconfiguration reports the current thread count instead of accumulating values.
@alexandre-daubois
alexandre-daubois merged commit b1ccb0e into php:main Jul 22, 2026
13 checks passed
@alexandre-daubois

Copy link
Copy Markdown
Member

Thank you @ousamabenyounes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

frankenphp_total_threads is registered as a Counter but is semantically a Gauge

3 participants