Skip to content

Commit

Permalink
Add timestamp for last value
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Oct 27, 2021
1 parent a4887e4 commit d65159b
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
AGGREGATION_TEMPORALITY_CUMULATIVE,
AGGREGATION_TEMPORALITY_DELTA,
)
from opentelemetry.util._time import _time_ns


class Aggregation(ABC):
Expand Down Expand Up @@ -77,8 +78,13 @@ class LastValueAggregation(Aggregation):
This aggregation collects data for the SDK sum metric point.
"""

def __init__(self):
super().__init__()
self._timestamp = _time_ns()

def aggregate(self, value):
self._value = value
self._timestamp = _time_ns()

def collect(self):
return self._value
Expand Down

0 comments on commit d65159b

Please sign in to comment.