Add last_updated_timestamp for observers#522
Add last_updated_timestamp for observers#522toumorokoshi merged 16 commits intoopen-telemetry:masterfrom
Conversation
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
I wondering if we are handling timestamps correctly. According of the specification, we should only capture the timestamps once per collection interval instead of each event: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-metrics.md#time
Am I missing something?
...opentelemetry-ext-otcollector/src/opentelemetry/ext/otcollector/metrics_exporter/__init__.py
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
|
@mauriciovasquezbernal |
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
I'm approving now. Just two minor nits. I think we should keep an eye on the fact that we are capturing the timestamps on every event.
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
LGTM, thanks for addressing all the comments.
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/metrics/export/aggregate.py
Outdated
Show resolved
Hide resolved
| def merge(self, other): | ||
| with self._lock: | ||
| self.checkpoint += other.checkpoint | ||
| if self.last_update_timestamp is None: |
There was a problem hiding this comment.
I feel like when this code shows up three times, it might be good to refactor it into a common utility method. All the timestamp comparisons seem to be doing the same logic.
There was a problem hiding this comment.
I agree with taking out repetitive code. Would passing an aggregator into a utility method look weird? The observer aggregator also modifies last, so it is not exactly the same; type checking would be needed. Is that logic worth it to simply reduce some duplicate code?
There was a problem hiding this comment.
I was considered passing in two Optional[DateTime] objects, and doing the none check there
you could pass the object in itself, but I agree that feels weird
There was a problem hiding this comment.
I made a change that factors out the checking logic and assigns the values as well.
Fixes [#510]
Refactors
last_updated_timestampinto aggregators instead of bound metric instrument.