Repository navigation
fix(telemetry): send the shared-hosting env signals the Worker expects - #1606
Merged
Merged
Conversation
sbpp/cf-analytics#4 extended schema-1 with env.sapi, three env doubles (memory_limit_mb, max_execution_time, disable_functions_count) and twelve env bits, and called for a paired panel change. That change never landed, so every ping arrived without them and the Analytics Engine rows carried null / 0 in those slots for every install. Add Sbpp\Telemetry\HostFingerprint, which computes the 16 fields per cf-analytics#3 (each probe Throwable-guarded; open_basedir value, DOCUMENT_ROOT and the disable_functions list reduced to a boolean or count), and merge it into Telemetry::collectEnv(). Extend the vendored JSON Schema and the parity test to match. memory_limit_mb is null on unlimited hosts. The Worker's zod schema rejects an explicit null (whole ping 400s), so send() now drops null leaves and the Worker sees the key as absent, which it maps to a null double as intended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Bwe7AmJS69ccciKdc2PPQi
|
Thanks for the PR! This change touches To sign, comment exactly the following line on this PR:
You only need to sign once — your signature applies to every future See I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In the telemetry Analytics Engine data,
env.sapi,env.memory_limit_mb,env.max_execution_time,env.disable_functions_countand all 12 newenv.*bits are always null or 0. The Worker is fine: it validates and maps every one of these fields. The cause is on the panel side: it never sends them.sbpp/cf-analytics#4 added these fields to schema-1. Its issue (sbpp/cf-analytics#3) listed a "lockstep panel-side work" item: a
HostFingerprinthelper, a re-vendored schema and a wider parity test. That work never landed, soTelemetry::collectEnv()still sends only the original five fields.This PR:
Sbpp\Telemetry\HostFingerprint, which computes the 16 fields as specified in cf-analytics#3.Throwable. If a host disablesini_getorposix_*, oropen_basedirblocks the/usr/local/*checks, only that one field falls back. The ping still goes out.open_basedirvalue,DOCUMENT_ROOTand thedisable_functionslist are reduced to a boolean or a count before they leave the class.sapi_per_userfollows the issue's leaning on its open question. The effective uid must own the panel files, be at least 1000 and not benobody. Without POSIX it returnsfalse.docroot_user_homealso matches/home2,/home3and so on (cPanel's multi-disk layout).collectEnv()and adds them (with descriptions) to the vendoredschema-1.lock.json.nullvalues from the wire body. On hosts with no memory limit (memory_limit = -1),memory_limit_mbisnull. The Worker's zod schema uses.optional(), which rejects an explicitnull, so the whole ping would get a 400.collect()keeps thenullso the parity test sees the same set of keys every time.send()strips it, the Worker treats the key as missing, and it stores a null double as intended.updating/1-8-to-2-0.mdx, and updatesARCHITECTURE.mdandAGENTS.md.Separate pre-existing issue, not fixed here:
make sync-telemetry-schemadownloadscf-analytics/schema/1.lock.json. That file is the Worker's AE slot layout (blobs,doubles,bits), not a Draft-7 JSON Schema. Running the target would overwrite the panel's schema with a fileSchema1can't read. That's why the schema change here was made by hand.Motivation and Context
Without these fields we can't tell shared-hosting installs from other installs, so the
host_kindanalysis in the cf-analytics README can't be run.How Has This Been Tested?
./sbpp.sh test --filter='HostFingerprint|Telemetry': 32 tests pass. That includes the parity test in both directions and the newHostFingerprintTest, which covers thememory_limitparser, thedisable_functionscount, the docroot regex, a check that the raw docroot never appears in the output, andwithoutNulls../sbpp.sh test: 1232 tests, 6 errors, all inPluginVersionResolveTest($incBackupTypeError). The same 6 fail onmainin the same environment../sbpp.sh phpstan: no errors.-d memory_limit=-1. I ran both through the Worker's ownvalidate()andmapDataPoint(). Both validate.env.sapi,memory_limit_mb(256, or null when unlimited),max_execution_timeanddisable_functions_countland in their slots, and all 12 env bits match the payload. I also confirmed thatvalidate()rejectsmemory_limit_mb: null, which is why the null-stripping is needed.docker build -f docker/Dockerfile.prod .(amd64 only, no qemu available) succeeds, andHostFingerprint::collect()runs inside the built image.Types of changes
Checklist:
Generated by Claude Code