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

Timestamp support for const metrics #129

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lstrojny
Copy link

@lstrojny lstrojny commented Jan 19, 2023

@mxinden could you have a look if this is roughly what you had in mind?

Addresses #126

Signed-off-by: Lars Strojny <lars@strojny.net>
Signed-off-by: Lars Strojny <lars@strojny.net>
Signed-off-by: Lars Strojny <lars@strojny.net>
@lstrojny
Copy link
Author

@mxinden any thoughts?

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry for the late review here.

The direction looks good to me. Great job working through the many layers.

Can you add the protobuf implementation. Also would you mind adding a changelog entry?

Comment on lines +347 to +350
if let Ok(time) = timestamp.duration_since(UNIX_EPOCH) {
self.writer.write_char(' ')?;
return self.writer.write_str(&time.as_millis().to_string());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we panic in debug mode?

fn write_timestamp(&mut self, timestamp: SystemTime) -> Result<(), std::fmt::Error> {
if let Ok(time) = timestamp.duration_since(UNIX_EPOCH) {
self.writer.write_char(' ')?;
return self.writer.write_str(&time.as_millis().to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library follows the OpenMetrics specification. This should be compatible with recent Prometheus versions (remember to set the right content type).

Please use seconds instead of milliseconds here.

https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#timestamps-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants