-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BFD-2835: CCW RIF Pipeline SLO Alarms are failing to evaluate when SL…
…Os are violated (#1906)
- Loading branch information
Showing
11 changed files
with
464 additions
and
111 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
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
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
55 changes: 55 additions & 0 deletions
55
ops/terraform/services/pipeline/modules/bfd_pipeline_slis/lambda_src/common.py
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,55 @@ | ||
import os | ||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
METRICS_NAMESPACE = os.environ.get("METRICS_NAMESPACE", "") | ||
|
||
|
||
@dataclass | ||
class PipelineMetricMetadata: | ||
"""Encapsulates metadata about a given pipeline metric""" | ||
|
||
metric_name: str | ||
"""The name of the metric in CloudWatch Metrics, excluding namespace""" | ||
unit: str | ||
"""The unit of the metric. Must conform to the list of supported CloudWatch Metrics""" | ||
|
||
def __hash__(self) -> int: | ||
return hash(self.metric_name) | ||
|
||
|
||
class PipelineMetric(PipelineMetricMetadata, Enum): | ||
"""Enumeration of pipeline metrics that can be stored in CloudWatch Metrics""" | ||
|
||
TIME_DATA_AVAILABLE = PipelineMetricMetadata("time/data-available", "Seconds") | ||
TIME_DATA_FIRST_AVAILABLE = PipelineMetricMetadata("time/data-first-available", "Seconds") | ||
TIME_DATA_LOADED = PipelineMetricMetadata("time/data-loaded", "Seconds") | ||
TIME_DATA_FULLY_LOADED = PipelineMetricMetadata("time/data-fully-loaded", "Seconds") | ||
TIME_DELTA_DATA_LOAD_TIME = PipelineMetricMetadata("time-delta/data-load-time", "Seconds") | ||
TIME_DELTA_FULL_DATA_LOAD_TIME = PipelineMetricMetadata( | ||
"time-delta/data-full-load-time", "Seconds" | ||
) | ||
TIME_DATA_FIRST_AVAILABLE_REPEATING = PipelineMetricMetadata( | ||
"time/data-first-available-repeating", "Seconds" | ||
) | ||
TIME_DATA_FULLY_LOADED_REPEATING = PipelineMetricMetadata( | ||
"time/data-fully-loaded-repeating", "Seconds" | ||
) | ||
|
||
def __init__(self, data: PipelineMetricMetadata): | ||
for key in data.__annotations__.keys(): | ||
value = getattr(data, key) | ||
setattr(self, key, value) | ||
|
||
def __hash__(self) -> int: | ||
return hash(self.value) | ||
|
||
def full_name(self) -> str: | ||
"""Returns the fully qualified name of the metric, which includes the metric namespace and | ||
metric name | ||
Returns: | ||
str: The "full name" of the metric | ||
""" | ||
metric_metadata: PipelineMetricMetadata = self.value | ||
return f"{METRICS_NAMESPACE}/{metric_metadata.metric_name}" |
Oops, something went wrong.