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

Support time stamps when exporting metrics #423

Closed
Mikadore opened this issue Oct 25, 2021 · 3 comments
Closed

Support time stamps when exporting metrics #423

Mikadore opened this issue Oct 25, 2021 · 3 comments

Comments

@Mikadore
Copy link

Is your feature request related to a problem? Please describe.
In order to backfill metrics into prometheus, time stamps are needed. Currently, this crate doesn't provide a way to add time stamps when exporting using either ProtobufEncoder or TextEncoder

Describe the solution you'd like
Add a method to ProtobufEncoder and TextEncoder, perhaps something like encode_with_timestamp.

Describe alternatives you've considered
Hacking around manually with exported metrics. This is error prone, but also a feature that falls within the use case of this crate.

@Mikadore
Copy link
Author

Mikadore commented Nov 2, 2021

This can be done using:

        metric_families
            .into_iter()
            .map(|mut fam| {
                for metric in fam.mut_metric() {
                    metric.set_timestamp_ms(timestamp)
                }
                fam
            })
            .collect()

@Mikadore Mikadore closed this as completed Nov 2, 2021
@lucab
Copy link
Member

lucab commented Nov 2, 2021

Welcome and thanks for the report. Are you maybe chasing the same feature request as #382?

@Mikadore
Copy link
Author

Mikadore commented Nov 2, 2021

Welcome and thanks for the report. Are you maybe chasing the same feature request as #382?

Hello, yes, it seems I didn't search carefully enough. Thanks :D

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

No branches or pull requests

2 participants