|
8 | 8 | #include "opentelemetry/exporters/prometheus/exporter_factory.h" |
9 | 9 | #include "opentelemetry/exporters/prometheus/exporter_options.h" |
10 | 10 | #include "opentelemetry/exporters/prometheus/prometheus_pull_builder.h" |
| 11 | +#include "opentelemetry/sdk/common/global_log_handler.h" |
11 | 12 | #include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_builder.h" |
12 | 13 | #include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" |
13 | 14 | #include "opentelemetry/sdk/configuration/registry.h" |
| 15 | +#include "opentelemetry/sdk/configuration/translation_strategy.h" |
14 | 16 | #include "opentelemetry/sdk/metrics/metric_reader.h" |
15 | 17 | #include "opentelemetry/version.h" |
16 | 18 |
|
@@ -38,8 +40,36 @@ std::unique_ptr<opentelemetry::sdk::metrics::MetricReader> PrometheusPullBuilder |
38 | 40 | options.url = url; |
39 | 41 | options.populate_target_info = true; |
40 | 42 | options.without_otel_scope = model->without_scope_info; |
41 | | - options.without_units = model->without_units; |
42 | | - options.without_type_suffix = model->without_type_suffix; |
| 43 | + |
| 44 | + switch (model->translation_strategy) |
| 45 | + { |
| 46 | + case sdk::configuration::TranslationStrategy::UnderscoreEscapingWithSuffixes: |
| 47 | + options.without_units = false; |
| 48 | + options.without_type_suffix = false; |
| 49 | + break; |
| 50 | + case sdk::configuration::TranslationStrategy::UnderscoreEscapingWithoutSuffixes: |
| 51 | + options.without_units = true; |
| 52 | + options.without_type_suffix = true; |
| 53 | + break; |
| 54 | + case sdk::configuration::TranslationStrategy::NoUTF8EscapingWithSuffixes: |
| 55 | + // FIXME: no flag to disable UnderscoreEscaping |
| 56 | + OTEL_INTERNAL_LOG_WARN("[Prometheus Exporter] NoUTF8EscapingWithSuffixes not supported"); |
| 57 | + options.without_units = false; |
| 58 | + options.without_type_suffix = false; |
| 59 | + break; |
| 60 | + case sdk::configuration::TranslationStrategy::NoTranslation: |
| 61 | + // FIXME: no flag to disable UnderscoreEscaping |
| 62 | + OTEL_INTERNAL_LOG_WARN("[Prometheus Exporter] NoTranslation not supported"); |
| 63 | + options.without_units = true; |
| 64 | + options.without_type_suffix = true; |
| 65 | + break; |
| 66 | + } |
| 67 | + |
| 68 | + if (model->with_resource_constant_labels != nullptr) |
| 69 | + { |
| 70 | + // FIXME: with_resource_constant_labels |
| 71 | + OTEL_INTERNAL_LOG_WARN("[Prometheus Exporter] with_resource_constant_labels not supported"); |
| 72 | + } |
43 | 73 |
|
44 | 74 | return PrometheusExporterFactory::Create(options); |
45 | 75 | } |
|
0 commit comments