-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Make MetricsRegistry as an interface #12487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
18f3cf2
make DogStats member protected
xiaohansong ae69e57
make metrics registry as interface so cloud server could extend from it
xiaohansong 4ae36b1
fix dependency renaming issues, and renaming OssMetricsRegistry
xiaohansong 0f8c00e
fix dependency renaming issues, and renaming OssMetricsRegistry
xiaohansong f6e6995
more dependency fix
xiaohansong 62867fe
Merge branch 'master' into xiaohan/dog2
xiaohansong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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/MetricsRegistries.java
This file contains hidden or 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 MetricsRegistries 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; | ||
|
||
MetricsRegistries(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 | ||
MetricEmittingApp getApplication() { | ||
return application; | ||
} | ||
|
||
@Override | ||
String getMetricName() { | ||
return metricName; | ||
} | ||
|
||
@Override | ||
String getMetricDescription() { | ||
return metricDescription; | ||
} | ||
|
||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Instead of
MetricsRegistries
as the enum name, what aboutMetricsRegistryEnum
orMetricsRegistryImpl
? The plural "registries" feels slightly off to meThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
PublicMetricRegistry
orOssMetricRegistry
? The practice of adding the java type to the name is a throwback to when IDEs didn't provide introspection. I generally feel its superfluous and make it more difficult to read.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good - I was following MetricEmittingApp & MetricEmittingApps pattern. I think the Oss one makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. i suppose that pattern is less logical here since it suggests we have multiple registries. appreciate trying to keep the consistency!