1 /* 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package software.amazon.awssdk.metrics; 17 18 import software.amazon.awssdk.annotations.SdkPublicApi; 19 20 /** 21 * A enum class representing the different types of metric categories in the SDK. 22 * <p> 23 * A metric can be tagged with multiple categories. Clients can enable/disable metric collection 24 * at a {@link MetricCategory} level. 25 */ 26 @SdkPublicApi 27 public enum MetricCategory { 28 /** 29 * Metrics collected by the core SDK are classified under this category. 30 */ 31 CORE("Core"), 32 33 /** 34 * Metrics collected at the http client level are classified under this category. 35 */ 36 HTTP_CLIENT("HttpClient"), 37 38 /** 39 * Metrics specified by the customer should be classified under this category. 40 */ 41 CUSTOM("Custom"), 42 43 /** 44 * This is an umbrella category (provided for convenience) that records metrics belonging to every category 45 * defined in this enum. Clients who wish to collect lot of SDK metrics data should use this. 46 * <p> 47 * Note: Enabling this option along with {@link MetricLevel#TRACE} is verbose and can be expensive based on the platform 48 * the metrics are uploaded to. Please make sure you need all this data before using this category. 49 */ 50 ALL("All"); 51 52 private final String value; 53 MetricCategory(String value)54 MetricCategory(String value) { 55 this.value = value; 56 } 57 getValue()58 public String getValue() { 59 return value; 60 } 61 62 /** 63 * Create a {@link MetricCategory} from the given String value. This method is case insensitive. 64 * 65 * @param value the value to create the {@link MetricCategory} from 66 * @return A {@link MetricCategory} if the given {@link #value} matches one of the enum values. 67 * Otherwise throws {@link IllegalArgumentException} 68 */ fromString(String value)69 public static MetricCategory fromString(String value) { 70 for (MetricCategory mc : MetricCategory.values()) { 71 if (mc.value.equalsIgnoreCase(value)) { 72 return mc; 73 } 74 } 75 76 throw new IllegalArgumentException("MetricCategory cannot be created from value: " + value); 77 } 78 } 79