EcoTrace: High-precision carbon tracking engine for production Python. Function-level CPU/GPU emission measurement with 50ms continuous sampling, Boavizta TDP database, and audit-ready PDF reporting.
Project description
EcoTrace
High-Precision Energy and Emissions Instrumentation
v1.4.0 — Feature Release. Pausable tracking API, WebhookExporter, side-by-side CLI diff comparison, filtered CSV exporting, and log maintenance commands — all with zero new mandatory dependencies.
EcoTrace is a lightweight library for granular carbon footprint measurement of Python applications. No configuration files, no background services—just real-time hardware-level transparency.
Real-time monitoring | 50+ Global Zones | AI-powered insights | Zero-configuration
[!TIP] VS Code Extension: Monitor application carbon footprint in real-time during development. Download here.
Function-level carbon measurement with real-time monitoring
Core Features in v1.4.0
Feature Release. v1.4.0 adds pausable tracking, side-by-side run comparisons, webhook integrations, filtered CSV exporting, and log rotation capabilities.
- Pausing API — Temporarily disable carbon tracking using
EcoTrace.pause()andEcoTrace.resume()to exclude setup and teardown overhead. - Run Comparisons (
ecotrace diff) — Perform side-by-side carbon and execution duration comparisons between two specific runs. - Webhook Integration (
WebhookExporter) — Stream carbon emissions data to Slack, Teams, Discord, or a custom API in real-time. - Filtered CSV Exporting — Export filtered subsets of measurement logs with
--csvformat and--run/--funcfilters. - Log Maintenance Commands — Rotate and trim logs via
ecotrace clean, and permanently delete logs usingecotrace reset. - Multi-Run History — Every session gets a unique
RunID. Useecotrace historyto compare runs andecotrace trendsfor an ASCII carbon trend chart. get_summary()API — Programmatic access to all session metrics as a typed dict. Ideal for notebooks, dashboards, and CI assertions.
Quick Install
pip install ecotrace
Optional extras:
pip install ecotrace[gpu] # NVIDIA GPU support
pip install ecotrace[ai] # Gemini AI insights
pip install ecotrace[all] # Everything
Quick Start
Option 1: Zero-Code Profiling (CLI)
Measure any script without changing a single line of code:
ecotrace run my_script.py
Option 2: Programmatic Tracking (Library)
Decorate functions for granular instrumentation:
from ecotrace import EcoTrace
eco = EcoTrace(region_code="US")
@eco.track
def my_function():
# Your heavy processing here
pass
my_function()
# Export audit-ready reports or check cumulative totals
eco.generate_pdf_report("carbon_audit.pdf")
print(f"Total Carbon Emitted: {eco.total_carbon} gCO2")
Option 3: Carbon Budget Mode
Set a limit and let EcoTrace enforce it:
eco = EcoTrace(
region_code="TR",
carbon_limit=5.0, # 5 gCO2 budget
on_budget_exceeded=lambda t, l: print(f"Budget exceeded: {t:.4f}/{l:.4f} gCO2")
)
@eco.track
def training_pipeline():
...
training_pipeline()
print(f"Remaining budget: {eco.remaining_budget} gCO2")
Expected Output
When initialized, EcoTrace performs automated hardware detection:
[EcoTrace] INFO: [INFO] EcoTrace instrumentation session initialized (STATIC).
[EcoTrace] INFO: -----------------------------------------------------
[EcoTrace] INFO: Region : TR (475 gCO2/kWh)
[EcoTrace] INFO: Hardware Logic: 13th Gen Intel Core i7-13700H
[EcoTrace] INFO: Specifications: 20 Cores | 45.0W TDP
[EcoTrace] INFO: Energy Sensor : Boavizta Advanced Estimation
[EcoTrace] INFO: Memory Config : 15.6 GB DDR4
[EcoTrace] INFO: GPU Accelerator: Intel Iris Xe Graphics (15.0W TDP)
[EcoTrace] INFO: -----------------------------------------------------
At process exit, a session summary is printed automatically:
=======================================================
EcoTrace — Session Summary
=======================================================
Duration : 12.34s
Functions : 5 tracked
Total Carbon : 0.00312000 gCO2
Region : TR (475 gCO2/kWh)
Budget : 0.003120 / 5.000000 gCO2 (0.1%) [OK]
Equivalent : 0.4 min of LED bulb (10W)
=======================================================
CI/CD Integration
Official GitHub Action
Enforce carbon budgets in your pipeline with our official GitHub Action. Add this to your .github/workflows/ci.yml:
- name: EcoTrace Carbon Gate
uses: Zwony/ecotrace@v1.3.0
with:
budget: '10.0'
region: 'US'
Manual CLI Integration
You can also run the gate manually:
ecotrace gate --budget 10.0
If total emissions exceed the budget, the gate fails with exit code 1 — preventing carbon-heavy code from being merged.
Why EcoTrace?
| Feature | EcoTrace v1.0 | CodeCarbon | CarbonTracker |
|---|---|---|---|
| Sampling Interval | 50ms | 15s | Per Epoch |
| Isolation | Process-scoped | System-wide | System-wide |
| Budget Enforcement | Built-in | No | No |
| CI/CD Gate | Built-in | No | No |
| Idle Noise Subtraction | Automatic | No | No |
| Async Support | Native | Limited | No |
- Deep Transparency: Derived from verified manufacturer TDP specifications rather than category averages.
- Fail-Safe Architecture: Guaranteed application continuity even if hardware drivers or API keys are missing.
- Actionable AI: Integrates with Google Gemini to provide specific code optimization advice (optional).
Documentation
Full documentation is available at ecotrace.readthedocs.io.
- Architecture and Science — How the energy model and process isolation work.
- Advanced Usage — GPU tracking, AI insights, benchmarks, and comparison tables.
- API Reference — Technical documentation for core classes and functions.
- Support and Reference — Troubleshooting, region codes, and hardware compatibility.
Contributing
We welcome contributions! Please see our CONTRIBUTING.MD for guidelines on reporting bugs, suggesting features, or contributing hardware data.
Community
Author and License
Emre Ozkal — GitHub · ecotraceteam@gmail.com
MIT License — Use it however you like.
Developed for sustainable software development practices.
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 ecotrace-1.4.0.tar.gz.
File metadata
- Download URL: ecotrace-1.4.0.tar.gz
- Upload date:
- Size: 192.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79788fc796393c83b6fc397121395faf909e590356d8fbbc0712319076b212ce
|
|
| MD5 |
a9956c21490da3328a9b24365e100d1e
|
|
| BLAKE2b-256 |
92e4851946ca0616ccf2dbef14132706ac2074e335acc568bf2df85cea1d9e48
|
File details
Details for the file ecotrace-1.4.0-py3-none-any.whl.
File metadata
- Download URL: ecotrace-1.4.0-py3-none-any.whl
- Upload date:
- Size: 197.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bc733e92525dfebe2178c78b74f8cb939d137c2cb05592158e9264a043dfb86
|
|
| MD5 |
ba597b6f1ac6e0fc27980b720b07998d
|
|
| BLAKE2b-256 |
9b7c3cbceaac32f973d19ecd923c09416a857ea8437588f143eabdf5b1aaac73
|