Skip to content
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

Merged
merged 16 commits into from
Apr 2, 2020

Conversation

lzchen
Copy link
Contributor

@lzchen lzchen commented Mar 23, 2020

Fixes [#510]

Refactors last_updated_timestamp into aggregators instead of bound metric instrument.

@lzchen lzchen requested a review from a team March 23, 2020 17:01
@lzchen lzchen added needs reviewers PRs with this label are ready for review and needs people to review to move forward. metrics labels Mar 23, 2020
Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a 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?

@lzchen
Copy link
Contributor Author

lzchen commented Mar 24, 2020

@mauriciovasquezbernal
Thanks for reviewing! I added a comment to the otep which asks about this concern. It seems there are some cases (Azure specifically) that we require the actual timestamp of the event, rather than jus the collection time.

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a 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.

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a 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.

Copy link
Member

@toumorokoshi toumorokoshi left a 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.

@@ -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:
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

@toumorokoshi toumorokoshi left a 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!

@toumorokoshi toumorokoshi merged commit 83e89d1 into open-telemetry:master Apr 2, 2020
@lzchen lzchen deleted the obs branch April 2, 2020 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
metrics needs reviewers PRs with this label are ready for review and needs people to review to move forward.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants