-
Notifications
You must be signed in to change notification settings - Fork 512
Description
Greetings,
I am attempting to export to Prometheus from an application based on the Prometheus example.
WITH_METRICS_PREVIEW is undefined.
Running the example binary appears to work, and reports a metric named prometheus_metric_example, type counter,
for an instrument named prometheus_metric_example_counter in the C++ code.
Running my application,
No matter how instruments or views are named, the data exported to Prometheus always reports the same metric name,
which is the name given as instrumentation library when calling GetMeter().
Should the prometheus export code use metric_data.instrument_descriptor.name_ instead of instrumentation_info.instrumentation_library_->GetName() ?
Also, there is no HELP exported to Prometheus.
The following change helps to go further ...
Regards.
diff --git a/exporters/prometheus/src/exporter_utils.cc b/exporters/prometheus/src/exporter_utils.cc
index 39131e2..0b7a26f 100644
--- a/exporters/prometheus/src/exporter_utils.cc
+++ b/exporters/prometheus/src/exporter_utils.cc
@@ -82,11 +82,17 @@ void PrometheusExporterUtils::SetMetricFamilyByAggregator(
{
for (const auto &instrumentation_info : data.instrumentation_info_metric_data_)
{
+#ifdef NEVER
auto origin_name = instrumentation_info.instrumentation_library_->GetName();
auto sanitized = SanitizeNames(origin_name);
metric_family->name = sanitized;
+#endif
for (const auto &metric_data : instrumentation_info.metric_data_)
{
+ auto origin_name = metric_data.instrument_descriptor.name_;
+ auto sanitized = SanitizeNames(origin_name);
+ metric_family->name = sanitized;
+ metric_family->help = metric_data.instrument_descriptor.description_;
auto time = metric_data.start_ts.time_since_epoch();
for (const auto &point_data_attr : metric_data.point_data_attr_)
{