Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: msvinaykumar <[email protected]>
  • Loading branch information
msvinaykumar committed Jun 27, 2024
1 parent 232dfe3 commit 344e3c8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 51 deletions.
106 changes: 58 additions & 48 deletions src/main/java/com/autotune/utils/KruizeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
* limitations under the License.
*******************************************************************************/


package com.autotune.utils;

import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;

/**
* Constants for Autotune module
*/
Expand All @@ -29,6 +34,21 @@ public class KruizeConstants {
private KruizeConstants() {
}

public static enum KRUIZE_RECOMMENDATION_API_VERSION {
V1_0("1.0"),
LATEST("1.0");
private final String versionNumber;

KRUIZE_RECOMMENDATION_API_VERSION(String versionNumber) {
this.versionNumber = versionNumber;
}

public String getVersionNumber() {
return versionNumber;
}

}

public static class APIMessages {
public static final String MAX_DAY = "maxDay : %s";
public static final String SUCCESS = "success";
Expand All @@ -46,23 +66,6 @@ public static class APIMessages {
public static final String UPDATE_RECOMMENDATIONS_FAILURE_MSG = "UpdateRecommendations API failed for experiment_name: %s and intervalEndTimeStr : %s due to %s";
}


public static enum KRUIZE_RECOMMENDATION_API_VERSION {
V1_0("1.0"),
LATEST("1.0");
private final String versionNumber;

KRUIZE_RECOMMENDATION_API_VERSION(String versionNumber) {
this.versionNumber = versionNumber;
}

public String getVersionNumber() {
return versionNumber;
}

}


/**
* Holds the constants of env vars and values to start Autotune in different Modes
*/
Expand Down Expand Up @@ -275,11 +278,11 @@ public static final class TimeUnitsExt {
public static final String HOUR_SINGLE_LC = "h";
public static final String HOUR_SINGLE_UC = HOUR_SINGLE_LC.toUpperCase();

public static final class TimeZones {
public static final String UTC = "UTC";
private TimeUnitsExt() {
}

private TimeUnitsExt() {
public static final class TimeZones {
public static final String UTC = "UTC";
}
}

Expand Down Expand Up @@ -374,22 +377,25 @@ public static class DataSourceConstants {
public static final String PROMETHEUS_DEFAULT_SERVICE_PORT = "9090";
public static final String PROMETHEUS_REACHABILITY_QUERY = "up";
public static final String DATASOURCE_ENDPOINT_WITH_QUERY = "%s/api/v1/query_range?query=%s&start=%s&end=%s&step=%s";
public static final String DATE_ENDPOINT_WITH_QUERY = "%s/api/v1/query?query=%s";
public static final String DATE_ENDPOINT_WITH_QUERY = "%s/api/v1/query?query=%s";

public static class DataSourceDetailsInfoConstants {
private DataSourceDetailsInfoConstants() {
}
private DataSourceConstants() {
}

public static class DataSourceDetailsInfoConstants {
public static final String version = "v1.0";
public static final String CLUSTER_NAME = "default";
private DataSourceDetailsInfoConstants() {
}
}

public static class DataSourceInfoMsgs {
public static final String ADDING_DATASOURCE = "Trying to add the datasource to collection: ";
public static final String VERIFYING_DATASOURCE_REACHABILITY = "Verifying datasource reachability status: ";
public static final String CHECKING_AVAILABLE_DATASOURCE = "Checking available datasources:";
public static final String CHECKING_AVAILABLE_DATASOURCE_FROM_DB = "Checking available datasources from database:";
public static final String NO_DATASOURCE_FOUND_IN_DB = "No datasource found in database.";
public static final String CHECKING_AVAILABLE_DATASOURCE_FROM_DB = "Checking available datasources from database:";
public static final String NO_DATASOURCE_FOUND_IN_DB = "No datasource found in database.";

private DataSourceInfoMsgs() {
}
}
Expand All @@ -398,14 +404,12 @@ public static class DataSourceSuccessMsgs {
public static final String DATASOURCE_ADDED = "Datasource added to the collection successfully.";
public static final String DATASOURCE_FOUND = "Datasource found: ";
public static final String DATASOURCE_SERVICEABLE = "Datasource is serviceable.";

private DataSourceSuccessMsgs() {
}
}

public static class DataSourceErrorMsgs {
private DataSourceErrorMsgs() {
}

public static final String MISSING_DATASOURCE_NAME = "Datasource name cannot be empty.";
public static final String MISSING_DATASOURCE_PROVIDER = "Datasource provider cannot be empty.";
public static final String MISSING_DATASOURCE_NAMESPACE = "Datasource namespace cannot be empty.";
Expand All @@ -421,53 +425,47 @@ private DataSourceErrorMsgs() {
public static final String SERVICE_NOT_FOUND = "Can not find service with specified name.";
public static final String ENDPOINT_NOT_FOUND = "Service endpoint not found.";
public static final String MISSING_DATASOURCE_INFO = "Datasource is missing, add a valid Datasource";
private DataSourceErrorMsgs() {
}
}

public static class DataSourceQueryJSONKeys {
private DataSourceQueryJSONKeys() {
}

public static final String STATUS = "status";
public static final String DATA = "data";
public static final String RESULT = "result";
public static final String METRIC = "metric";
public static final String VALUE = "value";
public static final String VALUES = "values";
private DataSourceQueryJSONKeys() {
}

}

public static class DataSourceQueryStatus {
private DataSourceQueryStatus() {
}

public static final String SUCCESS = "success";
public static final String ERROR = "error";
}
private DataSourceConstants() {
private DataSourceQueryStatus() {
}
}

public static class DataSourceQueryMetricKeys {
private DataSourceQueryMetricKeys() {
}

public static final String NAMESPACE = "namespace";
public static final String WORKLOAD = "workload";
public static final String WORKLOAD_TYPE = "workload_type";
public static final String CONTAINER_NAME = "container";
public static final String CONTAINER_IMAGE_NAME = "image";
private DataSourceQueryMetricKeys() {
}
}

public static class DataSourceMetadataInfoConstants {
private DataSourceMetadataInfoConstants() {
}

public static final String version = "v1.0";
public static final String CLUSTER_NAME = "default";
private DataSourceMetadataInfoConstants() {
}
}

public static class DataSourceMetadataErrorMsgs {
private DataSourceMetadataErrorMsgs() {
}
public static final String MISSING_DATASOURCE_METADATA_DATASOURCE_NAME = "DataSourceMetadata Datasource name cannot be empty";
public static final String MISSING_DATASOURCE_METADATA_WORKLOAD_MAP = "DataSourceMetadata Workload data cannot be empty or null";
public static final String MISSING_DATASOURCE_METADATA_CONTAINER_MAP = "DataSourceMetadata Container data cannot be empty or null";
Expand Down Expand Up @@ -499,11 +497,11 @@ private DataSourceMetadataErrorMsgs() {
public static final String DATASOURCE_METADATA_VALIDATION_FAILURE_MSG = "Validation of imported metadata failed, mandatory fields missing: %s";
public static final String NAMESPACE_QUERY_VALIDATION_FAILED = "Validation failed for namespace data query.";
public static final String DATASOURCE_OPERATOR_RETRIEVAL_FAILURE = "Failed to retrieve data source operator for provider: %s";
private DataSourceMetadataErrorMsgs() {
}
}

public static class DataSourceMetadataInfoJSONKeys {
private DataSourceMetadataInfoJSONKeys() {
}
public static final String DATASOURCES = "datasources";
public static final String DATASOURCE_NAME = "datasource_name";
public static final String CLUSTERS = "clusters";
Expand All @@ -516,10 +514,13 @@ private DataSourceMetadataInfoJSONKeys() {
public static final String CONTAINERS = "containers";
public static final String CONTAINER_NAME = "container_name";
public static final String CONTAINER_IMAGE_NAME = "container_image_name";
private DataSourceMetadataInfoJSONKeys() {
}
}

public static class DataSourceMetadataInfoSuccessMsgs {
public static final String DATASOURCE_METADATA_DELETED = "Datasource metadata deleted successfully.";

private DataSourceMetadataInfoSuccessMsgs() {
}
}
Expand Down Expand Up @@ -574,9 +575,10 @@ public static final class DateFormats {
public static final String DB_EXTRACTION_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
public static final long MILLI_SECONDS_FOR_DAY = 24 * 60 * 60 * 1000;
public static final long MINUTES_FOR_DAY = 24 * 60;
public static SimpleDateFormat simpleDateFormatForUTC = new SimpleDateFormat(KruizeConstants.DateFormats.STANDARD_JSON_DATE_FORMAT, Locale.ROOT);

private DateFormats() {

simpleDateFormatForUTC.setTimeZone(TimeZone.getTimeZone(KruizeConstants.TimeUnitsExt.TimeZones.UTC));
}
}

Expand Down Expand Up @@ -627,6 +629,7 @@ public static final class KRUIZE_CONFIG_ENV_NAME {
public static final String SETTINGS_HIBERNATE_SHOW_SQL = "hibernate_showsql";
public static final String SETTINGS_HIBERNATE_TIME_ZONE = "hibernate_timezone";
public static final String PLOTS = "plots";
public static final String log_recommendation_metrics_level = "log_recommendation_metrics_level";
public static final String CLOUDWATCH_LOGS_ACCESS_KEY_ID = "logging_cloudwatch_accessKeyId";
public static final String CLOUDWATCH_LOGS_SECRET_ACCESS_KEY = "logging_cloudwatch_secretAccessKey";
public static final String CLOUDWATCH_LOGS_LOG_GROUP = "logging_cloudwatch_logGroup";
Expand Down Expand Up @@ -691,4 +694,11 @@ private RecommendationDurationRanges() {
public static final class KRUIZE_CONFIG_DEFAULT_VALUE {
public static final int DELETE_PARTITION_THRESHOLD_IN_DAYS = 16;
}

public static final class KRUIZE_RECOMMENDATION_METRICS {
public static final String METRIC_NAME = "KruizeRecommendationsNotification";
public static final String TAG_NAME = "experiment_details";
public static final String notification_format = "%s|%s|%s|%s|%s|%s|%s|%s|%s"; //experiment_name,container_name,endtime,level,termname,modelname,code,type,message

}
}
10 changes: 7 additions & 3 deletions src/main/java/com/autotune/utils/MetricsConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.autotune.utils;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
Expand All @@ -10,19 +11,21 @@
import io.micrometer.prometheus.PrometheusMeterRegistry;

public class MetricsConfig {

public static Timer timerListRec, timerListExp, timerCreateExp, timerUpdateResults, timerUpdateRecomendations;
public static Timer timerLoadRecExpName, timerLoadResultsExpName, timerLoadExpName, timerLoadRecExpNameDate, timerBoxPlots;
public static Timer timerLoadAllRec, timerLoadAllExp, timerLoadAllResults;
public static Timer timerAddRecDB, timerAddResultsDB, timerAddExpDB, timerAddBulkResultsDB;
public static Timer timerAddPerfProfileDB, timerLoadPerfProfileName, timerLoadAllPerfProfiles;
public static Counter timerKruizeNotifications;
public static Timer.Builder timerBListRec, timerBListExp, timerBCreateExp, timerBUpdateResults, timerBUpdateRecommendations;
public static Timer.Builder timerBLoadRecExpName, timerBLoadResultsExpName, timerBLoadExpName, timerBLoadRecExpNameDate, timerBBoxPlots;
public static Timer.Builder timerBLoadAllRec, timerBLoadAllExp, timerBLoadAllResults;
public static Timer.Builder timerBAddRecDB, timerBAddResultsDB, timerBAddExpDB, timerBAddBulkResultsDB;
public static Timer.Builder timerBAddPerfProfileDB, timerBLoadPerfProfileName, timerBLoadAllPerfProfiles;
public static Counter.Builder timerBKruizeNotifications;
public static PrometheusMeterRegistry meterRegistry;
public static Timer timerListDS, timerImportDSMetadata,timerListDSMetadata;
public static Timer timerListDS, timerImportDSMetadata, timerListDSMetadata;
public static Timer.Builder timerBListDS, timerBImportDSMetadata, timerBListDSMetadata;
private static MetricsConfig INSTANCE;
public String API_METRIC_DESC = "Time taken for Kruize APIs";
Expand Down Expand Up @@ -58,6 +61,7 @@ private MetricsConfig() {
timerBListDS = Timer.builder("kruizeAPI").description(API_METRIC_DESC).tag("api", "datasources").tag("method", "GET");
timerBImportDSMetadata = Timer.builder("kruizeAPI").description(API_METRIC_DESC).tag("api", "dsmetadata").tag("method", "POST");
timerBListDSMetadata = Timer.builder("kruizeAPI").description(API_METRIC_DESC).tag("api", "dsmetadata").tag("method", "GET");
timerBKruizeNotifications = Counter.builder("KruizeNotifications").description("Kruize notifications").tag("api", "updateRecommendations");
new ClassLoaderMetrics().bindTo(meterRegistry);
new ProcessorMetrics().bindTo(meterRegistry);
new JvmGcMetrics().bindTo(meterRegistry);
Expand All @@ -77,4 +81,4 @@ public static PrometheusMeterRegistry meterRegistry() {
return meterRegistry;
}

}
}

0 comments on commit 344e3c8

Please sign in to comment.