Skip to content

Commit 5c61390

Browse files
author
brunnert
committed
Move ccf coefficient data
1 parent 354ad98 commit 5c61390

15 files changed

+215
-12
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ resource demand data as [Attributes](https://opentelemetry.io/docs/concepts/sign
88

99
In addition to attaching Span attributes for OpenTelemetry Traces this extension publishes the resource demand data as OpenTelemetry [Metrics](https://opentelemetry.io/docs/concepts/signals/metrics/) for all entry level transactions (e.g., API calls) of an instrumented application. You can find a list of metrics published by this extension in the corresponding [section](#OpenTelemetry-Metrics-published-by-this-extension). If you are just starting with analyzing the resource demand of your application this is the best starting point for you, before you dig into the span attributes to analyze where exactly the resources are consumed.
1010

11-
Furthermore, the extension follows the [Methodology](https://www.cloudcarbonfootprint.org/docs/methodology/) published by the [Cloud Carbon Footprint (CCF)](https://www.cloudcarbonfootprint.org/) project to calculate the carbon emissions of an instrumented application. It contains the [Cloud Carbon coefficients](https://github.com/cloud-carbon-footprint/ccf-coefficients) for the biggest clouds (AWS, Azure, and GCP) and their instances. Using the resource demand data and the data of the CCF coefficents allows you to calculate the carbon emissions of single API calls of your application. This is usually done in an OpenTelemetry compatible backend, you can find an example on how this works in the [Demo](#demo) section of this document. If you want to use the extension for your own application check out the [Quickstart](#Quickstart) and [Configuration Options](#configuration-options) section of this document.
11+
Furthermore, the extension follows the [Methodology](https://www.cloudcarbonfootprint.org/docs/methodology/) published by the [Cloud Carbon Footprint (CCF)](https://www.cloudcarbonfootprint.org/) project to calculate the carbon emissions of an instrumented application. It contains data from the [CCF coefficients project](https://github.com/cloud-carbon-footprint/ccf-coefficients) for the biggest clouds (AWS, Azure, and GCP) and their instances. Using the resource demand data and the data of the CCF coefficents allows you to calculate the carbon emissions of single API calls of your application. This is usually done in an OpenTelemetry compatible backend, you can find an example on how this works in the [Demo](#demo) section of this document. If you want to use the extension for your own application check out the [Quickstart](#Quickstart) and [Configuration Options](#configuration-options) section of this document.
1212

1313
# Quickstart
1414

@@ -69,7 +69,7 @@ This application will run until you stop it and generate data. While it is gener
6969

7070
http://localhost:3000/grafana/dashboards
7171

72-
After some time you can see the data produced by this application in the following dashboard. As an example the CPU and memory demands are shown as they are supported on most plattforms as well as the Emission Calculation Factors. Furthermore, we have integrated a [Software Carbon Intensity](https://sci.greensoftware.foundation/) calculation for each transaction based on this data. This calculation is based on our work presented at the [Workshop on Challenges in Performance Methods for Software Development (WOSP-C) 2024](https://www.retit.de/wp-content/uploads/2024/05/Green_Software_Metrics.pdf) and [EcoCompute](https://www.retit.de/wp-content/uploads/2024/04/2024-04-25_How_to_Measure_CO2-Emissions_For_Every_API_Call_Of_Your_Microservices.pdf) with the main difference that we are now using the [Cloud Carbon coefficients](https://github.com/cloud-carbon-footprint/ccf-coefficients) instead of an external datasource for the emission data.
72+
After some time you can see the data produced by this application in the following dashboard. As an example the CPU and memory demands are shown as they are supported on most plattforms as well as the Emission Calculation Factors. Furthermore, we have integrated a [Software Carbon Intensity](https://sci.greensoftware.foundation/) calculation for each transaction based on this data. This calculation is based on our work presented at the [Workshop on Challenges in Performance Methods for Software Development (WOSP-C) 2024](https://www.retit.de/wp-content/uploads/2024/05/Green_Software_Metrics.pdf) and [EcoCompute](https://www.retit.de/wp-content/uploads/2024/04/2024-04-25_How_to_Measure_CO2-Emissions_For_Every_API_Call_Of_Your_Microservices.pdf) with the main difference that we are now using the [Cloud Carbon coefficients](https://github.com/cloud-carbon-footprint/ccf-coefficients) instead of an external datasource for the emission data.
7373

7474
![dashboard.png](img/dashboard.png)
7575

@@ -145,4 +145,5 @@ Bytes written to the network by the thread processing the Span...
145145
Bytes allocated in memory by the thread processing the Span...
146146

147147
io.retit.startheapbyteallocation- ...at Span start time
148-
io.retit.endheapbyteallocation - ...at Span end time
148+
io.retit.endheapbyteallocation - ...at Span end time
149+

extension/src/main/java/io/retit/opentelemetry/javaagent/extension/emissions/CloudCarbonFootprintData.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public CloudCarbonFootprintInstanceData getCloudInstanceDetails() {
8181
private Double initializeGridEmissionFactor(final String envRegion) {
8282
double gridEmissionFactorMetricTonPerKwh = 0.0;
8383
if (Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY_VALUE_AWS.equalsIgnoreCase(InstanceConfiguration.getCloudProvider())) {
84-
gridEmissionFactorMetricTonPerKwh = getDoubleValueFromCSVForRegionOrInstance("/grid-emissions/grid-emissions-factors-aws.csv", 0, envRegion, 3);
84+
gridEmissionFactorMetricTonPerKwh = getDoubleValueFromCSVForRegionOrInstance("/ccf-coefficients/grid-emissions/grid-emissions-factors-aws.csv", 0, envRegion, 3);
8585
} else if (Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY_VALUE_AZURE.equalsIgnoreCase(InstanceConfiguration.getCloudProvider())) {
86-
gridEmissionFactorMetricTonPerKwh = getDoubleValueFromCSVForRegionOrInstance("/grid-emissions/grid-emissions-factors-azure.csv", 0, envRegion, 3);
86+
gridEmissionFactorMetricTonPerKwh = getDoubleValueFromCSVForRegionOrInstance("/ccf-coefficients/grid-emissions/grid-emissions-factors-azure.csv", 0, envRegion, 3);
8787
} else if (Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY_VALUE_GCP.equalsIgnoreCase(InstanceConfiguration.getCloudProvider())) {
88-
gridEmissionFactorMetricTonPerKwh = getDoubleValueFromCSVForRegionOrInstance("/grid-emissions/grid-emissions-factors-gcp.csv", 0, envRegion, 2);
88+
gridEmissionFactorMetricTonPerKwh = getDoubleValueFromCSVForRegionOrInstance("/ccf-coefficients/grid-emissions/grid-emissions-factors-gcp.csv", 0, envRegion, 2);
8989
}
9090

9191
// we need to do the conversion using BigDecimal to avoid loosing precision
@@ -146,7 +146,7 @@ private CloudCarbonFootprintInstanceData initializeCloudInstanceDetails(final St
146146
*/
147147
private CloudCarbonFootprintInstanceData initializeCloudInstanceDetailsForGcp(final String vmInstanceType) {
148148

149-
CloudCarbonFootprintInstanceData cloudVMInstanceDetails = initializeCloudInstanceDetailsCommon("/instances/gcp-instances.csv", "/instances/coefficients-gcp-use.csv", vmInstanceType);
149+
CloudCarbonFootprintInstanceData cloudVMInstanceDetails = initializeCloudInstanceDetailsCommon("/ccf-coefficients/instances/gcp-instances.csv", "/ccf-coefficients/instances/coefficients-gcp-use.csv", vmInstanceType);
150150
cloudVMInstanceDetails.setCloudProvider(CloudProvider.GCP);
151151
if (cloudVMInstanceDetails.getCpuPowerConsumptionIdle() == DOUBLE_ZERO) {
152152
cloudVMInstanceDetails.setCpuPowerConsumptionIdle(CloudCarbonFootprintCoefficients.AVERAGE_MIN_WATT_GCP);
@@ -167,7 +167,7 @@ private CloudCarbonFootprintInstanceData initializeCloudInstanceDetailsForGcp(fi
167167
*/
168168
private CloudCarbonFootprintInstanceData initializeCloudInstanceDetailsForAzure(final String vmInstanceType) {
169169

170-
CloudCarbonFootprintInstanceData cloudVMInstanceDetails = initializeCloudInstanceDetailsCommon("/instances/azure-instances.csv", "/instances/coefficients-azure-use.csv", vmInstanceType);
170+
CloudCarbonFootprintInstanceData cloudVMInstanceDetails = initializeCloudInstanceDetailsCommon("/ccf-coefficients/instances/azure-instances.csv", "/ccf-coefficients/instances/coefficients-azure-use.csv", vmInstanceType);
171171
cloudVMInstanceDetails.setCloudProvider(CloudProvider.AZURE);
172172
if (cloudVMInstanceDetails.getCpuPowerConsumptionIdle() == DOUBLE_ZERO) {
173173
cloudVMInstanceDetails.setCpuPowerConsumptionIdle(CloudCarbonFootprintCoefficients.AVERAGE_MIN_WATT_AZURE);
@@ -227,7 +227,7 @@ private CloudCarbonFootprintInstanceData initializeCloudInstanceDetailsForAws(fi
227227
CloudCarbonFootprintInstanceData cloudVMInstanceDetails = new CloudCarbonFootprintInstanceData();
228228
cloudVMInstanceDetails.setCloudProvider(CloudProvider.AWS);
229229
cloudVMInstanceDetails.setInstanceType(vmInstanceType);
230-
List<String[]> csvLines = CSVParser.readAllCSVLinesExceptHeader("/instances/aws-instances.csv");
230+
List<String[]> csvLines = CSVParser.readAllCSVLinesExceptHeader("/ccf-coefficients/instances/aws-instances.csv");
231231
for (String[] lineFields : csvLines) {
232232
String csvInstanceType = lineFields[0];
233233
if (csvInstanceType.equalsIgnoreCase(vmInstanceType.trim())) {
@@ -254,11 +254,11 @@ private CloudCarbonFootprintInstanceData initializeCloudInstanceDetailsForAws(fi
254254
*/
255255
public Double getTotalEmbodiedEmissionsForInstanceType(final String instanceType) {
256256
if (Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY_VALUE_AWS.equalsIgnoreCase(InstanceConfiguration.getCloudProvider())) {
257-
return getDoubleValueFromCSVForRegionOrInstance("/embodied-emissions/coefficients-aws-embodied.csv", 1, instanceType, 6);
257+
return getDoubleValueFromCSVForRegionOrInstance("/ccf-coefficients/embodied-emissions/coefficients-aws-embodied.csv", 1, instanceType, 6);
258258
} else if (Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY_VALUE_GCP.equalsIgnoreCase(InstanceConfiguration.getCloudProvider())) {
259-
return getDoubleValueFromCSVForRegionOrInstance("/embodied-emissions/coefficients-gcp-embodied-mean.csv", 1, instanceType, 2);
259+
return getDoubleValueFromCSVForRegionOrInstance("/ccf-coefficients/embodied-emissions/coefficients-gcp-embodied-mean.csv", 1, instanceType, 2);
260260
} else if (Constants.RETIT_EMISSIONS_CLOUD_PROVIDER_CONFIGURATION_PROPERTY_VALUE_AZURE.equalsIgnoreCase(InstanceConfiguration.getCloudProvider())) {
261-
return getDoubleValueFromCSVForRegionOrInstance("/embodied-emissions/coefficients-azure-embodied.csv", 2, instanceType, 8);
261+
return getDoubleValueFromCSVForRegionOrInstance("/ccf-coefficients/embodied-emissions/coefficients-azure-embodied.csv", 2, instanceType, 8);
262262
}
263263
return 0.0;
264264
}

0 commit comments

Comments
 (0)