tracarbon
π Tracarbon tracks your device's energy consumption and calculates your carbon emissions using your location.
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
-
βcodemeta.json file
Found codemeta.json file -
β.zenodo.json file
Found .zenodo.json file -
βDOI references
-
βAcademic publication links
-
βCommitters with academic emails
-
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (10.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
π Tracarbon tracks your device's energy consumption and calculates your carbon emissions using your location.
Basic Info
- Host: GitHub
- Owner: fvaleye
- License: apache-2.0
- Language: Python
- Default Branch: main
- Homepage: https://fvaleye.github.io/tracarbon/documentation/
- Size: 5.57 MB
Statistics
- Stars: 104
- Watchers: 5
- Forks: 7
- Open Issues: 6
- Releases: 33
Topics
Metadata Files
README.md

π 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
```sh
Install Tracarbon
pip install tracarbon ```
```sh
Install one or more exporters from the list
pip install 'tracarbon[datadog,prometheus,kubernetes]' ```
π Devices: energy consumption
| Devices | Description | | ----------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | Mac | β Global energy consumption of your Mac (must be plugged into a wall adapter). | | Linux | β οΈ Only with RAPL. See #1. It works with containers on Kubernetes using the Metric API if available. | | Windows | β Not yet implemented. See #184. |
| Cloud Provider | Description | | ------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | AWS | β Use the hardware's 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. | | JSON | Write the metrics in a JSON file. | | Prometheus | Send the metrics to Prometheus. | | Datadog | Send the metrics to Datadog. |
πΊοΈ Locations
| Location | Description | Source | | ------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Worldwide | Get the latest co2g/kwh in near real-time using the CO2Signal or ElectricityMaps APIs. See here for the list of available zones. | CO2Signal API or ElectricityMaps | | Europe | Static file created from the European Environment Agency Emission for the co2g/kwh in European countries. | EEA website | | AWS | Static file of the AWS Grid emissions factors. | cloud-carbon-coefficients |
βοΈ Configuration
The environment variables can be set from an environment file .env.
| Parameter | Description | | ----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | TRACARBONCO2SIGNALAPIKEY | The api key received from CO2Signal or ElectricityMaps. | | TRACARBONCO2SIGNALURL | The url of CO2Signal is the default endpoint to retrieve the last known state of the zone, but it could be changed to ElectricityMaps. | | TRACARBONMETRICPREFIXNAME | The prefix to use in all the metrics name. | | TRACARBONINTERVALINSECONDS | The interval in seconds to wait between the metrics evaluation. | | TRACARBONLOG_LEVEL | The level to use for displaying the logs. |
π Usage
Request your API key
- Go to CO2Signal and get your free API key for non-commercial use, or go to ElectricityMaps for commercial use.
- This API is used to retrieve the last known carbon intensity (in gCO2eq/kWh) of electricity consumed in your location.
- Set your API key in the environment variables, in the
.envfile or directly in the configuration. - If you would like to start without an API key, it's possible, the carbon intensity will be loaded statistically from a file.
- Launch Tracarbon π
Command Line
sh
tracarbon run
API
```python from tracarbon import TracarbonBuilder, TracarbonConfiguration
configuration = TracarbonConfiguration() # Your configuration tracarbon = TracarbonBuilder(configuration=configuration).build() tracarbon.start()
Your code
tracarbon.stop()
with tracarbon: # Your code
report = tracarbon.report() # Get the report ```
π» Development
Local: using uv
sh
make init
make test-unit
π‘οΈ Licence
π Documentation
The documentation is hosted here: https://fvaleye.github.io/tracarbon/documentation
Owner
- Name: Florian Valeye
- Login: fvaleye
- Kind: user
- Location: France
- Company: @BackMarket
- Website: https://fvaleye.github.io/
- Repositories: 14
- Profile: https://github.com/fvaleye
GitHub Events
Total
- Create event: 63
- Issues event: 3
- Release event: 7
- Watch event: 5
- Delete event: 58
- Issue comment event: 50
- Push event: 75
- Pull request review event: 8
- Pull request event: 108
- Fork event: 1
Last Year
- Create event: 63
- Issues event: 3
- Release event: 7
- Watch event: 5
- Delete event: 58
- Issue comment event: 50
- Push event: 75
- Pull request review event: 8
- Pull request event: 108
- Fork event: 1
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| dependabot[bot] | 4****] | 266 |
| fvaleye | f****e@g****m | 79 |
| Patric Gruber | me@p****t | 2 |
| Brice AIELLO | b****o@m****m | 1 |
| Florian VALEYE | f****e@F****l | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 12
- Total pull requests: 556
- Average time to close issues: about 2 months
- Average time to close pull requests: 5 days
- Total issue authors: 7
- Total pull request authors: 4
- Average comments per issue: 1.0
- Average comments per pull request: 0.31
- Merged pull requests: 396
- Bot issues: 0
- Bot pull requests: 474
Past Year
- Issues: 2
- Pull requests: 123
- Average time to close issues: about 1 month
- Average time to close pull requests: 10 days
- Issue authors: 2
- Pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.51
- Merged pull requests: 65
- Bot issues: 0
- Bot pull requests: 110
Top Authors
Issue Authors
- corentinbettiol (3)
- fvaleye (3)
- fatma-laribi (2)
- maxbaiw29 (1)
- patricgruber (1)
- AceWang377 (1)
- JosuaCarl (1)
Pull Request Authors
- dependabot[bot] (493)
- fvaleye (81)
- patricgruber (2)
- baiello (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 77 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 1
(may contain duplicates) - Total versions: 66
- Total maintainers: 1
proxy.golang.org: github.com/fvaleye/tracarbon
- Documentation: https://pkg.go.dev/github.com/fvaleye/tracarbon#section-documentation
- License: apache-2.0
-
Latest release: v0.8.0
published 12 months ago
Rankings
pypi.org: tracarbon
Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.
- Documentation: https://tracarbon.readthedocs.io/
- License: apache-2.0
-
Latest release: 0.8.0
published 12 months ago
Rankings
Maintainers (1)
Dependencies
- abatilo/actions-poetry v2 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/checkout v3 composite
- github/codeql-action/analyze v2 composite
- github/codeql-action/init v2 composite
- abatilo/actions-poetry v2 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- python 3.8-buster build
- Babel 2.11.0 develop
- GitPython 3.1.30 develop
- Jinja2 3.1.2 develop
- MarkupSafe 2.1.1 develop
- PyYAML 6.0 develop
- Pygments 2.14.0 develop
- Sphinx 5.3.0 develop
- alabaster 0.7.13 develop
- bandit 1.7.4 develop
- beautifulsoup4 4.11.1 develop
- black 22.12.0 develop
- commonmark 0.9.1 develop
- coverage 7.0.5 develop
- docutils 0.19 develop
- exceptiongroup 1.1.0 develop
- execnet 1.9.0 develop
- future 0.18.3 develop
- gitdb 4.0.10 develop
- imagesize 1.4.1 develop
- iniconfig 2.0.0 develop
- isort 5.11.4 develop
- mando 0.6.4 develop
- mypy 0.991 develop
- mypy-extensions 0.4.3 develop
- packaging 23.0 develop
- pathspec 0.10.3 develop
- pbr 5.11.1 develop
- platformdirs 2.6.2 develop
- pluggy 1.0.0 develop
- pprintpp 0.4.0 develop
- pydata-sphinx-theme 0.12.0 develop
- pytest 7.2.1 develop
- pytest-asyncio 0.20.3 develop
- pytest-clarity 1.0.1 develop
- pytest-cov 4.0.0 develop
- pytest-mock 3.10.0 develop
- pytest-xdist 3.1.0 develop
- pytz 2022.7.1 develop
- radon 5.1.0 develop
- rich 13.1.0 develop
- six 1.16.0 develop
- smmap 5.0.0 develop
- snowballstemmer 2.2.0 develop
- soupsieve 2.3.2.post1 develop
- sphinxcontrib-devhelp 1.0.2 develop
- sphinxcontrib-htmlhelp 2.0.0 develop
- sphinxcontrib-jsmath 1.0.1 develop
- sphinxcontrib-qthelp 1.0.3 develop
- sphinxcontrib-serializinghtml 1.1.5 develop
- sphinxcontrib.applehelp 1.0.2 develop
- stevedore 3.5.2 develop
- toml 0.10.2 develop
- tomli 2.0.1 develop
- typed-ast 1.5.4 develop
- types-aiofiles 22.1.0.4 develop
- types-requests 2.28.11.7 develop
- types-ujson 5.7.0.0 develop
- types-urllib3 1.26.25.4 develop
- aiocache 0.12.0
- aiofiles 22.1.0
- aiohttp 3.8.3
- aiosignal 1.3.1
- async-timeout 4.0.2
- asynctest 0.13.0
- attrs 22.2.0
- cached-property 1.5.2
- certifi 2022.12.7
- charset-normalizer 2.1.1
- click 8.1.3
- colorama 0.4.6
- datadog 0.44.0
- ec2-metadata 2.11.0
- frozenlist 1.3.3
- idna 3.4
- importlib-metadata 6.0.0
- loguru 0.6.0
- msgpack 1.0.4
- multidict 6.0.4
- prometheus-client 0.15.0
- psutil 5.9.4
- pydantic 1.10.4
- python-dotenv 0.21.0
- requests 2.28.2
- typer 0.7.0
- typing-extensions 4.4.0
- ujson 5.7.0
- urllib3 1.26.14
- win32-setctime 1.1.0
- yarl 1.8.2
- zipp 3.11.0
- bandit ^1.7.4 develop
- black ^22.12.0 develop
- datadog ^0.44.0 develop
- isort ^5.11.4 develop
- mypy ^0.991 develop
- prometheus-client ^0.15.0 develop
- pydata-sphinx-theme ^0.12.0 develop
- pytest ^7.2.0 develop
- pytest-asyncio ^0.20.3 develop
- pytest-clarity ^1.0.1 develop
- pytest-cov ^4.0.0 develop
- pytest-mock ^3.7.0 develop
- pytest-xdist ^3.1.0 develop
- radon ^5.1.0 develop
- sphinx ^5.3.0 develop
- toml ^0.10.2 develop
- types-aiofiles ^22.1.0 develop
- types-requests ^2.28.11 develop
- types-ujson ^5.7.0 develop
- aiocache >=0.11.1,<0.13.0
- aiofiles ^22.1.0
- aiohttp ^3.8.1
- datadog ^0.44.0
- ec2-metadata ^2.10.0
- loguru ^0.6.0
- msgpack ^1.0.4
- prometheus-client ^0.15.0
- psutil ^5.9.1
- pydantic ^1.9.1
- python ^3.7
- python-dotenv ^0.21.0
- typer >=0.4.1,<0.8.0
- ujson ^5.3.0