forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MetricsRegistry as an interface (airbytehq#12487)
Make MetricsRegistry as an interface
- Loading branch information
1 parent
f18f046
commit 341ef12
Showing
7 changed files
with
159 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
airbyte-metrics/lib/src/main/java/io/airbyte/metrics/lib/OssMetricsRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.metrics.lib; | ||
|
||
import com.google.api.client.util.Preconditions; | ||
|
||
/** | ||
* Enum source of truth of all Airbyte metrics. Each enum value represent a metric and is linked to | ||
* an application and contains a description to make it easier to understand. | ||
* | ||
* Each object of the enum actually represent a metric, so the Registry name is misleading. The | ||
* reason 'Registry' is in the name is to emphasize this enum's purpose as a source of truth for all | ||
* metrics. This also helps code readability i.e. AirbyteMetricsRegistry.metricA. | ||
* | ||
* Metric Name Convention (adapted from | ||
* https://docs.datadoghq.com/developers/guide/what-best-practices-are-recommended-for-naming-metrics-and-tags/): | ||
* <p> | ||
* - Use lowercase. Metric names are case sensitive. | ||
* <p> | ||
* - Use underscore to delimit names with multiple words. | ||
* <p> | ||
* - No spaces. This makes the metric confusing to read. | ||
* <p> | ||
* - Avoid numbers. This makes the metric confusing to read. Numbers should only be used as a | ||
* <p> | ||
* - Add units at name end if applicable. This is especially relevant for time units. | ||
* <p> | ||
* - Include the time period in the name if the metric is meant to be run at a certain interval. | ||
*/ | ||
public enum OssMetricsRegistry implements MetricsRegistry { | ||
|
||
ATTEMPT_CREATED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"attempt_created_by_release_stage", | ||
"increments when a new attempt is created. attempts are double counted as this is tagged by release stage."), | ||
ATTEMPT_FAILED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"attempt_failed_by_release_stage", | ||
"increments when an attempt fails. attempts are double counted as this is tagged by release stage."), | ||
ATTEMPT_FAILED_BY_FAILURE_ORIGIN( | ||
MetricEmittingApps.WORKER, | ||
"attempt_failed_by_failure_origin", | ||
"increments for every failure origin a failed attempt has. since a failure can have multiple origins, a single failure can be counted more than once. tagged by failure origin."), | ||
ATTEMPT_SUCCEEDED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"attempt_succeeded_by_release_stage", | ||
"increments when an attempts succeeds. attempts are double counted as this is tagged by release stage."), | ||
EST_NUM_METRICS_EMITTED_BY_REPORTER( | ||
MetricEmittingApps.METRICS_REPORTER, | ||
"est_num_metrics_emitted_by_reporter", | ||
"estimated metrics emitted by the reporter in the last interval. this is estimated since the count is not precise."), | ||
JOB_CANCELLED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"job_cancelled_by_release_stage", | ||
"increments when a job is cancelled. jobs are double counted as this is tagged by release stage."), | ||
JOB_CREATED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"job_created_by_release_stage", | ||
"increments when a new job is created. jobs are double counted as this is tagged by release stage."), | ||
JOB_FAILED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"job_failed_by_release_stage", | ||
"increments when a job fails. jobs are double counted as this is tagged by release stage."), | ||
JOB_SUCCEEDED_BY_RELEASE_STAGE( | ||
MetricEmittingApps.WORKER, | ||
"job_succeeded_by_release_stage", | ||
"increments when a job succeeds. jobs are double counted as this is tagged by release stage."), | ||
KUBE_POD_PROCESS_CREATE_TIME_MILLISECS( | ||
MetricEmittingApps.WORKER, | ||
"kube_pod_process_create_time_millisecs", | ||
"time taken to create a new kube pod process"), | ||
NUM_PENDING_JOBS( | ||
MetricEmittingApps.METRICS_REPORTER, | ||
"num_pending_jobs", | ||
"number of pending jobs"), | ||
NUM_RUNNING_JOBS( | ||
MetricEmittingApps.METRICS_REPORTER, | ||
"num_running_jobs", | ||
"number of running jobs"), | ||
NUM_ACTIVE_CONN_PER_WORKSPACE( | ||
MetricEmittingApps.METRICS_REPORTER, | ||
"num_active_conn_per_workspace", | ||
"number of active connections per workspace"), | ||
OLDEST_PENDING_JOB_AGE_SECS(MetricEmittingApps.METRICS_REPORTER, | ||
"oldest_pending_job_age_secs", | ||
"oldest pending job in seconds"), | ||
OLDEST_RUNNING_JOB_AGE_SECS(MetricEmittingApps.METRICS_REPORTER, | ||
"oldest_running_job_age_secs", | ||
"oldest running job in seconds"), | ||
OVERALL_JOB_RUNTIME_IN_LAST_HOUR_BY_TERMINAL_STATE_SECS(MetricEmittingApps.METRICS_REPORTER, | ||
"overall_job_runtime_in_last_hour_by_terminal_state_secs", | ||
"overall job runtime - scheduling and execution for all attempts - for jobs that reach terminal states in the last hour. tagged by terminal states."); | ||
|
||
private final MetricEmittingApp application; | ||
private final String metricName; | ||
private final String metricDescription; | ||
|
||
OssMetricsRegistry(final MetricEmittingApp application, final String metricName, final String metricDescription) { | ||
Preconditions.checkNotNull(metricDescription); | ||
Preconditions.checkNotNull(application); | ||
|
||
this.application = application; | ||
this.metricName = metricName; | ||
this.metricDescription = metricDescription; | ||
} | ||
|
||
@Override | ||
public MetricEmittingApp getApplication() { | ||
return application; | ||
} | ||
|
||
@Override | ||
public String getMetricName() { | ||
return metricName; | ||
} | ||
|
||
@Override | ||
public String getMetricDescription() { | ||
return metricDescription; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.