diff --git a/README.md b/README.md index 10359b1d..b589660d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ SQLFlow is a stream processing engine that lets you define pipelines with just S One click runs SQLFlow on Render: a webhook that accepts metrics, a one-minute aggregation into Postgres, and an HTTP API that reads them back. It asks for -one secret and is a paid deploy. See [`render/`](render/README.md). +a signing secret and a client id, and is a paid deploy. Telemetry is off. See +[`render/`](render/README.md). # Quick Start (Getting Started in 5 Minutes) diff --git a/render.yaml b/render.yaml index 035043dc..e3dc95c7 100644 --- a/render.yaml +++ b/render.yaml @@ -5,8 +5,8 @@ # This file is at the repository root because the button reads it from there. # Everything it deploys is under render/. # -# The deploy asks for three values. The first two are yours to choose, so you -# have them when the deploy finishes. `openssl rand -hex 32` and `openssl rand -hex 16` +# The deploy asks for two values. Both are yours to choose, so you have them +# when the deploy finishes. `openssl rand -hex 32` and `openssl rand -hex 16` # make good ones. # SQLFLOW_WEBHOOK_HMAC_SECRET signs what you send. A blank one fails the # ingest service: the pipeline will not start @@ -14,11 +14,11 @@ # SQLFLOW_SERVE_CLIENT_ID reads what you sent, as ?client_id=. A blank # one fails the API service. Letters, digits, # '.', '_', '~' and '-' only. -# SQLFLOW_TELEMETRY leave it blank, or type off. Blank sends the -# sqlflow maintainers two events, ever: that -# this was deployed, and that it received its -# first metric. render/README.md, "What this -# sends", prints both in full. +# +# Telemetry is off: SQLFLOW_TELEMETRY is unset, and the deploy does not ask +# for it. Setting it to on sends the sqlflow maintainers two events, ever: +# that this was deployed, and that it received its first metric. +# render/README.md, "What this sends", prints both in full. databases: - name: sqlflow-metrics-db plan: 0.1c-256mb @@ -59,11 +59,10 @@ services: # Prompted for during the deploy. - key: SQLFLOW_WEBHOOK_HMAC_SECRET sync: false - # Prompted for during the deploy, so that it is seen before anything is - # sent rather than found afterwards. Blank is on. off sends nothing. - # sync: false also means a later sync never touches what was typed. - - key: SQLFLOW_TELEMETRY - sync: false + # SQLFLOW_TELEMETRY is not here, on purpose. Unset, nothing is sent. + # To opt in, add it to this service in the dashboard with the value on. + # A variable this file does not name survives a sync, so the opt-in is + # kept. # SQLFLOW_WEBHOOK_AUTH is not here, on purpose. Unset, the pipeline # requires a signature. To accept unsigned requests, add it to this # service in the dashboard with the value none. Render keeps a variable diff --git a/render/README.md b/render/README.md index 57190a8d..e7007107 100644 --- a/render/README.md +++ b/render/README.md @@ -12,9 +12,8 @@ services, in `virginia`. Render shows the price before you confirm. ## Deploy -Render asks for three values. Make the first two before you click, and keep -them. You choose both, so you have -them when the deploy finishes: +Render asks for two values. Make both before you click, and keep them. You +choose both, so you have them when the deploy finishes: ```sh openssl rand -hex 32 # SQLFLOW_WEBHOOK_HMAC_SECRET @@ -25,7 +24,6 @@ openssl rand -hex 16 # SQLFLOW_SERVE_CLIENT_ID |---|---| | `SQLFLOW_WEBHOOK_HMAC_SECRET` | Signs what you send. Any long random string. | | `SQLFLOW_SERVE_CLIENT_ID` | Reads what you sent, as `?client_id=`. Letters, digits, `.`, `_`, `~` and `-` only, so it can be pasted into a URL. | -| `SQLFLOW_TELEMETRY` | Leave it blank, or type `off`. See [What this sends](#what-this-sends). | A blank value fails its service, on purpose. The pipeline writes to your database and will not start unsigned unless you set @@ -39,10 +37,10 @@ When the deploy finishes, copy the URLs of `sqlflow-metrics-ingest` and ## What this sends -Unless you type `off` at the `SQLFLOW_TELEMETRY` prompt, this deploy sends the -sqlflow maintainers two events, once each, for as long as it exists. They -tell us that the template was deployed and that it worked. This is the whole -of both: +Nothing. The deploy leaves `SQLFLOW_TELEMETRY` unset and does not ask for it. +If you set it to `on`, this deploy sends the sqlflow maintainers two events, +once each, for as long as it exists. They tell us that the template was +deployed and that it worked. This is the whole of both: ```json {"name": "install.deployed", "type": "count", "value": 1, @@ -73,12 +71,12 @@ address it came from. The pipeline neither reads nor stores it. Render's request log for that service holds it for a while, as any host's does. The ingest service logs each event in full when it sends it. `bin/telemetry.sh` -is 91 lines and is the only code that sends anything. The sqlflow +is 97 lines and is the only code that sends anything. The sqlflow binary itself never phones home. -**To turn it off**, type `off` at the prompt, or set `SQLFLOW_TELEMETRY=off` on -`sqlflow-metrics-ingest` later. `false`, `0` and `no` also work. Nothing is -sent, and the log says so. +**To turn it on**, add `SQLFLOW_TELEMETRY=on` to `sqlflow-metrics-ingest` in +the Render dashboard. `true`, `1` and `yes` also work. Any other value, blank +included, sends nothing, and the log says so. A collector that is down, slow or gone never affects your deploy. A send is bounded at five seconds, runs in the background, and is retried later. @@ -273,7 +271,7 @@ not name and rewrites one it does, so a setting made here survives a sync. | `SQLFLOW_WEBHOOK_HMAC_SECRET` | | Required under `hmac`. | | `SQLFLOW_METRIC_NAME_PREFIX` | empty | When set, a metric whose name does not start with it is dropped. Letters, digits, `.`, `_` and `-`. | | `SQLFLOW_WEBHOOK_MAX_BODY_BYTES` | 26214400 | A larger body is refused with 413. | -| `SQLFLOW_TELEMETRY` | on | `off` sends nothing. See [What this sends](#what-this-sends). | +| `SQLFLOW_TELEMETRY` | off | `on` sends two events. See [What this sends](#what-this-sends). | ## Run it locally diff --git a/render/bin/entrypoint.sh b/render/bin/entrypoint.sh index 69ddddf8..6f2b89bf 100755 --- a/render/bin/entrypoint.sh +++ b/render/bin/entrypoint.sh @@ -63,9 +63,10 @@ export SQLFLOW_WRITER_ID /app/bin/migrate.sh # Two events per install, ever, to the sqlflow maintainers: that this was -# deployed, and that it received its first metric. SQLFLOW_TELEMETRY=off stops -# both. In the background and detached from this script's fate: it logs and -# swallows its own failures, and nothing it does can stop the pipeline below. +# deployed, and that it received its first metric. Off unless +# SQLFLOW_TELEMETRY=on. In the background and detached from this script's +# fate: it logs and swallows its own failures, and nothing it does can stop +# the pipeline below. /app/bin/telemetry.sh & # exec keeps sqlflow as PID 1, so the platform's SIGTERM reaches it and the diff --git a/render/bin/telemetry.sh b/render/bin/telemetry.sh index 7f9f96f3..33903327 100755 --- a/render/bin/telemetry.sh +++ b/render/bin/telemetry.sh @@ -3,7 +3,9 @@ # received its first metric. Two events, each sent once per install, and # nothing else, ever. render/README.md, "What this sends", prints both. # -# SQLFLOW_TELEMETRY=off sends nothing. Also: false, 0, no. +# Off by default. +# SQLFLOW_TELEMETRY=on sends the two events. Also: true, 1, yes. +# anything else sends nothing, blank and unset included. # # bin/entrypoint.sh starts this in the background after the migrations. It must # never be the reason a pipeline does not start or stops: every failure here is @@ -13,9 +15,10 @@ set -uo pipefail log() { echo "telemetry: $*" >&2; } -case "$(printf '%s' "${SQLFLOW_TELEMETRY:-on}" | tr '[:upper:]' '[:lower:]')" in - off|false|0|no) - log "off (SQLFLOW_TELEMETRY=${SQLFLOW_TELEMETRY}). Nothing is sent." +case "$(printf '%s' "${SQLFLOW_TELEMETRY:-}" | tr '[:upper:]' '[:lower:]')" in + on|true|1|yes) ;; + *) + log "off (SQLFLOW_TELEMETRY=${SQLFLOW_TELEMETRY:-}). Nothing is sent. Set it to on to send two events; see render/README.md." exit 0 ;; esac diff --git a/render/docker-compose.yml b/render/docker-compose.yml index f7d14eb6..8f45ac93 100644 --- a/render/docker-compose.yml +++ b/render/docker-compose.yml @@ -50,7 +50,7 @@ services: SQLFLOW_WEBHOOK_HMAC_SECRET: ${SQLFLOW_WEBHOOK_HMAC_SECRET-local-secret} SQLFLOW_WEBHOOK_PORT: "10000" SQLFLOW_METRIC_NAME_PREFIX: ${SQLFLOW_METRIC_NAME_PREFIX:-} - # No value: on unless the caller says off, as on Render. + # No value: off unless the caller says on, as on Render. SQLFLOW_TELEMETRY: SQLFLOW_TELEMETRY_URL: ${SQLFLOW_TELEMETRY_URL:-http://collector:10000} SQLFLOW_TELEMETRY_POLL_SECONDS: "1" diff --git a/render/test/e2e.sh b/render/test/e2e.sh index 6bed718b..c5d710dd 100755 --- a/render/test/e2e.sh +++ b/render/test/e2e.sh @@ -93,7 +93,10 @@ docker compose up -d --wait postgres # Whatever ran before this, the pipelines below start with no claim held. docker compose exec -T postgres psql -U metrics -d metrics -X -Atqc "UPDATE install SET deployed_claimed_at = NULL, first_request_claimed_at = NULL" >/dev/null 2>&1 || true -docker compose up -d collector ingest ingest2 api +# Telemetry is off by default. On here, inline rather than exported, so the +# telemetry section below has events to check and the probes after it start +# with the default. +SQLFLOW_TELEMETRY=on docker compose up -d collector ingest ingest2 api wait_for ingest "$INGEST/events" wait_for ingest2 "$INGEST2/events" wait_for api "$API/healthz" @@ -280,21 +283,27 @@ reset_install() { psqlc 'UPDATE install SET deployed_claimed_at = NULL, deployed run_probe() { # run_probe