You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your environment
opentelemetry-cpp 1.9.0, prometheus 2.43.0.
Steps to reproduce
auto provider = std::make_shared<metrics_sdk::MeterProvider>();
provider->AddMetricReader(std::move(prometheus_exporter));
// ...
auto pluginCounter = metrics_api::Provider::GetMeterProvider()->GetMeter("test")->CreateUInt64Counter("plugin_counter3");
while (1)
{
pluginCounter->Add(1);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
PrometheusExporter generates such output:
# TYPE exposer_transferred_bytes_total counter
exposer_transferred_bytes_total 21388
# HELP exposer_scrapes_total Number of times metrics were scraped
# TYPE exposer_scrapes_total counter
exposer_scrapes_total 31
# HELP exposer_request_latencies Latencies of serving scrape requests, in microseconds
# TYPE exposer_request_latencies summary
exposer_request_latencies_count 31
exposer_request_latencies_sum 9972
exposer_request_latencies{quantile="0.5"} 276
exposer_request_latencies{quantile="0.9"} 524
exposer_request_latencies{quantile="0.99"} 553
# TYPE plugin_counter3 counter
plugin_counter3 155 1682692038761
Timestamp (1682692038761) for plugin_counter3 is not changing.
What is the expected behavior?
timestamp of plugin_counter3 is changed after each call Add() in cpp-code.
What is the actual behavior?
Timestamp is not changing. Errors in Prometheus logs: msg="Error on ingesting samples with different value but same timestamp" num_dropped=1
Prometheus is ignoring changes of metric value.
Additional context
In my opinion fix must be in PrometheusExporterUtils::TranslateToPrometheus:
* Helper function to convert OpenTelemetry metrics data collection
* to Prometheus metrics data collection
*
* @param records a collection of metrics in OpenTelemetry
* @return a collection of translated metrics that is acceptable by Prometheus
*/
std::vector<prometheus_client::MetricFamily> PrometheusExporterUtils::TranslateToPrometheus(
const sdk::metrics::ResourceMetrics &data)
{
// initialize output vector
std::vector<prometheus_client::MetricFamily> output;
for (const auto &instrumentation_info : data.scope_metric_data_)
{
for (const auto &metric_data : instrumentation_info.metric_data_)
{
auto origin_name = metric_data.instrument_descriptor.name_;
auto sanitized = SanitizeNames(origin_name);
prometheus_client::MetricFamily metric_family;
metric_family.name = sanitized;
metric_family.help = metric_data.instrument_descriptor.description_;
// ============= !!! FIX !!! ==============================================
auto time = metric_data.end_ts.time_since_epoch(); // metric_data.start_ts.time_since_epoch();
//========================================================================
The text was updated successfully, but these errors were encountered:
marcalff
changed the title
"Error on ingesting samples with different value but same timestamp" in Prometheus
[EXPORTER] Prometheus: Error on ingesting samples with different value but same timestamp
Jun 20, 2023
Describe your environment
opentelemetry-cpp 1.9.0, prometheus 2.43.0.
Steps to reproduce
PrometheusExporter generates such output:
Timestamp (1682692038761) for plugin_counter3 is not changing.
What is the expected behavior?
timestamp of plugin_counter3 is changed after each call Add() in cpp-code.
What is the actual behavior?
Timestamp is not changing. Errors in Prometheus logs:
msg="Error on ingesting samples with different value but same timestamp" num_dropped=1
Prometheus is ignoring changes of metric value.
Additional context
In my opinion fix must be in PrometheusExporterUtils::TranslateToPrometheus:
The text was updated successfully, but these errors were encountered: