tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.04k stars 182 forks source link

Need to add timestamp in data series before reporting to prometheus #492

Open winattack opened 1 year ago

winattack commented 1 year ago

Is your feature request related to a problem? Please describe. default timestamp mechanism will lead to wrong statistics due to network shaking

Describe the solution you'd like like go client, add NewMetricWithTimestamp support

// Create a constant gauge from values we got from an external // temperature reporting system. Those values are reported with a slight // delay, so we want to add the timestamp of the actual measurement. temperatureReportedByExternalSystem := 298.15 timeReportedByExternalSystem := time.Date(2009, time.November, 10, 23, 0, 0, 12345678, time.UTC) s := prometheus.NewMetricWithTimestamp( timeReportedByExternalSystem, prometheus.MustNewConstMetric( desc, prometheus.GaugeValue, temperatureReportedByExternalSystem, ), )