2
2
import json
3
3
import logging
4
4
import warnings
5
- from typing import Any , Callable , Dict , Optional , Union , cast
5
+ from typing import Any , Callable , Dict , Optional , Union
6
6
7
- from ..shared .types import AnyCallableT
8
7
from .base import MetricManager , MetricUnit
9
8
from .metric import single_metric
10
9
@@ -130,7 +129,7 @@ def log_metrics(
130
129
capture_cold_start_metric : bool = False ,
131
130
raise_on_empty_metrics : bool = False ,
132
131
default_dimensions : Optional [Dict [str , str ]] = None ,
133
- ) -> AnyCallableT :
132
+ ):
134
133
"""Decorator to serialize and publish metrics at the end of a function execution.
135
134
136
135
Be aware that the log_metrics **does call* the decorated function (e.g. lambda_handler).
@@ -170,14 +169,11 @@ def handler(event, context):
170
169
# Return a partial function with args filled
171
170
if lambda_handler is None :
172
171
logger .debug ("Decorator called with parameters" )
173
- return cast (
174
- AnyCallableT ,
175
- functools .partial (
176
- self .log_metrics ,
177
- capture_cold_start_metric = capture_cold_start_metric ,
178
- raise_on_empty_metrics = raise_on_empty_metrics ,
179
- default_dimensions = default_dimensions ,
180
- ),
172
+ return functools .partial (
173
+ self .log_metrics ,
174
+ capture_cold_start_metric = capture_cold_start_metric ,
175
+ raise_on_empty_metrics = raise_on_empty_metrics ,
176
+ default_dimensions = default_dimensions ,
181
177
)
182
178
183
179
@functools .wraps (lambda_handler )
@@ -198,7 +194,7 @@ def decorate(event, context):
198
194
199
195
return response
200
196
201
- return cast ( AnyCallableT , decorate )
197
+ return decorate
202
198
203
199
def __add_cold_start_metric (self , context : Any ) -> None :
204
200
"""Add cold start metric and function_name dimension
0 commit comments