Privacy-first usage analytics for Rust open source projects - understand how your CLI tools and libraries are used in the wild
telemetry-kit helps open source maintainers understand how their tools are used in the wild. Add privacy-first telemetry in 3 lines of code. Self-host or use our managed service. Perfect for CLI tools, libraries, and Rust applications.
π Currently Working (v0.2.0-alpha.1)
The following features are fully implemented and tested:
- β Interactive Consent Prompts: First-run consent dialogs for privacy compliance (NEW!)
- β Smart Instrumentation Recommendations: AI-powered code analysis suggesting where to add telemetry (NEW!)
- β Auto-Sync Background Task: Automatic event synchronization in the background
- β SQLite β Service Sync Protocol: Offline-first event buffering with HMAC-SHA256 authentication
- β
Privacy-First User IDs: Anonymous client identifiers with
client_prefix (SHA-256 hashed machine IDs) - β Event Tracking: Command and feature event builders with fluent API
- β Ingestion Server: Production-ready Rust server with PostgreSQL + Redis
- β Rate Limiting: Token-based rate limits (Free/Pro/Business/Enterprise tiers)
- β Replay Protection: Nonce-based duplicate request detection
- β Batch Ingestion: 1-1000 events per request with partial success handling
- β Docker Deployment: Complete docker-compose stack for local development
Quick Start with Working Features
# 1. Start the server
# 2. Run the end-to-end test
See DEPLOYMENT_GUIDE.md for complete setup instructions.
Auto-Sync Background Task (NEW! π)
Events are now automatically synced in the background - no manual .sync() calls required!
use *;
async
Features:
- Background tokio task syncs events at configurable intervals
- Graceful shutdown with optional final sync
- Respects DO_NOT_TRACK environment variable
- Exponential backoff on sync failures
- Thread-safe implementation
See examples/auto_sync.rs for a complete example.
CLI Tool (NEW! π)
Manage telemetry configuration and operations from the command line.
# Install CLI
# Create a new project with telemetry pre-configured
# Analyze code for instrumentation opportunities (NEW!)
# Interactive setup (for existing projects)
# View statistics
# Test sync credentials
# Validate configuration
# Clean local events
Available Commands:
new- Create new projects with telemetry pre-configuredanalyze- Get smart recommendations on where to add instrumentation (NEW!)init- Interactive project setup with credential configurationtest- Validate sync credentialsstats- View event statistics (total, synced, unsynced)sync- Manually trigger synchronizationvalidate- Validate configurationclean- Clear local event database
See CLI.md for complete CLI documentation.
π― The Problem
As an open source maintainer, you want to understand:
- Which features are actually used vs ignored
- Where users encounter errors or confusion
- How your CLI tool performs in real-world environments
- Whether your library is used correctly
But current telemetry solutions are:
- Too complex: Setting up OpenTelemetry requires understanding multiple crates and writing verbose boilerplate
- Not opinionated: You don't know what to track or where to add instrumentation
- Privacy-blind: Easy to accidentally log PII, risking your users' trust
- CLI-unfriendly: Most tools designed for long-running services, not CLI applications
- Hard to self-host: Commercial solutions or complex infrastructure required
- Trust issues: Users disable telemetry because they don't trust what's collected
β¨ The Solution
use *;
// π That's it!
async
What you get as an OSS maintainer:
- β 3 lines instead of 50+: Sensible defaults, zero boilerplate
- π― Smart instrumentation: Auto-detect CLI commands, errors, and performance bottlenecks
- π Privacy-first: Built-in anonymization, GDPR-compliant, earns user trust
- π CLI-optimized: Works with short-lived processes, offline-capable
- π¦ Self-hostable: Simple Docker-based collection server included
- π€ AI-suggested: Get recommendations on what to instrument
- π GitHub Badges: Show usage metrics in your README
- π₯ Public Dashboards: Share anonymous analytics with your community
π Key Features
For Open Source Maintainers
Understand Your Users Without Compromising Their Privacy:
// Add to your CLI tool or library
let telemetry = builder
.service_name?
.service_version
.prompt_for_consent? // Ask users first
.build?;
// Track what matters
telemetry.track_command.await?;
What You Can Learn:
- π Feature Usage: Which commands/features are popular vs unused
- β οΈ Error Patterns: Where users struggle or encounter bugs
- β‘ Performance: Real-world execution times and bottlenecks
- π Platform Distribution: OS/architecture breakdown
- π Adoption Trends: New vs returning users, version migration
Build Trust With Your Community:
- π Transparent: Users see exactly what you collect
- π Respectful: DO_NOT_TRACK honored automatically
- β Consent-First: Optional interactive prompts
- π Open Source: Inspect the code, self-host if preferred
- π― Anonymous: No PII, just anonymous usage patterns
Showcase Your Impact:
- π Add usage badges to your README:
- π Share public dashboards with your community
- π Show growth and adoption metrics to sponsors
Zero-Config Telemetry
// Literally one line
init.auto_configure?;
Privacy Controls
init
.anonymous // Anonymous user IDs
.sanitize_emails // Hash email addresses
.exclude_env_vars // Don't capture environment
.gdpr_compliant // Full GDPR compliance
.consent_prompt // Ask user on first run
.init;
Smart Instrumentation (NEW! π)
Enable automatic function instrumentation with the macros feature:
use *;
// Auto-track duration
async
Features:
- Automatic execution timing for all instrumented functions
- Works with async and sync functions
- Supports functions with or without Result return types
- Zero-overhead when macros feature is disabled
- Compile-time code generation
Enable with:
[]
= { = "0.2", = ["macros"] }
See examples/instrument_macro.rs for a complete example.
Note: Currently the macro measures timing but doesn't send telemetry yet. Full telemetry integration coming soon!
CLI-Specific Features
use *;
// Automatically tracks:
// - Which commands are used
// - Command duration
// - Success/failure rates
// - Anonymous usage patterns
πΊοΈ Roadmap
Phase 1: Foundation (v0.1.0) - Q1 2025
- Core telemetry abstraction over OpenTelemetry
- Privacy-first defaults (anonymization, sanitization)
- Basic instrumentation macros
- Simple OTLP export
- Documentation and examples
Phase 2: Developer Experience (v0.2.0) - Q2 2025
- CLI scaffolding tool (
telemetry-kit init) - Auto-detection of instrumentation points
- Smart suggestions (analyze code, suggest where to add tracking)
- Pre-built configuration templates
- VS Code extension for inline suggestions
Phase 3: CLI Optimization (v0.3.0) - Q2 2025
- Short-lived process handling
- Offline caching with automatic sync
- User consent flow (first-run prompts)
- Minimal overhead (<1ms impact)
- Graceful degradation when server unavailable
Phase 4: Self-Hosting (v0.4.0) - Q3 2025
- Simple collection server (Docker one-liner)
- Built-in dashboard for basic analytics
- SQLite/PostgreSQL storage backends
- REST API for custom integrations
- Pre-built dashboards for common patterns
Phase 5: Advanced Features (v0.5.0+) - Q4 2025
- AI-powered insights (usage patterns, anomaly detection)
- Anonymous user cohorts
- A/B testing support
- Feature flag integration
- Custom metric definitions
- Multi-project dashboards
π Comparison with Existing Solutions
| Feature | telemetry-kit | OpenTelemetry | tracing | sentry-rust |
|---|---|---|---|---|
| Setup Complexity | β Low (3 lines) | β οΈ High (50+ lines) | β οΈ Medium | β Low |
| Privacy Built-in | β Yes | β No | β No | β οΈ Partial |
| CLI Optimized | β Yes | β No | β No | β οΈ Partial |
| Auto-instrumentation | β Yes | β No | β No | β οΈ Errors only |
| Self-hostable | β Included | β οΈ Complex | N/A | β Commercial |
| Smart Suggestions | β Yes | β No | β No | β No |
| Offline Support | β Yes | β No | N/A | β οΈ Limited |
| GDPR Compliant | β Built-in | β οΈ Manual | β οΈ Manual | β οΈ Manual |
π Quick Start
Installation
[]
= "0.0.1"
Basic Usage
use *;
async
async
CLI Application
use Parser;
use *;
// Auto-track all commands!
async
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Your Application β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Macros β β Middleware β β Manual β β
β β #[instrument]β β Tracking β β Tracking β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ β
β ββββββββββββββββββββ΄βββββββββββββββββββ β
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β
ββββββββββββΌβββββββββββ
β telemetry-kit Core β
β β
β β’ Privacy filters β
β β’ Anonymization β
β β’ Batching β
β β’ Sampling β
ββββββββββββ¬βββββββββββ
β
βββββββββββββββββββββββΌββββββββββββββββββββββ
β β β
βββββββββΌβββββββββ βββββββββββΌβββββββββ ββββββββββΌβββββββββ
β OpenTelemetry β β Simple Server β β Custom β
β (OTLP) β β (Self-hosted) β β Backends β
ββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
π Privacy & Compliance
telemetry-kit is privacy-first by design:
- Anonymous by default: No PII collected unless explicitly enabled
- User consent: Built-in consent flow for CLI applications
- Data sanitization: Automatic scrubbing of sensitive data
- GDPR compliant: Right to erasure, data portability, consent management
- Transparent: Users can see exactly what data is collected
- Opt-out friendly: Easy to disable, respects DO_NOT_TRACK
Privacy Features
Interactive Consent Prompts (NEW!):
use *;
async
Privacy Configuration:
use *;
use PrivacyConfig;
// Strict privacy mode (GDPR-compliant)
let telemetry = builder
.service_name?
.strict_privacy // Requires consent, sanitizes data, 30-day retention
.build?;
// Or configure individually
let telemetry = builder
.service_name?
.consent_required
.sanitize_paths
.sanitize_emails
.data_retention // Days
.build?;
Manage Consent via CLI:
See examples/interactive_consent.rs and examples/privacy.rs for complete examples.
π€ Contributing
We welcome contributions! This is a new project and we're building it in the open.
How to Contribute
- Check out our Roadmap for planned features
- Look at GitHub Issues for tasks
- Read CONTRIBUTING.md for guidelines
- Join discussions in GitHub Discussions
Areas We Need Help
- π¨ Design: API design, ergonomics, developer experience
- π Documentation: Examples, tutorials, guides
- π§ Implementation: Core features, integrations, tools
- π§ͺ Testing: Unit tests, integration tests, real-world usage
- π Community: Blog posts, talks, spreading the word
π Documentation
User Documentation
- Quick Start Guide (coming soon)
- API Reference
- Privacy Guide (coming soon)
- CLI Best Practices (coming soon)
- Self-Hosting Guide (coming soon)
Project Documentation
- Roadmap - Feature roadmap and release plan
- Security Policy - Vulnerability disclosure and security practices
- SLSA Compliance - Supply chain security documentation
- Contributing Guide - How to contribute to the project
- Project Docs - Internal development documentation
π‘ Inspiration
This project is inspired by:
- The simplicity of sentry-rust
- The power of OpenTelemetry
- The ergonomics of tracing
- The privacy-focus of Plausible Analytics
- The developer experience of Next.js Analytics
π License
This project is dual-licensed under your choice of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
You may choose either license at your option.
Why Dual License?
We follow the Rust community standard of dual licensing to give you flexibility:
- Choose MIT if you prefer simplicity and maximum compatibility (including GPL2)
- Choose Apache 2.0 if you want explicit patent protection and contributor agreements
Both licenses are permissive and allow commercial use, modification, distribution, and private use.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
π Acknowledgments
Built with β€οΈ by Ibrahim Cesar and contributors.
Special thanks to:
- The OpenTelemetry project
- The Rust tracing ecosystem
- Everyone who provided feedback and ideas
GNU Terry Pratchett
This project includes the X-Clacks-Overhead: GNU Terry Pratchett header in all HTTP requests to keep the memory of Sir Terry Pratchett alive in the overhead of the internet. Learn more at gnuterrypratchett.com.
"A man is not dead while his name is still spoken." - Going Postal, Terry Pratchett
Status: π§ Early Development - API is unstable and will change
Current Version: 0.0.1 - Placeholder release for crate reservation
First Usable Release: v0.1.0 (Target: Q1 2025)
β Star us on GitHub | π Read the Docs | π¬ Discussions