feat(telemetry): runtime endpoint config + opt-in by default (#73)#190
Open
quangdang46 wants to merge 1 commit into
Open
feat(telemetry): runtime endpoint config + opt-in by default (#73)#190quangdang46 wants to merge 1 commit into
quangdang46 wants to merge 1 commit into
Conversation
Two related changes that move telemetry from "baked-in URL, on by
default" to "runtime-resolved URL, opt-in by default":
1. Drop the const TELEMETRY_ENDPOINT pointing at upstream's Cloudflare
Worker. Replace it with a runtime resolver telemetry_endpoint()
that reads, in order:
a. JCODE_TELEMETRY_ENDPOINT environment variable
b. endpoint = "..." in ${JCODE_HOME:-~/.jcode}/telemetry.toml
c. None
Empty / whitespace-only values resolve to None so a user can
disable telemetry by setting JCODE_TELEMETRY_ENDPOINT="" without
needing the separate JCODE_NO_TELEMETRY knob.
2. is_enabled() now requires telemetry_endpoint().is_some(). The pre-
existing JCODE_NO_TELEMETRY / DO_NOT_TRACK / no_telemetry marker
short-circuits still apply on top.
3. post_payload() resolves the endpoint at send time and returns false
if the resolver yields None, so even if a caller bypasses
is_enabled(), no event leaves the process without an explicitly
configured endpoint.
Three tests in src/telemetry/tests.rs pin the contract:
- telemetry_endpoint_returns_none_without_config
- telemetry_endpoint_picks_up_env_var (incl. whitespace -> None)
- telemetry_endpoint_picks_up_telemetry_toml
Ports upstream PR 1jehuang#77.
Closes #73
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Two related changes that move telemetry from "baked-in URL, on by default" to "runtime-resolved URL, opt-in by default":
This addresses issue #73: #73
Changes
TELEMETRY_ENDPOINTpointing at upstream's Cloudflare Worker.telemetry_endpoint()runtime resolver. Resolution order:JCODE_TELEMETRY_ENDPOINTenvironment variable.endpoint = "..."in${JCODE_HOME:-~/.jcode}/telemetry.toml.None— telemetry is disabled (the fork's default).NonesoJCODE_TELEMETRY_ENDPOINT=""reliably disables telemetry without needing the separateJCODE_NO_TELEMETRYknob.is_enabled()now requirestelemetry_endpoint().is_some(). ExistingJCODE_NO_TELEMETRY/DO_NOT_TRACK/no_telemetrymarker short-circuits still apply.post_payload()resolves the endpoint at send time; ifNone, returnsfalseimmediately so no event leaves the process without an explicit endpoint.telemetry_endpoint_returns_none_without_configtelemetry_endpoint_picks_up_env_var(incl. whitespace → None)telemetry_endpoint_picks_up_telemetry_tomlTests
Notes
Ports upstream PR 1jehuang#77.