Tracarbon tracks your device's power consumption and calculates your carbon emissions.
Project description
📌 Overview
Tracarbon is a Python library that tracks your device's power consumption and calculates your carbon emissions.
📦 Where to get it
# Install Tracarbon
pip install 'tracarbon'
# Install one or more exporters from the list
pip install 'tracarbon[datadog]'
🔌 Devices: energy consumption
Device | Description |
---|---|
Mac | ✅ Battery energy consumption (must be plugged). |
Linux | ❌ Not yet implemented. |
Windows | ❌ Not yet implemented. |
Cloud Provider | Description |
---|---|
AWS | ✅ Estimation based on cloud-carbon-coefficients. |
GCP | ❌ Not yet implemented. |
Azure | ❌ Not yet implemented. |
📡 Exporters
Exporter | Description |
---|---|
Stdout | Print the metrics in Stdout. |
Datadog | Publish the metrics on Datadog. |
🗺️ Locations
Location | Description | Source |
---|---|---|
Europe | European Environment Agency Emission co2g/kwh for European countries. | EEA website |
France | RTE energy consumption API in real-time. | RTE API |
AWS | AWS Grid emissions factors from cloud-carbon. | cloud-carbon-coefficients |
🔎 Usage
API
import asyncio
from tracarbon import CarbonEmission, EnergyConsumption, Country
from tracarbon.exporters import Metric, StdoutExporter
from tracarbon.hardwares import HardwareInfo
exporter = StdoutExporter()
metrics = list()
location = asyncio.run(Country.get_location())
energy_consumption = EnergyConsumption.from_platform()
platform = HardwareInfo.get_platform()
metrics.append(
Metric(
name="energy_consumption",
value=energy_consumption.run,
tags=[f"platform:{platform}", f"location:{location}"]
)
)
metrics.append(
Metric(
name="co2_emission",
value=CarbonEmission(energy_consumption=energy_consumption, location=location).run,
tags=[f"platform:{platform}", f"location:{location}"]
)
)
metrics.append(
Metric(
name="hardware_cpu_usage",
value=HardwareInfo().get_cpu_usage,
tags=[f"platform:{platform}", f"location:{location}"]
)
)
metrics.append(
Metric(
name="hardware_memory_usage",
value=HardwareInfo().get_memory_usage,
tags=[f"platform:{platform}", f"location:{location}"]
)
)
asyncio.run(exporter.launch_all(metrics=metrics))
CLI
tracarbon run Stdout
💻 Development
Local
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.0.tar.gz
(37.7 kB
view hashes)
Built Distribution
tracarbon-0.2.0-py3-none-any.whl
(40.7 kB
view hashes)
Close
Hashes for tracarbon-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8ab7d7c7a15f77fc249651cc2a252e7b35302d34dc7669c854059d6d3806a9b |
|
MD5 | 324cf2abf0943c976a8b6a555a40913b |
|
BLAKE2b-256 | 825c04011bca9b5439ea914dd1af6432f915e3087037319316bb9cb5d71b21b4 |