Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

feat(server): add SIE_TELEMETRY_ENABLED and announce the 0.13.0 opt-in default (#747)

Krisztian Gajdar09b62a323dd9
diff --git a/README.md b/README.md
index dfe78ef11..3a0a73eb5 100644
--- a/README.md
+++ b/README.md
@@ -248,7 +248,32 @@ helm upgrade --install sie-cluster oci://ghcr.io/superlinked/charts/sie-cluster
See the [deployment guide](https://superlinked.com/docs/deployment/).
-> **Telemetry**: SIE collects anonymous usage data (version, OS, architecture, GPU type) to understand adoption. No IP addresses, hostnames, or request data are collected. Disable with `SIE_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.
+### Telemetry
+
+`sie-server` sends anonymous usage telemetry so the maintainers can see which versions, platforms, and GPUs are in use. It is on by default in releases before 0.13.0. **From 0.13.0 it is off unless `SIE_TELEMETRY_ENABLED=1` is set.** Until then, a server that sends it only because of the default logs a notice at startup.
+
+Each event is a JSON `POST` to `https://telemetry.superlinked.com/api/telemetry` (`SIE_TELEMETRY_URL` overrides the endpoint) with these fields:
+
+| Field | Value |
+| --- | --- |
+| `worker_id` | A random UUID generated on first start and stored in the server data directory (`SIE_DATA_DIR`) |
+| `sent_at` | The send time (UTC) |
+| `event` | `init`, `update`, or `terminate` |
+| `sie_version` | The installed `sie-server` version |
+| `variant` | `SIE_VARIANT`: the image platform and bundle, set by the Helm chart (`null` otherwise) |
+| `os`, `arch` | Operating system and CPU architecture |
+| `gpus` | GPU model names |
+| `deployment_env` | `SIE_DEPLOYMENT_ENV` (default `unknown`) |
+
+The receiver derives country, region, and city from the request's source IP address and does not store the address. No request data, hostnames, or file paths are sent.
+
+`init` is sent at start, the first `update` 45 to 75 minutes later, then one `update` every 55 to 65 minutes, and `terminate` at shutdown.
+
+- Opt in: `SIE_TELEMETRY_ENABLED=1`.
+- Opt out: `SIE_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`, which always win, or `SIE_TELEMETRY_ENABLED=0`.
+- `SIE_TELEMETRY_ENABLED` and `SIE_TELEMETRY_DISABLED` accept `1`, `true`, `yes`, `on` and `0`, `false`, `no`, `off`, in any case. Any other value of either turns telemetry off with a warning.
+
+Every start logs the state and where it came from, for example `telemetry: on (default)` or `telemetry: off (DO_NOT_TRACK)`. The Helm chart's `telemetry.enabled` default also changes to `false` in 0.13.0; see the [chart README](https://github.com/superlinked/sie/blob/main/deploy/helm/sie-cluster/README.md#telemetry). Policy: [superlinked.com/policies/telemetry](https://superlinked.com/policies/telemetry).
---
diff --git a/deploy/helm/sie-cluster/README.md b/deploy/helm/sie-cluster/README.md
index 77b95ac36..3b2eecfd7 100644
--- a/deploy/helm/sie-cluster/README.md
+++ b/deploy/helm/sie-cluster/README.md
@@ -1963,9 +1963,33 @@ docker run -e HF_TOKEN=hf_your_token_here \
## Telemetry
-SIE collects anonymous usage telemetry (version, OS, architecture, GPU type) to help maintainers understand adoption and hardware distribution. Telemetry is on by default and sends a lightweight heartbeat once per hour.
+The `sie-server` worker containers send anonymous usage telemetry so the maintainers can see which versions, platforms, and GPUs are in use. Workers with `engine: candle` send none.
-**No IP addresses, hostnames, cluster names, API keys, or request data are collected.**
+`telemetry.enabled` is `true` by default. **The chart default changes to `false` in 0.13.0**, and so does the `sie-server` default.
+
+| `telemetry.enabled` | Worker environment |
+| --- | --- |
+| `true` (default) | `SIE_TELEMETRY_ENABLED=1` |
+| `false` | `SIE_TELEMETRY_DISABLED=1` |
+
+Because the chart sets the variable explicitly, workers do not log the `sie-server` default-on notice; the install notes print the 0.13.0 change instead. Each worker logs `telemetry: on (SIE_TELEMETRY_ENABLED)` or `telemetry: off (SIE_TELEMETRY_DISABLED)` at startup.
+
+Each event is a JSON `POST` to `https://telemetry.superlinked.com/api/telemetry` (`telemetry.url` overrides it) with these fields:
+
+| Field | Value |
+| --- | --- |
+| `worker_id` | A random UUID generated on the worker's first start and stored in its data directory (`SIE_DATA_DIR`) |
+| `sent_at` | The send time (UTC) |
+| `event` | `init`, `update`, or `terminate` |
+| `sie_version` | The installed `sie-server` version |
+| `variant` | `SIE_VARIANT`: the worker image platform and bundle, for example `cuda12-default` |
+| `os`, `arch` | Operating system and CPU architecture |
+| `gpus` | GPU model names |
+| `deployment_env` | `telemetry.deploymentEnv` (default `production`) |
+
+The receiver derives country, region, and city from the request's source IP address and does not store the address. No request data, hostnames, cluster names, API keys, or file paths are sent.
+
+`init` is sent when a worker starts, the first `update` 45 to 75 minutes later, then one `update` every 55 to 65 minutes, and `terminate` at shutdown. See the [telemetry policy](https://superlinked.com/policies/telemetry).
Disable telemetry:
diff --git a/deploy/helm/sie-cluster/templates/NOTES.txt b/deploy/helm/sie-cluster/templates/NOTES.txt
index f3143bb91..fbeb84230 100644
--- a/deploy/helm/sie-cluster/templates/NOTES.txt
+++ b/deploy/helm/sie-cluster/templates/NOTES.txt
@@ -44,6 +44,12 @@ Grafana password: kubectl get secret -n {{ include "sie-cluster.kubePrometheusSt
{{- if .Values.keda.install }}
KEDA: enabled
{{- end }}
+{{- if and .Values.telemetry .Values.telemetry.enabled }}
+
+Telemetry: the workers send anonymous usage telemetry (telemetry.enabled=true). The chart default
+changes to false in 0.13.0. Set telemetry.enabled=true to keep sending it after that release, or
+telemetry.enabled=false to stop now. What is sent: see the chart README section "Telemetry".
+{{- end }}
{{- if eq (include "sie-cluster.worker.remoteLaneEnabled" .) "true" }}
Remote backends: the remote lane is the only worker that holds upstream credentials.
diff --git a/deploy/helm/sie-cluster/templates/worker-statefulset.yaml b/deploy/helm/sie-cluster/templates/worker-statefulset.yaml
index 31b1cc3f6..81aae3082 100644
--- a/deploy/helm/sie-cluster/templates/worker-statefulset.yaml
+++ b/deploy/helm/sie-cluster/templates/worker-statefulset.yaml
@@ -418,10 +418,15 @@ spec:
value: {{ .nakDelaySec | default 5 | quote }}
{{- end }}
# Telemetry
- {{- if and $root.Values.telemetry (hasKey $root.Values.telemetry "enabled") (not $root.Values.telemetry.enabled) }}
+ {{- if and $root.Values.telemetry (hasKey $root.Values.telemetry "enabled") }}
+ {{- if $root.Values.telemetry.enabled }}
+ - name: SIE_TELEMETRY_ENABLED
+ value: "1"
+ {{- else }}
- name: SIE_TELEMETRY_DISABLED
value: "1"
{{- end }}
+ {{- end }}
{{- if and $root.Values.telemetry $root.Values.telemetry.url }}
- name: SIE_TELEMETRY_URL
value: {{ $root.Values.telemetry.url | quote }}
diff --git a/deploy/helm/sie-cluster/values.yaml b/deploy/helm/sie-cluster/values.yaml
index f10f7afb9..681d62943 100644
--- a/deploy/helm/sie-cluster/values.yaml
+++ b/deploy/helm/sie-cluster/values.yaml
@@ -1547,8 +1547,11 @@ hfToken:
# -- Token value (passed via --set, never baked into values files)
value: ""
-# -- Anonymous usage telemetry. See https://superlinked.com/policies/telemetry
+# -- Anonymous usage telemetry from the workers. See the chart README section
+# "Telemetry" for every field sent, and https://superlinked.com/policies/telemetry
telemetry:
+ # -- true renders SIE_TELEMETRY_ENABLED=1 on the workers; false renders
+ # SIE_TELEMETRY_DISABLED=1. The chart default changes to false in 0.13.0.
enabled: true
# -- Override receiver endpoint (enterprise self-hosted collectors)
url: ""
diff --git a/packages/sie_server/src/sie_server/observability/telemetry.py b/packages/sie_server/src/sie_server/observability/telemetry.py
index 78226c2b4..d771aff52 100644
--- a/packages/sie_server/src/sie_server/observability/telemetry.py
+++ b/packages/sie_server/src/sie_server/observability/telemetry.py
@@ -28,12 +28,49 @@ _UPDATE_MAX_S = 65 * 60 # 65 minutes
_SEND_TIMEOUT_S = 10
_CONSECUTIVE_FAILURE_WARN_THRESHOLD = 3
-
-def _is_telemetry_disabled() -> bool:
- disabled_val = os.environ.get("SIE_TELEMETRY_DISABLED", "").lower()
- if disabled_val in ("1", "true", "yes"):
- return True
- return os.environ.get("DO_NOT_TRACK") == "1"
+_DEFAULT_ENABLED = True
+_TRUE_VALUES = frozenset({"1", "true", "yes", "on"})
+_FALSE_VALUES = frozenset({"0", "false", "no", "off"})
+_DEFAULT_ON_NOTICE = (
+ "Anonymous usage telemetry is on by default. From 0.13.0 it is off unless SIE_TELEMETRY_ENABLED=1. "
+ "Set SIE_TELEMETRY_ENABLED=1 to keep sending it, or SIE_TELEMETRY_DISABLED=1 to stop now. "
+ "What is sent: https://github.com/superlinked/sie#telemetry"
+)
+
+_default_on_notice_shown = False
+
+
+def _warn_unrecognised(name: str) -> None:
+ logger.warning(
+ "%s has a value that is not recognised, so telemetry is off. Use 1, true, yes or on, or 0, false, no or off.",
+ name,
+ )
+
+
+def _resolve_telemetry() -> tuple[bool, str]:
+ disabled = os.environ.get("SIE_TELEMETRY_DISABLED", "").strip().lower()
+ if disabled and disabled not in _FALSE_VALUES:
+ if disabled not in _TRUE_VALUES:
+ _warn_unrecognised("SIE_TELEMETRY_DISABLED")
+ return False, "SIE_TELEMETRY_DISABLED"
+ if os.environ.get("DO_NOT_TRACK", "").strip() == "1":
+ return False, "DO_NOT_TRACK"
+ enabled = os.environ.get("SIE_TELEMETRY_ENABLED", "").strip().lower()
+ if not enabled:
+ return _DEFAULT_ENABLED, "default"
+ if enabled in _TRUE_VALUES:
+ return True, "SIE_TELEMETRY_ENABLED"
+ if enabled not in _FALSE_VALUES:
+ _warn_unrecognised("SIE_TELEMETRY_ENABLED")
+ return False, "SIE_TELEMETRY_ENABLED"
+
+
+def _warn_default_on_once() -> None:
+ global _default_on_notice_shown
+ if _default_on_notice_shown:
+ return
+ _default_on_notice_shown = True
+ logger.warning(_DEFAULT_ON_NOTICE)
def _get_or_create_worker_id(data_dir: str | None = None) -> str:
@@ -156,10 +193,13 @@ async def _telemetry_loop(
@asynccontextmanager
async def telemetry_sender() -> AsyncGenerator[None, None]:
- if _is_telemetry_disabled():
- logger.info("telemetry: disabled via env var")
+ enabled, source = _resolve_telemetry()
+ logger.info("telemetry: %s (%s)", "on" if enabled else "off", source)
+ if not enabled:
yield
return
+ if source == "default":
+ _warn_default_on_once()
url = os.environ.get("SIE_TELEMETRY_URL", _DEFAULT_TELEMETRY_URL)
worker_id = _get_or_create_worker_id()
diff --git a/packages/sie_server/tests/observability/test_telemetry.py b/packages/sie_server/tests/observability/test_telemetry.py
index 635b90017..11ef633d9 100644
--- a/packages/sie_server/tests/observability/test_telemetry.py
+++ b/packages/sie_server/tests/observability/test_telemetry.py
@@ -2,65 +2,124 @@ import asyncio
import logging
import os
import uuid
+from collections.abc import Iterator
+from contextlib import contextmanager
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock, patch
import httpx
import pytest
+from sie_server.observability import telemetry
from sie_server.observability.telemetry import (
_CONSECUTIVE_FAILURE_WARN_THRESHOLD,
+ _DEFAULT_ON_NOTICE,
_FIRST_UPDATE_MAX_S,
_FIRST_UPDATE_MIN_S,
_UPDATE_MAX_S,
_UPDATE_MIN_S,
_build_payload,
_get_or_create_worker_id,
- _is_telemetry_disabled,
_normalize_arch,
+ _resolve_telemetry,
_send_heartbeat,
_telemetry_loop,
telemetry_sender,
)
-class TestIsTelemetryDisabled:
- def test_disabled_when_sie_telemetry_disabled_is_1(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.setenv("SIE_TELEMETRY_DISABLED", "1")
- assert _is_telemetry_disabled() is True
[email protected](autouse=True)
+def _telemetry_env(monkeypatch: pytest.MonkeyPatch) -> None:
+ for name in ("SIE_TELEMETRY_ENABLED", "SIE_TELEMETRY_DISABLED", "DO_NOT_TRACK"):
+ monkeypatch.delenv(name, raising=False)
+ monkeypatch.setattr(telemetry, "_default_on_notice_shown", False)
- def test_disabled_when_sie_telemetry_disabled_is_true(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.setenv("SIE_TELEMETRY_DISABLED", "true")
- assert _is_telemetry_disabled() is True
- def test_disabled_when_sie_telemetry_disabled_is_yes(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.setenv("SIE_TELEMETRY_DISABLED", "yes")
- assert _is_telemetry_disabled() is True
+class TestResolveTelemetry:
+ def test_unset_uses_the_release_default(self) -> None:
+ assert _resolve_telemetry() == (True, "default")
- def test_disabled_when_sie_telemetry_disabled_is_true_case_insensitive(
- self, monkeypatch: pytest.MonkeyPatch
- ) -> None:
- monkeypatch.setenv("SIE_TELEMETRY_DISABLED", "TRUE")
- assert _is_telemetry_disabled() is True
+ @pytest.mark.parametrize("value", ["", " "])
+ def test_empty_uses_the_release_default(self, monkeypatch: pytest.MonkeyPatch, value: str) -> None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", value)
+ assert _resolve_telemetry() == (True, "default")
- def test_disabled_when_do_not_track_is_1(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.delenv("SIE_TELEMETRY_DISABLED", raising=False)
- monkeypatch.setenv("DO_NOT_TRACK", "1")
- assert _is_telemetry_disabled() is True
+ @pytest.mark.parametrize("value", ["1", "true", "yes", "on", "TRUE", " Yes ", "On"])
+ def test_enabled_values_turn_it_on(self, monkeypatch: pytest.MonkeyPatch, value: str) -> None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", value)
+ assert _resolve_telemetry() == (True, "SIE_TELEMETRY_ENABLED")
- def test_not_disabled_when_do_not_track_is_0(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.delenv("SIE_TELEMETRY_DISABLED", raising=False)
- monkeypatch.setenv("DO_NOT_TRACK", "0")
- assert _is_telemetry_disabled() is False
-
- def test_not_disabled_when_no_env_vars(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.delenv("SIE_TELEMETRY_DISABLED", raising=False)
- monkeypatch.delenv("DO_NOT_TRACK", raising=False)
- assert _is_telemetry_disabled() is False
+ @pytest.mark.parametrize("value", ["0", "false", "no", "off", "FALSE", " Off "])
+ def test_disabled_values_turn_it_off(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, value: str
+ ) -> None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", value)
+ with caplog.at_level(logging.WARNING, logger="sie_server.observability.telemetry"):
+ assert _resolve_telemetry() == (False, "SIE_TELEMETRY_ENABLED")
+ assert caplog.records == []
+
+ @pytest.mark.parametrize("value", ["enable", "maybe", "s3cr3t-value"])
+ def test_unrecognised_value_turns_it_off_with_one_warning(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, value: str
+ ) -> None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", value)
+ with caplog.at_level(logging.WARNING, logger="sie_server.observability.telemetry"):
+ assert _resolve_telemetry() == (False, "SIE_TELEMETRY_ENABLED")
+ (record,) = caplog.records
+ assert record.levelno == logging.WARNING
+ assert "SIE_TELEMETRY_ENABLED has a value that is not recognised" in record.getMessage()
+ assert value not in record.getMessage()
+
+ @pytest.mark.parametrize("value", ["disable", "maybe", "s3cr3t-value"])
+ @pytest.mark.parametrize("enabled", [None, "1"])
+ def test_unrecognised_opt_out_value_turns_it_off_with_one_warning(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, value: str, enabled: str | None
+ ) -> None:
+ monkeypatch.setenv("SIE_TELEMETRY_DISABLED", value)
+ if enabled is not None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", enabled)
+ with caplog.at_level(logging.WARNING, logger="sie_server.observability.telemetry"):
+ assert _resolve_telemetry() == (False, "SIE_TELEMETRY_DISABLED")
+ (record,) = caplog.records
+ assert record.levelno == logging.WARNING
+ assert "SIE_TELEMETRY_DISABLED has a value that is not recognised" in record.getMessage()
+ assert value not in record.getMessage()
+
+ @pytest.mark.parametrize("value", ["1", "true", "yes", "on", "TRUE", " yes ", "On"])
+ @pytest.mark.parametrize("enabled", [None, "1", "on"])
+ def test_sie_telemetry_disabled_wins(
+ self, monkeypatch: pytest.MonkeyPatch, value: str, enabled: str | None
+ ) -> None:
+ monkeypatch.setenv("SIE_TELEMETRY_DISABLED", value)
+ monkeypatch.setenv("DO_NOT_TRACK", "1")
+ if enabled is not None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", enabled)
+ assert _resolve_telemetry() == (False, "SIE_TELEMETRY_DISABLED")
- def test_both_vars_set(self, monkeypatch: pytest.MonkeyPatch) -> None:
- monkeypatch.setenv("SIE_TELEMETRY_DISABLED", "1")
+ @pytest.mark.parametrize("enabled", [None, "1", "on"])
+ def test_do_not_track_wins(self, monkeypatch: pytest.MonkeyPatch, enabled: str | None) -> None:
monkeypatch.setenv("DO_NOT_TRACK", "1")
- assert _is_telemetry_disabled() is True
+ if enabled is not None:
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", enabled)
+ assert _resolve_telemetry() == (False, "DO_NOT_TRACK")
+
+ @pytest.mark.parametrize(
+ ("name", "value"),
+ [
+ ("SIE_TELEMETRY_DISABLED", "0"),
+ ("SIE_TELEMETRY_DISABLED", "false"),
+ ("SIE_TELEMETRY_DISABLED", "no"),
+ ("SIE_TELEMETRY_DISABLED", " Off "),
+ ("SIE_TELEMETRY_DISABLED", " "),
+ ("DO_NOT_TRACK", "0"),
+ ],
+ )
+ def test_opt_out_variables_set_to_false_do_not_opt_out(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, name: str, value: str
+ ) -> None:
+ monkeypatch.setenv(name, value)
+ with caplog.at_level(logging.WARNING, logger="sie_server.observability.telemetry"):
+ assert _resolve_telemetry() == (True, "default")
+ assert caplog.records == []
class TestGetOrCreateWorkerId:
@@ -278,16 +337,78 @@ class TestJitterRanges:
assert _UPDATE_MAX_S == 65 * 60
+@contextmanager
+def _receiver() -> Iterator[MagicMock]:
+ with (
+ patch("sie_server.observability.telemetry.httpx.AsyncClient") as mock_client_cls,
+ patch("sie_server.observability.telemetry.get_gpu_metrics", return_value=[]),
+ ):
+ mock_client = AsyncMock()
+ mock_client.post = AsyncMock(return_value=MagicMock(is_success=True))
+ mock_client.aclose = AsyncMock()
+ mock_client_cls.return_value = mock_client
+ yield mock_client_cls
+
+
+def _telemetry_messages(caplog: pytest.LogCaptureFixture, level: int) -> list[str]:
+ return [
+ r.getMessage() for r in caplog.records if r.name == "sie_server.observability.telemetry" and r.levelno == level
+ ]
+
+
class TestTelemetrySender:
@pytest.mark.asyncio
- async def test_disabled_via_env_yields_immediately(
- self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
+ @pytest.mark.parametrize(
+ ("name", "value", "source"),
+ [
+ ("SIE_TELEMETRY_DISABLED", "1", "SIE_TELEMETRY_DISABLED"),
+ ("SIE_TELEMETRY_DISABLED", "maybe", "SIE_TELEMETRY_DISABLED"),
+ ("DO_NOT_TRACK", "1", "DO_NOT_TRACK"),
+ ("SIE_TELEMETRY_ENABLED", "0", "SIE_TELEMETRY_ENABLED"),
+ ("SIE_TELEMETRY_ENABLED", "maybe", "SIE_TELEMETRY_ENABLED"),
+ ],
+ )
+ async def test_off_states_its_source_and_sends_nothing(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, name: str, value: str, source: str
) -> None:
- monkeypatch.setenv("SIE_TELEMETRY_DISABLED", "1")
- with caplog.at_level(logging.INFO, logger="sie_server.observability.telemetry"):
+ monkeypatch.setenv(name, value)
+ with _receiver() as mock_client_cls, caplog.at_level(logging.INFO):
async with telemetry_sender():
pass
- assert any("disabled via env var" in r.message for r in caplog.records)
+ assert _telemetry_messages(caplog, logging.INFO) == [f"telemetry: off ({source})"]
+ assert _DEFAULT_ON_NOTICE not in _telemetry_messages(caplog, logging.WARNING)
+ mock_client_cls.assert_not_called()
+
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize("value", ["1", "true", "yes", "on"])
+ async def test_explicit_opt_in_states_its_source_without_the_notice(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, tmp_path: Path, value: str
+ ) -> None:
+ monkeypatch.setenv("SIE_DATA_DIR", str(tmp_path))
+ monkeypatch.setenv("SIE_TELEMETRY_ENABLED", value)
+ with _receiver() as mock_client_cls, caplog.at_level(logging.INFO):
+ async with telemetry_sender():
+ pass
+ assert _telemetry_messages(caplog, logging.INFO) == ["telemetry: on (SIE_TELEMETRY_ENABLED)"]
+ assert _telemetry_messages(caplog, logging.WARNING) == []
+ mock_client_cls.assert_called_once()
+
+ @pytest.mark.asyncio
+ async def test_default_on_states_its_source_every_start_and_warns_once(
+ self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, tmp_path: Path
+ ) -> None:
+ monkeypatch.setenv("SIE_DATA_DIR", str(tmp_path))
+ with _receiver(), caplog.at_level(logging.INFO):
+ for _ in range(2):
+ async with telemetry_sender():
+ pass
+ assert _telemetry_messages(caplog, logging.INFO) == ["telemetry: on (default)"] * 2
+ assert _telemetry_messages(caplog, logging.WARNING) == [_DEFAULT_ON_NOTICE]
+
+ def test_default_on_notice_names_the_flip_release_and_both_variables(self) -> None:
+ assert "From 0.13.0 it is off unless SIE_TELEMETRY_ENABLED=1." in _DEFAULT_ON_NOTICE
+ assert "SIE_TELEMETRY_DISABLED=1 to stop now" in _DEFAULT_ON_NOTICE
+ assert "https://github.com/superlinked/sie#telemetry" in _DEFAULT_ON_NOTICE
@pytest.mark.asyncio
async def test_lifecycle_init_terminate(self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
diff --git a/tools/ci/tests/test_helm_render.py b/tools/ci/tests/test_helm_render.py
index 8a22ce73b..44daaee28 100644
--- a/tools/ci/tests/test_helm_render.py
+++ b/tools/ci/tests/test_helm_render.py
@@ -581,6 +581,26 @@ def test_non_production_config_service_may_opt_out_of_the_token(tmp_path: Path,
assert env_entries(docs, "SIE_CONFIG_SERVICE_TOKEN") == dict.fromkeys(CONFIG_CONSUMERS, "")
+ ("telemetry", "expected"),
+ [
+ ({}, {"SIE_TELEMETRY_ENABLED": "1"}),
+ ({"enabled": True}, {"SIE_TELEMETRY_ENABLED": "1"}),
+ ({"enabled": False}, {"SIE_TELEMETRY_DISABLED": "1"}),
+ ({"enabled": None}, {}),
+ ],
+)
+def test_worker_telemetry_setting_is_explicit(tmp_path: Path, telemetry: dict, expected: dict[str, str]) -> None:
+ (statefulset,) = worker_statefulsets(tmp_path, {**L4_POOL, "telemetry": telemetry})
+ (worker,) = [c for c in statefulset["spec"]["template"]["spec"]["containers"] if c["name"] == "worker"]
+ rendered = {
+ env["name"]: env["value"]
+ for env in worker["env"]
+ if env["name"] in {"SIE_TELEMETRY_ENABLED", "SIE_TELEMETRY_DISABLED"}
+ }
+ assert rendered == expected
+
+
@pytest.mark.parametrize("setting", ["admin", "read"])
@pytest.mark.parametrize(
("token", "error"),