diff --git a/x-pack/plugin/profiling/build.gradle b/x-pack/plugin/profiling/build.gradle index 8275bfe633c91..3790fb6e762aa 100644 --- a/x-pack/plugin/profiling/build.gradle +++ b/x-pack/plugin/profiling/build.gradle @@ -24,3 +24,7 @@ dependencies { testImplementation project(path: xpackModule('ilm')) testImplementation project(':modules:data-streams') } +tasks.named("dependencyLicenses").configure { + ignoreFile 'cloudcarbonfootprint-LICENSE.txt' + ignoreFile 'cloudcarbonfootprint-NOTICE.txt' +} diff --git a/x-pack/plugin/profiling/licenses/cloudcarbonfootprint-LICENSE.txt b/x-pack/plugin/profiling/licenses/cloudcarbonfootprint-LICENSE.txt new file mode 100644 index 0000000000000..b46d5a742382d --- /dev/null +++ b/x-pack/plugin/profiling/licenses/cloudcarbonfootprint-LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2021 Thoughtworks Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/x-pack/plugin/profiling/licenses/cloudcarbonfootprint-NOTICE.txt b/x-pack/plugin/profiling/licenses/cloudcarbonfootprint-NOTICE.txt new file mode 100644 index 0000000000000..44eaf62f3b2c9 --- /dev/null +++ b/x-pack/plugin/profiling/licenses/cloudcarbonfootprint-NOTICE.txt @@ -0,0 +1,6 @@ +For CO2 calculations, we include and use data from +https://github.com/PaoloFrigo/cloud-carbon-footprint . + +License: Apache 2.0 + +Copyright: Cloud Carbon Footprint, (C) 2021 Thoughtworks, Inc. diff --git a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CO2Calculator.java b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CO2Calculator.java index 4013afd2002f2..454cd35b396b9 100644 --- a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CO2Calculator.java +++ b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CO2Calculator.java @@ -9,8 +9,6 @@ import java.util.Map; -import static java.util.Map.entry; - final class CO2Calculator { private static final double DEFAULT_SAMPLING_FREQUENCY = 20.0d; private static final double DEFAULT_CO2_TONS_PER_KWH = 0.000379069d; // unit: metric tons / kWh @@ -66,150 +64,10 @@ private double getKiloWattsPerCore(HostMetadata host) { } private double getCO2TonsPerKWH(HostMetadata host) { - Provider provider = PROVIDERS.get(host.instanceType.provider); - return provider == null ? customCO2PerKWH : provider.co2TonsPerKWH.getOrDefault(host.instanceType.region, customCO2PerKWH); + return CloudProviders.getCO2TonsPerKWHOrDefault(host.instanceType.provider, host.instanceType.region, customCO2PerKWH); } private double getDatacenterPUE(HostMetadata host) { - Provider provider = PROVIDERS.get(host.instanceType.provider); - return provider == null ? customDatacenterPUE : provider.pue; - } - - private record Provider(double pue, Map co2TonsPerKWH) {} - - // values are taken from https://www.cloudcarbonfootprint.org/docs/methodology/ - private static final Map PROVIDERS; - static { - // noinspection (explicit type arguments speedup compilation and analysis time) - PROVIDERS = Map.of( - "aws", - new Provider( - 1.135d, - Map.ofEntries( - entry("us-east-1", 0.000379069d), - entry("us-east-2", 0.000410608d), - entry("us-west-1", 0.000322167d), - entry("us-west-2", 0.000322167d), - entry("us-gov-east-1", 0.000379069d), - entry("us-gov-west-1", 0.000322167d), - entry("af-south-1", 0.0009006d), - entry("ap-east-1", 0.00071d), - entry("ap-south-1", 0.0007082d), - entry("ap-northeast-3", 0.0004658d), - entry("ap-northeast-2", 0.0004156d), - entry("ap-southeast-1", 0.000408d), - entry("ap-southeast-2", 0.00076d), - entry("ap-northeast-1", 0.0004658d), - entry("ca-central-1", 0.00012d), - entry("cn-north-1", 0.0005374d), - entry("cn-northwest-1", 0.0005374d), - entry("eu-central-1", 0.000311d), - entry("eu-west-1", 0.0002786d), - entry("eu-west-2", 0.000225d), - entry("eu-south-1", 0.0002134d), - entry("eu-west-3", 0.0000511d), - entry("eu-north-1", 0.0000088d), - entry("me-south-1", 0.0005059d), - entry("sa-east-1", 0.0000617d) - ) - ), - // noinspection (explicit type arguments speedup compilation and analysis time) - "gcp", - new Provider( - 1.1d, - Map.ofEntries( - entry("us-central1", 0.00003178d), - entry("us-east1", 0.0003504d), - entry("us-east4", 0.00015162d), - entry("us-west1", 0.0000078d), - entry("us-west2", 0.00011638d), - entry("us-west3", 0.00038376d), - entry("us-west4", 0.00036855d), - entry("asia-east1", 0.0004428d), - entry("asia-east2", 0.000453d), - entry("asia-northeast1", 0.00048752d), - entry("asia-northeast2", 0.00048752d), - entry("asia-northeast3", 0.00031533d), - entry("asia-south1", 0.00063448d), - entry("asia-south2", 0.000657d), - entry("asia-southeast1", 0.00047328d), - entry("asia-southeast2", 0.000647d), - entry("australia-southeast1", 0.00064703d), - entry("australia-southeast2", 0.000691d), - entry("europe-central2", 0.000622d), - entry("europe-north1", 0.00000798d), - entry("europe-west1", 0.00004452d), - entry("europe-west2", 0.00009471d), - entry("europe-west3", 0.000108), - entry("europe-west4", 0.000164d), - entry("europe-west6", 0.000087d), - entry("northamerica-northeast1", 0.000027d), - entry("southamerica-east1", 0.00001236d) - ) - ), - "azure", - new Provider( - 1.185d, - Map.ofEntries( - entry("centralus", 0.000426254d), - entry("eastus", 0.000379069d), - entry("eastus2", 0.000379069d), - entry("eastus3", 0.000379069d), - entry("northcentralus", 0.000410608d), - entry("southcentralus", 0.000373231d), - entry("westcentralusS", 0.000322167d), - entry("westus", 0.000322167d), - entry("westus2", 0.000322167d), - entry("westus3", 0.000322167d), - entry("eastasia", 0.00071d), - entry("southeastasia", 0.000408d), - entry("southafricanorth", 0.0009006d), - entry("southafricawest", 0.0009006d), - entry("southafrica", 0.0009006d), - entry("australia", 0.00079d), - entry("australiacentral", 0.00079d), - entry("australiacentral2", 0.00079d), - entry("australiaeast", 0.00079d), - entry("australiasoutheast", 0.00096d), - entry("japan", 0.0004658d), - entry("japanwest", 0.0004658d), - entry("japaneast", 0.0004658d), - entry("korea", 0.0004156d), - entry("koreaeast", 0.0004156d), - entry("koreasouth", 0.0004156d), - entry("india", 0.0007082d), - entry("indiawest", 0.0007082d), - entry("indiacentral", 0.0007082d), - entry("indiasouth", 0.0007082d), - entry("northeurope", 0.0002786d), - entry("westeurope", 0.0003284d), - entry("france", 0.00005128d), - entry("francecentral", 0.00005128d), - entry("francesouth", 0.00005128d), - entry("swedencentral", 0.00000567d), - entry("switzerland", 0.00000567d), - entry("switzerlandnorth", 0.00000567d), - entry("switzerlandwest", 0.00000567d), - entry("uk", 0.000225d), - entry("uksouth", 0.000225d), - entry("ukwest", 0.000228d), - entry("germany", 0.00033866d), - entry("germanynorth", 0.00033866d), - entry("germanywestcentral", 0.00033866d), - entry("norway", 0.00000762d), - entry("norwayeast", 0.00000762d), - entry("norwaywest", 0.00000762d), - entry("unitedarabemirates", 0.0004041d), - entry("unitedarabemiratesnorth", 0.0004041d), - entry("unitedarabemiratescentral", 0.0004041d), - entry("canada", 0.00012d), - entry("canadacentral", 0.00012d), - entry("canadaeast", 0.00012d), - entry("brazil", 0.0000617d), - entry("brazilsouth", 0.0000617d), - entry("brazilsoutheast", 0.0000617d) - ) - ) - ); + return CloudProviders.getPUEOrDefault(host.instanceType.provider, customDatacenterPUE); } } diff --git a/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CloudProviders.java b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CloudProviders.java new file mode 100644 index 0000000000000..0245df13f8fad --- /dev/null +++ b/x-pack/plugin/profiling/src/main/java/org/elasticsearch/xpack/profiling/CloudProviders.java @@ -0,0 +1,247 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.profiling; + +import java.util.Map; + +import static java.util.Map.entry; + +final class CloudProviders { + private CloudProviders() { + // no instances intended + } + + public record Provider(double pue, Map co2TonsPerKWH) {} + + private static Provider getProvider(String providerName) { + return PROVIDERS.get(providerName); + } + + /** + * Returns the PUE for the given provider, or the default value if the provider is unknown. + * PUE stands for Power Usage Effectiveness, and is a measure of how much power is used by + * the datacenter infrastructure (cooling, lighting, etc.) vs. the IT equipment (servers, etc.). + * A PUE of 1.0 means that all power is used by the IT equipment, and a PUE of 2.0 means that + * half of the power is used by the IT equipment and half is used by the infrastructure. + * See also https://en.wikipedia.org/wiki/Power_usage_effectiveness . + * + * @param providerName The name of the provider. + * Currently supported providers are "aws", "gcp", and "azure". + * If the provider is unknown, the default value is returned. + * @param defaultPUEValue The default value to return if the provider is unknown. + * @return The PUE for the given provider, or the default value if the provider is unknown. + */ + public static double getPUEOrDefault(String providerName, double defaultPUEValue) { + Provider provider = getProvider(providerName); + if (provider == null) { + return defaultPUEValue; + } + return provider.pue; + } + + /** + * Returns the CO2 emission factor for the given provider and region, or the default value if + * the provider or region is unknown. The CO2 emission factor is the amount of CO2 emitted per + * kWh of electricity consumed and measured in metric tons. + * + * @param providerName The name of the provider. + * Currently supported providers are "aws", "gcp", and "azure". + * If the provider is unknown, the default value is returned. + * @param region The name of the region. + * If the region is unknown, the default value is returned. + * @param defaultCO2Value The default value to return if the provider or region is unknown. + * @return The CO2 emission factor for the given provider and region, or the default value if + * the provider or region is unknown. + */ + public static double getCO2TonsPerKWHOrDefault(String providerName, String region, double defaultCO2Value) { + Provider provider = getProvider(providerName); + if (provider == null) { + return defaultCO2Value; + } + return provider.co2TonsPerKWH.getOrDefault(region, defaultCO2Value); + } + + // The following data taken from https://www.cloudcarbonfootprint.org/docs/methodology/ + // and updated from https://github.com/PaoloFrigo/cloud-carbon-footprint . + // License: Apache 2.0 + // Copyright: Cloud Carbon Footprint, (C) 2021 Thoughtworks, Inc. + private static final Map PROVIDERS; + static { + // noinspection (explicit type arguments speedup compilation and analysis time) + PROVIDERS = Map.of( + "aws", + new Provider( + 1.135d, + Map.ofEntries( + entry("us-east-1", 0.000379069d), + entry("us-east-2", 0.000410608d), + entry("us-west-1", 0.000322167d), + entry("us-west-2", 0.000322167d), + entry("us-gov-east-1", 0.000379069d), + entry("us-gov-west-1", 0.000322167d), + entry("af-south-1", 0.0009006d), + entry("ap-east-1", 0.00071d), + entry("ap-south-1", 0.0007082d), + entry("ap-northeast-3", 0.0004658d), + entry("ap-northeast-2", 0.0004156d), + entry("ap-southeast-1", 0.000408d), + entry("ap-southeast-2", 0.00076d), + entry("ap-southeast-3", 0.0007177d), + entry("ap-northeast-1", 0.0004658d), + entry("ca-central-1", 0.00012d), + entry("cn-north-1", 0.0005374d), + entry("cn-northwest-1", 0.0005374d), + entry("eu-central-1", 0.000311d), + entry("eu-west-1", 0.0002786d), + entry("eu-west-2", 0.000225d), + entry("eu-south-1", 0.0002134d), + entry("eu-west-3", 0.0000511d), + entry("eu-north-1", 0.0000088d), + entry("me-south-1", 0.0005059d), + entry("me-central-1", 0.0004041), + entry("sa-east-1", 0.0000617d) + ) + ), + // noinspection (explicit type arguments speedup compilation and analysis time) + "gcp", + new Provider( + 1.1d, + // These emission factors take into account Google Carbon Free Energy percentage in each region. + // Source: https://cloud.google.com/sustainability/region-carbon + Map.ofEntries( + entry("us-central1", 0.0002152373529d), + entry("us-central2", 0.0002152373529d), + entry("us-east1", 0.0003255d), + entry("us-east4", 0.00011124d), + entry("us-east5", 0.00011124d), + entry("us-west1", 0.0000072d), + entry("us-west2", 0.0000893d), + entry("us-west3", 0.00030912d), + entry("us-west4", 0.00028835d), + entry("us-south1", 0.0001776d), + entry("asia-east1", 0.00037848d), + entry("asia-east2", 0.0002592d), + entry("asia-northeast1", 0.00038976d), + entry("asia-northeast2", 0.00026496d), + entry("asia-northeast3", 0.00029325d), + entry("asia-south1", 0.000603d), + entry("asia-south2", 0.00061732d), + entry("asia-southeast1", 0.00035712d), + entry("asia-southeast2", 0.0005046d), + entry("australia-southeast1", 0.00047242d), + entry("australia-southeast2", 0.00035949d), + entry("europe-central2", 0.0004608d), + entry("europe-north1", 0.00001143d), + entry("europe-southwest1", 0.000121d), + entry("europe-west1", 0.0000198d), + entry("europe-west2", 0.00007396d), + entry("europe-west3", 0.0001076), + entry("europe-west4", 0.00013301d), + entry("europe-west6", 0.0000129d), + entry("europe-west8", 0.000298d), + entry("europe-west9", 0.000059d), + entry("northamerica-northeast1", 0d), // Montreal is 100% CFE + entry("northamerica-northeast2", 0.00000232d), + entry("southamerica-east1", 0.00002838d), + entry("southamerica-west1", 0.0000589d) + ) + ), + "azure", + new Provider( + 1.185d, + Map.ofEntries( + entry("centralus", 0.000426254d), + entry("centraluseuap", 0.000426254d), + entry("centralusestage", 0.000426254d), + entry("eastus", 0.000379069d), + entry("useast", 0.000379069d), + entry("eastusstage", 0.000379069d), + entry("eastus2", 0.000379069d), + entry("useast2", 0.000379069d), + entry("eastus2euap", 0.000379069d), + entry("eastus2stage", 0.000379069d), + entry("eastus3", 0.000379069d), + entry("usnorth", 0.000410608d), + entry("northcentralus", 0.000410608d), + entry("northcentralusstage", 0.000410608d), + entry("southcentralus", 0.000373231d), + entry("southcentralusstage", 0.000373231d), + entry("unitedstates", 0.000373231d), + entry("unitedstateseuap", 0.000373231d), + entry("westcentralus", 0.000322167d), + entry("westcentralusstage", 0.000322167d), + entry("westus", 0.000322167d), + entry("westusstage", 0.000322167d), + entry("westus2", 0.000322167d), + entry("westus2stage", 0.000322167d), + entry("westus3", 0.000322167d), + entry("asia", 0.0005647d), + entry("asiapacific", 0.0005647d), + entry("eastasia", 0.00071d), + entry("eastasiastage", 0.00071d), + entry("southeastasia", 0.000408d), + entry("asiasoutheast", 0.000408d), + entry("southafricanorth", 0.0009006d), + entry("southafricawest", 0.0009006d), + entry("southafrica", 0.0009006d), + entry("australia", 0.00079d), + entry("australiacentral", 0.00079d), + entry("australiacentral2", 0.00079d), + entry("australiaeast", 0.00079d), + entry("australiasoutheast", 0.00096d), + entry("apeast", 0.00071d), + entry("apsoutheast", 0.000408d), + entry("japan", 0.0004658d), + entry("japanwest", 0.0004658d), + entry("japaneast", 0.0004658d), + entry("korea", 0.0004156d), + entry("koreaeast", 0.0004156d), + entry("koreasouth", 0.0004156d), + entry("india", 0.0007082d), + entry("indiacentral", 0.0007082d), + entry("centralindia", 0.0007082d), + entry("jioindiacentral", 0.0007082d), + entry("indiawest", 0.0007082d), + entry("westindia", 0.0007082d), + entry("jioindiawest", 0.0007082d), + entry("indiasouth", 0.0007082d), + entry("southindia", 0.0007082d), + entry("northeurope", 0.0002786d), + entry("europenorth", 0.0002786d), + entry("westeurope", 0.0003284d), + entry("europewest", 0.0003284d), + entry("france", 0.00005128d), + entry("francecentral", 0.00005128d), + entry("francesouth", 0.00005128d), + entry("swedencentral", 0.00000567d), + entry("switzerland", 0.00001152d), + entry("switzerlandnorth", 0.00001152d), + entry("switzerlandwest", 0.00001152d), + entry("uk", 0.000225d), + entry("uksouth", 0.000225d), + entry("ukwest", 0.000228d), + entry("germany", 0.00033866d), + entry("germanynorth", 0.00033866d), + entry("germanywestcentral", 0.00033866d), + entry("norway", 0.00000762d), + entry("norwayeast", 0.00000762d), + entry("norwaywest", 0.00000762d), + entry("uae", 0.0004041d), + entry("uaenorth", 0.0004041d), + entry("uaecentral", 0.0004041d), + entry("canada", 0.00012d), + entry("canadacentral", 0.00012d), + entry("canadaeast", 0.00012d), + entry("brazil", 0.0000617d), + entry("brazilsouth", 0.0000617d), + entry("brazilsoutheast", 0.0000617d) + ) + ) + ); + } +} diff --git a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/CO2CalculatorTests.java b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/CO2CalculatorTests.java index eb0a2f056044b..96c56daef7d95 100644 --- a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/CO2CalculatorTests.java +++ b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/CO2CalculatorTests.java @@ -73,7 +73,7 @@ public void testCreateFromRegularSource() { CO2Calculator co2Calculator = new CO2Calculator(hostsTable, samplingDurationInSeconds, null, null, null, null); checkCO2Calculation(co2Calculator.getAnnualCO2Tons(HOST_ID_A, samples), annualCoreHours, 1.135d, 0.0002786d, 7.0d); - checkCO2Calculation(co2Calculator.getAnnualCO2Tons(HOST_ID_B, samples), annualCoreHours, 1.1d, 0.00004452d, 7.0d); + checkCO2Calculation(co2Calculator.getAnnualCO2Tons(HOST_ID_B, samples), annualCoreHours, 1.1d, 0.0000198d, 7.0d); checkCO2Calculation(co2Calculator.getAnnualCO2Tons(HOST_ID_C, samples), annualCoreHours, 1.185d, 0.000410608d, 2.8d); checkCO2Calculation(co2Calculator.getAnnualCO2Tons(HOST_ID_D, samples), annualCoreHours, 1.7d, 0.000379069d, 2.8d); }