Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.
Project description
📌 Overview
Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.
It detects your location and your device automatically before starting to export measurements to an exporter. It could be used as a CLI with already defined metrics or programmatically with the API by defining the metrics that you want to have.
Read more in this article.
📦 Where to get it
# Install Tracarbon
pip install tracarbon
# Install one or more exporters from the list
pip install 'tracarbon[datadog]'
🔌 Devices: energy consumption
Devices | Description |
---|---|
Mac | ✅ Global energy consumption of your Mac (must be plugged into a wall adapter). |
Linux | ❌ Not yet implemented. |
Windows | ❌ Not yet implemented. |
Cloud Provider | Description |
---|---|
AWS | ✅ Used the CPU usage with the EC2 instances carbon emissions datasets of cloud-carbon-coefficients. |
GCP | ❌ Not yet implemented. |
Azure | ❌ Not yet implemented. |
📡 Exporters
Exporter | Description |
---|---|
Stdout | Print the metrics in Stdout. |
Datadog | Send the metrics to Datadog. |
🗺️ Locations
Location | Description | Source |
---|---|---|
Europe | Static file of the European Environment Agency Emission for the co2g/kwh for European countries. | EEA website |
France | Get the co2g/kwh in near real-time using the RTE energy consumption. | RTE API |
AWS | Static file of the AWS Grid emissions factors. | cloud-carbon-coefficients |
⚙️ Configuration
Parameter | Description |
---|---|
TRACARBON_API_ACTIVATED | The activation of the real-time data collection of the carbon emission factor. |
TRACARBON_METRIC_PREFIX_NAME | The prefix to use in all the metrics name. |
TRACARBON_INTERVAL_IN_SECONDS | The interval in seconds to wait between the metrics evaluation. |
TRACARBON_LOG_LEVEL | The level to use for displaying the logs. |
🔎 Usage
Command Line
tracarbon run Stdout
API
from tracarbon import CarbonEmission
from tracarbon.exporters import Metric, StdoutExporter
metric = Metric(
name="co2_emission",
value=CarbonEmission().run,
tags=[],
)
exporter = StdoutExporter(metrics=[metric])
exporter.start()
# Your code
exporter.stop()
with exporter:
# Your code
💻 Development
Local: using Poetry
make setup
make unit-test
🛡️ Licence
📚 Documentation
The documentation is hosted here: https://fvaleye.github.io/tracarbon/documentation
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
tracarbon-0.2.4.tar.gz
(40.1 kB
view hashes)
Built Distribution
tracarbon-0.2.4-py3-none-any.whl
(43.6 kB
view hashes)
Close
Hashes for tracarbon-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c599ae9d2ba453631799be8d279d9e7f6bf35d40ef70108b38ecaaf9c2bc5902 |
|
MD5 | e19602ccf16bb501a9bf5e65b01917ed |
|
BLAKE2b-256 | 4733cf8c6f5c8526a15031408459a27a2b78461017e808a27817ade0e52b8f87 |