Unified telemetry and error tracking for OpenAdapt packages
Project description
openadapt-telemetry
Unified telemetry and error tracking for OpenAdapt packages.
Features
- Unified Error Tracking: Consistent error reporting across all OpenAdapt packages
- Usage Counters (PostHog): Lightweight product usage events for adoption metrics
- Privacy-First Design: Automatic PII scrubbing and path sanitization
- Configurable Opt-Out: Respects
DO_NOT_TRACKand custom environment variables - Internal Usage Tagging: Explicit flags + CI detection with optional git heuristic
- GlitchTip/Sentry Compatible: Uses the Sentry SDK for maximum compatibility
Installation
pip install openadapt-telemetry
Or with development dependencies:
pip install openadapt-telemetry[dev]
Quick Start
Initialize Telemetry
from openadapt_telemetry import get_telemetry
# Initialize once at package startup
get_telemetry().initialize(
dsn="https://xxx@app.glitchtip.com/XXXX",
package_name="openadapt-mypackage",
package_version="0.1.0",
)
Capture Exceptions
from openadapt_telemetry import get_telemetry
try:
risky_operation()
except Exception as e:
get_telemetry().capture_exception(e)
raise
Capture Usage Events (PostHog)
from openadapt_telemetry import capture_usage_event
capture_usage_event(
"agent_run",
properties={"entrypoint": "oa evals run", "mode": "live"},
package_name="openadapt-evals",
)
Using Decorators
from openadapt_telemetry import track_errors, track_performance, track_feature
@track_errors()
def process_data(data):
"""Exceptions are automatically captured."""
return transform(data)
@track_performance("indexing.build_faiss")
def build_index(vectors):
"""Execution time is automatically tracked."""
return create_index(vectors)
@track_feature("retrieval.add_demo")
def add_demo(demo_id, task):
"""Feature usage is tracked for analytics."""
save_demo(demo_id, task)
Span Context Manager
from openadapt_telemetry import TelemetrySpan
with TelemetrySpan("indexing", "build_faiss_index") as span:
span.set_tag("num_vectors", 1000)
# ... indexing operations ...
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
DO_NOT_TRACK |
- | Universal opt-out (1 = disabled) |
OPENADAPT_TELEMETRY_ENABLED |
true |
Enable/disable telemetry |
OPENADAPT_INTERNAL |
false |
Tag as internal usage |
OPENADAPT_DEV |
false |
Development mode |
OPENADAPT_INTERNAL_FROM_GIT |
false |
Optional: tag as internal when running from a git checkout |
OPENADAPT_TELEMETRY_DSN |
- | GlitchTip/Sentry DSN |
OPENADAPT_POSTHOG_PROJECT_API_KEY |
embedded default | PostHog ingestion project token (phc_...) |
OPENADAPT_POSTHOG_HOST |
https://us.i.posthog.com |
PostHog ingestion host |
OPENADAPT_TELEMETRY_DISTINCT_ID |
generated UUID | Stable anonymous identifier override |
OPENADAPT_TELEMETRY_TIMEOUT_SECONDS |
1.0 |
PostHog network timeout |
OPENADAPT_TELEMETRY_IN_CI |
false |
Enable usage events in CI pipelines |
OPENADAPT_TELEMETRY_ENVIRONMENT |
production |
Environment name |
OPENADAPT_TELEMETRY_SAMPLE_RATE |
1.0 |
Error sampling rate (0.0-1.0) |
OPENADAPT_TELEMETRY_TRACES_SAMPLE_RATE |
0.01 |
Performance sampling rate |
OPENADAPT_TELEMETRY_ANON_SALT |
generated | Optional anonymization salt override (advanced use only) |
Configuration File
Create ~/.config/openadapt/telemetry.json:
{
"enabled": true,
"internal": false,
"dsn": "https://xxx@app.glitchtip.com/XXXX",
"environment": "production",
"sample_rate": 1.0,
"traces_sample_rate": 0.01
}
Priority Order
- Environment variables (highest priority)
- Configuration file
- Package defaults (lowest priority)
Opt-Out
To disable telemetry, set either:
# Universal standard
export DO_NOT_TRACK=1
# Or package-specific
export OPENADAPT_TELEMETRY_ENABLED=false
Privacy
What We Collect
| Category | Data | Purpose |
|---|---|---|
| Errors | Exception type, stack trace | Bug fixing |
| Performance | Function timing | Optimization |
| Feature Usage | Feature names, counts | Prioritization |
| Environment | OS, Python version | Compatibility |
What We Never Collect
- Screenshots or images
- Text content or file contents
- Personal information (names, emails, IPs)
- API keys or passwords
- Full file paths with usernames
Automatic Scrubbing
- File paths have usernames replaced with
<user> - Sensitive fields (password, token, api_key, etc.) are redacted
- Email addresses and phone numbers are scrubbed from messages
- Top-level event messages/logentry strings are scrubbed
- Tag keys are validated, sensitive/invalid keys are dropped, and values are scrubbed before upload
- User IDs are HMAC-anonymized before upload (
anon:v2:<hash>) send_default_piiis enforced tofalseby the client
Internal Usage Tagging
Internal/developer usage is automatically detected via:
OPENADAPT_INTERNAL=trueenvironment variableOPENADAPT_DEV=trueenvironment variable- CI environment detected (GitHub Actions, GitLab CI, etc.)
- Optional git repository heuristic when
OPENADAPT_INTERNAL_FROM_GIT=true
Filter in GlitchTip:
tag:internal IS false # External users only
tag:internal IS true # Internal users only
Development
# Clone and install
git clone https://github.com/OpenAdaptAI/openadapt-telemetry
cd openadapt-telemetry
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=openadapt_telemetry
License
MIT License - see LICENSE for details.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openadapt_telemetry-0.3.0.tar.gz.
File metadata
- Download URL: openadapt_telemetry-0.3.0.tar.gz
- Upload date:
- Size: 32.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1634d5656d285b13a3117513f667677f231cf85b69f8acd1d6c1a22ce498ba98
|
|
| MD5 |
6aaec253f6bb012eb6b39c9e756b78b1
|
|
| BLAKE2b-256 |
16e8f222df262d305c9cc8bb1fe28472d3b4c3d80fd46dded9f11a393af212a9
|
Provenance
The following attestation bundles were made for openadapt_telemetry-0.3.0.tar.gz:
Publisher:
release.yml on OpenAdaptAI/openadapt-telemetry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openadapt_telemetry-0.3.0.tar.gz -
Subject digest:
1634d5656d285b13a3117513f667677f231cf85b69f8acd1d6c1a22ce498ba98 - Sigstore transparency entry: 1194055461
- Sigstore integration time:
-
Permalink:
OpenAdaptAI/openadapt-telemetry@a4ffd34265d78edbf29effb051dbdf1537c23b15 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/OpenAdaptAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a4ffd34265d78edbf29effb051dbdf1537c23b15 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openadapt_telemetry-0.3.0-py3-none-any.whl.
File metadata
- Download URL: openadapt_telemetry-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f249a54ddad71d39205606220b9cb3f0d5203c344ab92d02968635ccf8460888
|
|
| MD5 |
318d60ca387f6f18984a73336060d7bf
|
|
| BLAKE2b-256 |
c6858185bc7c71fcca5f3a65910c3d983cd16f03ea08dbd4a36af8125c4179d4
|
Provenance
The following attestation bundles were made for openadapt_telemetry-0.3.0-py3-none-any.whl:
Publisher:
release.yml on OpenAdaptAI/openadapt-telemetry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openadapt_telemetry-0.3.0-py3-none-any.whl -
Subject digest:
f249a54ddad71d39205606220b9cb3f0d5203c344ab92d02968635ccf8460888 - Sigstore transparency entry: 1194055596
- Sigstore integration time:
-
Permalink:
OpenAdaptAI/openadapt-telemetry@a4ffd34265d78edbf29effb051dbdf1537c23b15 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/OpenAdaptAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a4ffd34265d78edbf29effb051dbdf1537c23b15 -
Trigger Event:
push
-
Statement type: