sitespeedio / sitespeed.io

sitespeed.io is an open-source tool for comprehensive web performance analysis, enabling you to test, monitor, and optimize your website’s speed using real browsers in various environments.
https://www.sitespeed.io/
MIT License
4.74k stars 600 forks source link

Adding optional input parameter "Country code" from electricitymaps #3935

Open MartinWolfert opened 1 year ago

MartinWolfert commented 1 year ago

Feature/improvement

Hi @Sitespeed,

to get more specific CO2 numbers /measurements, I would raise the idea to add a possibility to add a country code from https://app.electricitymaps.com/zone/DE , as optional input in the sustainability plugin.

Best, Martin

soulgalore commented 1 year ago

Sounds cool, I'll have a look when I get some time maybe this weekend.

mrchrisadams commented 1 year ago

Hey gang - this is supported in co2.js already - we pull open data from Ember here:

https://developers.thegreenwebfoundation.org/co2js/data/

And this here demonstrates how to use specific country info if need be in calculations: https://developers.thegreenwebfoundation.org/co2js/tutorials/customise-website-carbon-calculations

I'm happy to provide further pointers if it helps 👍

MartinWolfert commented 1 year ago

Hi @all, great to hear @mrchrisadams :)

I'll share my thoughts:

Sitespeedio can in my opinion serve very well for a long term monitoring to help visualize and prove S3 costs in the sustainability report.

In addition, IMHO the respective "country-specific" emissions would be a good contribution to make the numbers more "valid".

What I did not consider in my impulse from 3 weeks ago, and what I generally ask myself, is how old are the data from Ember that are taken as a basis for calculation?

Because: the grid intensity changes in the course of a year and therefore also the CO2 consumption. If I visualize the monitoring data of a website based on the Sustainabiliy Web model over a year, then the fluctuations of the grid data are included in the numbers and visualizations without knowing the values / numbers of the grid intensity at the time of the measurements. So it may be that I have "outliers" in my numbers and visualizations that I can't explain in web terms, because they occur due to changing grid intensity In the "Measurements" of my InFLuxDB I did not find any references to grid intensity data.

Am I thinking wrong or did I overread the documentation in some point?

mrchrisadams commented 1 year ago

Hi Martin,

See my replies inline:

What I did not consider in my impulse from 3 weeks ago, and what I generally ask myself, is how old are the data from Ember that are taken as a basis for calculation?

We use the latest data we have available from Ember for a given year, who update their figures for a given year as they get better access to underlying data from those countries. You can see the monthly refinements to the figures at the link below, when we carry out an automated import for the latest data for a given year.

https://github.com/thegreenwebfoundation/co2.js/pulls?q=is%3Apr+is%3Aclosed+%22%5BAUTOMATED%5D%22+author%3Aapp%2Fgithub-actions

Because: the grid intensity changes in the course of a year and therefore also the CO2 consumption. If I visualize the monitoring data of a website based on the Sustainabiliy Web model over a year, then the fluctuations of the grid data are included in the numbers and visualizations without knowing the values / numbers of the grid intensity at the time of the measurements. So it may be that I have "outliers" in my numbers and visualizations that I can't explain in web terms, because they occur due to changing grid intensity

We use annual figures in CO2.js to provide a consistent baseline for calculations like this, and to avoid grid fluctations giving unpredictable results.

Sourcing carbon intensity data shouldn’t be the remit of developers. For that reason, CO2.js now includes yearly average grid intensity data from Ember,

Source: CO2.js: Data by The Green Web Foundation

We are looking at making higher temporal resolution info available in future, because the numbers can change significantly even inside a given day, and there are things you can do to take advantage of that. I've put together this notebook showing how the grid intensity changed in Germany in 2022 - if you're curious:

https://observablehq.com/d/46b74e017fba2f05

But right now, we use annual figures, because we like having consistent metrics too :D