sdk-telemetry: opt-in atlas_sdk_events_total emission (off by default)#90
Closed
mmercuri wants to merge 1 commit into
Closed
sdk-telemetry: opt-in atlas_sdk_events_total emission (off by default)#90mmercuri wants to merge 1 commit into
mmercuri wants to merge 1 commit into
Conversation
…otal
Adds a small client-side telemetry module that mirrors the
`atlas_sdk_events_total{surface, event}` counter exported by atlas-app
on the metrics-analytics-dashboard branch. Off by default; flip
LAYERLENS_TELEMETRY=on to opt in. Allowlists attribute keys so PII can
never leak; failure-isolated so telemetry can never break customer apps.
Wires `init` event into Stratix.__init__ and `cmd_run` event into the
CLI root command. 16 unit tests pass under PYTHONPATH=src pytest.
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.
Summary
Adds a small client-side telemetry module (
layerlens._telemetry) that mirrors theatlas_sdk_events_total{surface, event}andatlas_sdk_request_duration_secondsshapes the atlas-app server side declares (see the metrics-analytics-dashboard PR stack onLayerLens/atlas-app, starting at #1752).Contract: off by default. Customer opts in via
LAYERLENS_TELEMETRY=on.Key properties
LAYERLENS_TELEMETRYunset → zero-overhead no-op. OpenTelemetry SDK is not even imported until telemetry is enabled (lazy import in_try_init).command,resource,outcome,status_codeare forwarded on top of the requiredsurface+eventkeys. Anything else a caller might accidentally pass is dropped.atexit.register(shutdown)so the last batch flushes cleanly even on short-lived commands.What's wired
Stratix(...).__init__→ emitsatlas_sdk_events_total{surface=sdk_python, event=init}once per client construction.atlas_sdk_events_total{surface=cli, event=cmd_run}once per CLI invocation.Verification
pytest tests/test_telemetry.pyCross-repo coupling
The server side of this counter lands in
LayerLens/atlas-appPR #1752 (atlas_sdk_events_totalinapps/shared/observability/metrics.go). Labels match exactly:surface+event. Suggested merge order: atlas-app #1752 first, then this. If this merges first, opted-in customers emit to a metric that doesn't have a scrape target yet — harmless (OTLP exporter silently drops under network-unreachable) but wasteful.Docs
docs/telemetry.md(82 lines) — explains what's collected, how to disable, why none of it is PII.Test plan
LAYERLENS_TELEMETRY=on python -c "from layerlens import Stratix; Stratix(api_key='test')"→ confirm 1 counter emit to the configured OTLP endpoint (or silent drop if endpoint unreachable — that's the contract)LAYERLENS_TELEMETRY=off python -c "import layerlens; print('ok')"does not importopentelemetry(covered bytest_event_with_telemetry_off_doesnt_import_otel)