mlco2 / codecarbon

Track emissions from Compute and recommend ways to reduce their impact on the environment.
https://mlco2.github.io/codecarbon
MIT License
1.11k stars 173 forks source link

feat: add logfire as output method #542

Closed inimaz closed 3 months ago

inimaz commented 4 months ago

Goal

Open the discussion on how codecarbon could send the output to logfire, a new monitoring framework https://docs.pydantic.dev/logfire/

How to use this branch

pip install logfire
logfire auth

This redirects to a page where you can log in with your github user.

Once your logfire account is created, run the script:

hatch run python examples/logfire_metrics.py'

Output

Example of the output that I obtain image

inimaz commented 4 months ago

As discussed @SabAmine, here it is a rough example using the log output. What do you think?

inimaz commented 4 months ago

Example of a chart on logfire using the codecarbon data image

inimaz commented 4 months ago

Same example with emissions chart in g image

inimaz commented 3 months ago

@SaboniAmine It should be ready to merge. Now it uses the composite output handling coming from master. And it calls logfire.configure() to setup the main instance of logfire (see last commit).