|
69 | 69 | import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder; |
70 | 70 | import io.opentelemetry.sdk.trace.export.SpanExporter; |
71 | 71 | import io.opentelemetry.sdk.trace.samplers.SamplingDecision; |
| 72 | +import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; |
72 | 73 | import java.io.File; |
73 | 74 | import java.util.ArrayList; |
74 | 75 | import java.util.Collections; |
@@ -274,7 +275,7 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) { |
274 | 275 | (metricExporter, configProperties) -> { |
275 | 276 | if (metricExporter |
276 | 277 | instanceof AzureMonitorMetricExporterProvider.MarkerMetricExporter) { |
277 | | - return buildMetricExporter(configuration, telemetryClient, metricFilters); |
| 278 | + return buildMetricExporter(configuration, telemetryClient, metricFilters, configProperties); |
278 | 279 | } else { |
279 | 280 | return metricExporter; |
280 | 281 | } |
@@ -365,10 +366,16 @@ private static SpanExporter buildTraceExporter( |
365 | 366 | private static MetricExporter buildMetricExporter( |
366 | 367 | Configuration configuration, |
367 | 368 | TelemetryClient telemetryClient, |
368 | | - List<MetricFilter> metricFilters) { |
| 369 | + List<MetricFilter> metricFilters, ConfigProperties configProperties) { |
| 370 | + |
| 371 | + String otelMetricsEndpoint = configProperties.getString("otel.metrics.exporter.otlp.endpoint"); |
| 372 | + String otelMetricsExporter = configProperties.getString("otel.metrics.exporter"); |
| 373 | + boolean otlpEnabled = (otelMetricsExporter != null && !otelMetricsExporter.isEmpty()) && |
| 374 | + (otelMetricsEndpoint != null && !otelMetricsEndpoint.isEmpty()); |
| 375 | + |
369 | 376 | MetricDataMapper mapper = |
370 | 377 | new MetricDataMapper( |
371 | | - telemetryClient::populateDefaults, configuration.preview.captureHttpServer4xxAsError); |
| 378 | + telemetryClient::populateDefaults, configuration.preview.captureHttpServer4xxAsError, otlpEnabled); |
372 | 379 | return new AgentMetricExporter( |
373 | 380 | metricFilters, mapper, telemetryClient.getMetricsBatchItemProcessor()); |
374 | 381 | } |
|
0 commit comments