question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

co2 emissions estimation incoherent between LUT and UI

See original GitHub issue

Preflight Checklist

  • [ x] I have read the Contributing Guidelines for this project.
  • [ x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Operating System:
    • macOS 10.13.6
  • Browser:
    • Chrome

Expected Behavior

I would expect for the same time window selected for the billing report (AWS), to obtain the same amount of CO2 total emissions either via using the LUT or via using the UI.

Actual Behavior

The LUT estimation is way bigger, by a factor of 10k

Any help on ensuring the LUT is properly used ?

I just multiply the usageAmount by the CO2e factor…

If i look at the code of the following code of the UnknownEstimator

export default class UnknownEstimator implements IFootprintEstimator {
  constructor(private estimateKilowattHoursBy: EstimateUnknownUsageBy) {}

  estimate(
    data: UnknownUsage[],
    region: string,
    emissionsFactors: CloudConstantsEmissionsFactors,
    constants: CloudConstants,
  ): FootprintEstimate[] {
    return data.map((data: UnknownUsage) => {
      const estimatedKilowattHours = this.estimateKilowattHours(
        data,
        constants.kilowattHoursByServiceAndUsageUnit,
      )
      const estimatedCo2eEmissions = estimateCo2(
        estimatedKilowattHours,
        region,
        emissionsFactors,
      )
      return {
        timestamp: data.timestamp,
        kilowattHours: estimatedKilowattHours,
        co2e: estimatedCo2eEmissions,
        usesAverageCPUConstant: false,
      }
    })
  }

  private estimateKilowattHours(
    unknownUsage: UnknownUsage,
    kilowattHoursByServiceAndUsageUnit: KilowattHoursByServiceAndUsageUnit,
  ): number {
    const serviceAndUsageUnit =
      kilowattHoursByServiceAndUsageUnit[unknownUsage.service] &&
      kilowattHoursByServiceAndUsageUnit[unknownUsage.service][
        unknownUsage.usageUnit
      ]

    if (serviceAndUsageUnit)
      return (
        (serviceAndUsageUnit.kilowattHours /
          serviceAndUsageUnit[this.estimateKilowattHoursBy]) *
        unknownUsage[this.estimateKilowattHoursBy]
      )

    const totalForUsageUnit =
      kilowattHoursByServiceAndUsageUnit.total[unknownUsage.usageUnit]

    if (totalForUsageUnit)
      return (
        (totalForUsageUnit.kilowattHours /
          totalForUsageUnit[this.estimateKilowattHoursBy]) *
        unknownUsage[this.estimateKilowattHoursBy]
      )
    const totalKiloWattHours = this.getTotalFor(
      'kilowattHours',
      kilowattHoursByServiceAndUsageUnit,
    )
    const totalCost = this.getTotalFor(
      this.estimateKilowattHoursBy,
      kilowattHoursByServiceAndUsageUnit,
    )

    return (
      (totalKiloWattHours / totalCost) *
      unknownUsage[this.estimateKilowattHoursBy]
    )
  }

my understanding, it is that even if for the unknown row, we do not find a “UsageUnit”, we would still provide an estimation via these lines

 const totalKiloWattHours = this.getTotalFor(
      'kilowattHours',
      kilowattHoursByServiceAndUsageUnit,
    )
    const totalCost = this.getTotalFor(
      this.estimateKilowattHoursBy,
      kilowattHoursByServiceAndUsageUnit,
    )

    return (
      (totalKiloWattHours / totalCost) *
      unknownUsage[this.estimateKilowattHoursBy]
    )

Is it not misaligned with the methodology description where we only provide an estimate if there is a match at one of the following two levels

  • servicename & usageunit
  • usageunit

?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
lllllAlexlllllcommented, Oct 31, 2022

@4upz Hey Arik, Thank you for dealing with the bug. The issue is a significant obstacle for our Carbon Footprint Tracking project. We would like to offer some help since we have an experienced Node JS developer on our team. Would you like to collaborate on this?

2reactions
ericksodcommented, Jun 20, 2022

Thanks all - we will also take a look at this. Additionally we got a request to look at how this works with Unknown usage types, see here: https://groups.google.com/g/cloud-carbon-footprint/c/RrrYH8qQVH0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Greenhouse Gas Equivalencies Calculator | US EPA
The Greenhouse Gas Equivalencies calculator allows you to convert emissions or energy data to the equivalent amount of carbon dioxide (CO2 )  ......
Read more >
Historical CO2 emissions from land use and land cover ... - BG
We estimate that the global CO2 emissions from land use and land cover change were 1.36±0.42 PgC yr−1 (1σ range) on average over...
Read more >
Allocation of GHG Emissions from a Combined Heat and ...
Guide to calculation worksheets – “Indirect CO2 emissions from the consumption of purchased electricity, heat or steam”. This is a cross-sector tool, ...
Read more >
Carbon Emissions and Large Neural Network Training
Here we investigate and share the estimates of the energy consumed and CO 2 e 3 of these recent and large NLP models....
Read more >
remotesensing-12-03932-v3.pdf
However, large uncertainties in estimating CO2 emissions at the urban ... between grid value and uncertainty, from the LUT and gridded CO2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found