-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add last_updated_timestamp for observers #522
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing all the comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my only comment is around the DRY of the code, but the content looks good!
If the time comparison code can be converted to a utility method, that would be great.
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
@@ -62,6 +66,11 @@ def take_checkpoint(self): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a change that factors out the checking logic and assigns the values as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks! If you can fix the build, I think we're good to go!
Fixes [#510]
Refactors
last_updated_timestamp
into aggregators instead of bound metric instrument.