Skip to main content

Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.

Project description

Alt text

doc pypi example workflow

📌 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

Apache License 2.0

📚 Documentation

The documentation is hosted here: https://fvaleye.github.io/tracarbon/documentation

Project details


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.3.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

tracarbon-0.2.3-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file tracarbon-0.2.3.tar.gz.

File metadata

  • Download URL: tracarbon-0.2.3.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.13 Linux/5.13.0-1031-azure

File hashes

Hashes for tracarbon-0.2.3.tar.gz
Algorithm Hash digest
SHA256 38e09dc2c97004646b8db999bb2667363a670b14204114051cf62ea62272be9f
MD5 0806a65d97116fabf90575d9084e34af
BLAKE2b-256 51a6d5ff3531d6878cb21a6020aa64b63a6b65caa2bdf9406403ea4c84b6dc1b

See more details on using hashes here.

Provenance

File details

Details for the file tracarbon-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: tracarbon-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 43.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.13 Linux/5.13.0-1031-azure

File hashes

Hashes for tracarbon-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bfa774c0144dfdb647af945c0dfc378a79d05dd4868f3a3d722a5ad48a8ed1e3
MD5 de024417cc66b71961f4e0b4cf1aca88
BLAKE2b-256 597b89044ea1efc7ddf26efb738608423f7432bbdd6c653f3c335d5bbb78913b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page