Skip to content

feat(metrics): Support for external observability providers - Metrics #2343

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix static checking error
  • Loading branch information
roger-zhangg committed May 30, 2023
commit 06c9c8e27860d41a72609114b46e90b9e86a3f61
2 changes: 2 additions & 0 deletions aws_lambda_powertools/metrics/provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

logger = logging.getLogger(__name__)

is_cold_start = True


class MetricsProviderBase(ABC):
"""Class for metric provider template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Check if using layer
try:
from datadog import lambda_metric
from datadog_lambda.metric import lambda_metric
except ImportError:
lambda_metric = None

Expand All @@ -28,7 +28,7 @@ def __init__(self, namespace):
super().__init__()

# adding timestamp, tags. unit, resolution, name will not be used
def add_metric(self, name, value, timestamp, tag: List = None):
def add_metric(self, name: str, value: float, timestamp: float, tag: List):
if not isinstance(value, numbers.Real):
raise MetricValueError(f"{value} is not a valid number")
if not timestamp:
Expand All @@ -38,8 +38,8 @@ def add_metric(self, name, value, timestamp, tag: List = None):
# serialize for flushing
def serialize(self) -> Dict:
# logic here is to add dimension and metadata to each metric's tag with "key:value" format
extra_tags = []
output_list = []
extra_tags: List = []
output_list: List = []

for single_metric in self.metrics:
output_list.append(
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(self, provider):
self.provider = provider
super().__init__()

def add_metric(self, name: str, value: float, timestamp: time, tags: List = None):
def add_metric(self, name: str, value: float, timestamp: float, tags: List):
self.provider.add_metric(name, value, timestamp, tags)

def flush_metrics(self, raise_on_empty_metrics: bool = False) -> None:
Expand Down