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 Nov 2, 2021
1 parent 97bc54a commit 7db8e99
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 7db8e99

Please sign in to comment.