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. |
📡 Exporters
Exporter | Description |
---|---|
Stdout | Print the metrics in Stdout. |
Datadog | Publish the metrics on Datadog. |
🗺️ Locations
Location | Description | Source |
---|---|---|
European Environment Agency | European Emission co2g/kwh for European countries. | EEA website |
France | RTE energy consumption API in real-time. | RTE API |
🔎 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
🛡️ Licence
https://raw.githubusercontent.com/fvaleye/tracarbon/main/LICENSE.txt[Apache License 2.0]
📚 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.1.0.tar.gz
(13.7 kB
view hashes)
Built Distribution
tracarbon-0.1.0-py3-none-any.whl
(16.7 kB
view hashes)
Close
Hashes for tracarbon-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ab43493d691c598cafbe9ec0c86ea7ddff9011daeed4365e4c5eef92436d4c |
|
MD5 | b19e53d7bfd9e664931eb97fbda3492d |
|
BLAKE2b-256 | 6e4ec5309531b6969378e61c09836fe7fd52022b9093bbb5bf4b7a5954606b9b |