Skip to content

Commit 19c9cf7

Browse files
committed
Add timestamp for last value
1 parent feeb863 commit 19c9cf7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/metrics/aggregation.py

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
AGGREGATION_TEMPORALITY_CUMULATIVE,
2121
AGGREGATION_TEMPORALITY_DELTA,
2222
)
23+
from opentelemetry.util._time import _time_ns
2324

2425

2526
class Aggregation(ABC):
@@ -77,8 +78,13 @@ class LastValueAggregation(Aggregation):
7778
This aggregation collects data for the SDK sum metric point.
7879
"""
7980

81+
def __init__(self):
82+
super().__init__()
83+
self._timestamp = _time_ns()
84+
8085
def aggregate(self, value):
8186
self._value = value
87+
self._timestamp = _time_ns()
8288

8389
def collect(self):
8490
return self._value

0 commit comments

Comments
 (0)