Skip to content

fix: correct unit mismatch in php.compilation.total_time_ms#3915

Open
dortort wants to merge 1 commit into
DataDog:masterfrom
dortort:fix/compile-time-unit-mismatch
Open

fix: correct unit mismatch in php.compilation.total_time_ms#3915
dortort wants to merge 1 commit into
DataDog:masterfrom
dortort:fix/compile-time-unit-mismatch

Conversation

@dortort
Copy link
Copy Markdown

@dortort dortort commented May 24, 2026

Description

PR #2230 (v0.98.0) replaced _get_microseconds() (which used clock_gettime and returned microseconds) with zend_hrtime() (which returns nanoseconds) in ext/engine_hooks.c, but did not update the accumulator. The serializer in ext/serializer.c divides by 1000. expecting microseconds → milliseconds, so since v0.98.0 the metric php.compilation.total_time_ms has been reporting microseconds labeled as milliseconds — a 1000x inflation.

The same PR correctly handled this conversion in circuit_breaker.c (return zend_hrtime() / 1000;). This change applies the same pattern to the compile time accumulator.

Evidence

A request with a total duration of ~4,350 ms reported php.compilation.total_time_ms of ~28,346 — impossible if in milliseconds (exceeds request duration), but consistent with ~28.3 ms when interpreted as microseconds.

Fixes #3914

PR DataDog#2230 replaced _get_microseconds() (which returned microseconds via
clock_gettime) with zend_hrtime() (which returns nanoseconds) without
updating the accumulator. The serializer divides by 1000 expecting
microseconds, so the metric has been reporting microseconds labeled
as milliseconds since v0.98.0.

Convert nanoseconds to microseconds at the accumulator to restore
correct behavior, matching the pattern used in circuit_breaker.c
from the same PR.

Fixes DataDog#3914
@dortort dortort requested a review from a team as a code owner May 24, 2026 15:39
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.

php.compilation.total_time_ms reports microseconds instead of milliseconds since v0.98.0

1 participant