From b29bcd28aa7f779ffd3e37a4fabf2707d4808407 Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Thu, 28 Nov 2024 12:29:06 +1100 Subject: [PATCH] Dont emit metrics to console --- server/build.gradle | 1 - .../endpoints/honeycomb/HoneycombOTELEndpointHandler.java | 2 +- .../opentelemetry/server/helpers/OTELMetrics.java | 8 +------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/server/build.gradle b/server/build.gradle index 114879f..290eab2 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -18,7 +18,6 @@ dependencies { implementation('io.opentelemetry:opentelemetry-api:1.44.1') implementation('io.opentelemetry:opentelemetry-sdk:1.44.1') implementation('io.opentelemetry:opentelemetry-exporter-otlp:1.44.1') - implementation('io.opentelemetry:opentelemetry-exporter-logging:1.44.1') implementation 'io.opentelemetry:opentelemetry-sdk-metrics:1.28.0' implementation('io.opentelemetry:opentelemetry-semconv:1.31.0-alpha-SNAPSHOT') implementation('io.opentelemetry:opentelemetry-exporter-zipkin') diff --git a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java index c37c96a..046e880 100644 --- a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java +++ b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/endpoints/honeycomb/HoneycombOTELEndpointHandler.java @@ -82,7 +82,7 @@ private MetricExporter buildMetricsExporter(String endpoint, Map return null; } - private SpanProcessor buildGrpcSpanProcessor(Map headers, String exporterEndpoint, MetricExporter metricsExporter) { + private SpanProcessor buildGrpcSpanProcessor(Map headers, String exporterEndpoint, @Nullable MetricExporter metricsExporter) { var serviceNameResource = Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME)); var meterProvider = OTELMetrics.getOTELMeterProvider(metricsExporter, serviceNameResource); diff --git a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELMetrics.java b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELMetrics.java index 1088328..8c4234d 100644 --- a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELMetrics.java +++ b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELMetrics.java @@ -1,7 +1,6 @@ package com.octopus.teamcity.opentelemetry.server.helpers; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.exporter.logging.LoggingMetricExporter; import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.export.MetricExporter; @@ -26,13 +25,8 @@ public static SdkMeterProvider getOTELMeterProvider(@Nullable MetricExporter met if (metricsConfigured.get()) return sdkMeterProvider; metricsConfigured.set(true); - var loggingMetricExporter = LoggingMetricExporter.create(); - var consoleLogMetricReader = PeriodicMetricReader.builder(loggingMetricExporter) - .setInterval(Duration.ofSeconds(10)) - .build(); var meterProviderBuilder = SdkMeterProvider.builder() - .setResource(Resource.getDefault().merge(serviceNameResource)) - .registerMetricReader(consoleLogMetricReader); + .setResource(Resource.getDefault().merge(serviceNameResource)); if (metricExporter != null) { var providedMetricExporterBuilder = PeriodicMetricReader.builder(metricExporter) .setInterval(Duration.ofSeconds(10))