From dac3271f4e4bf585558b0ff0f6d3ef83b2433fda Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Fri, 29 Nov 2024 16:32:54 +1100 Subject: [PATCH 1/3] Updates to fix deprecation warnings --- server/build.gradle | 5 +++-- .../honeycomb/HoneycombOTELEndpointHandler.java | 11 +++++++++-- .../opentelemetry/server/helpers/OTELHelperImpl.java | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/server/build.gradle b/server/build.gradle index a40a68c..10b3423 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -19,13 +19,14 @@ dependencies { implementation('io.opentelemetry:opentelemetry-sdk:1.44.1') implementation('io.opentelemetry:opentelemetry-exporter-otlp:1.44.1') implementation 'io.opentelemetry:opentelemetry-sdk-metrics:1.44.1' - implementation('io.opentelemetry:opentelemetry-semconv:1.31.0-alpha-SNAPSHOT') + implementation('io.opentelemetry.semconv:opentelemetry-semconv') + implementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.26.0-alpha") implementation('io.opentelemetry:opentelemetry-exporter-zipkin') implementation 'io.grpc:grpc-netty-shaded:1.68.1' testImplementation 'org.jetbrains.teamcity:tests-support:2024.07' testImplementation 'org.jetbrains.teamcity:server-api:2024.07' - testImplementation 'org.apache.commons:commons-lang3:3.17.0' + testImplementation 'org.apache.commons:commons-text:1.12.0' testImplementation 'org.mockito:mockito-junit-jupiter:5.14.2' testImplementation 'org.mockito:mockito-core:5.14.2' testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3' 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 2651980..9dd4413 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 @@ -4,6 +4,7 @@ import com.octopus.teamcity.opentelemetry.server.*; import com.octopus.teamcity.opentelemetry.server.endpoints.IOTELEndpointHandler; import com.octopus.teamcity.opentelemetry.server.helpers.OTELMetrics; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporter; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; @@ -11,7 +12,7 @@ import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.SpanProcessor; import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ServiceAttributes; import jetbrains.buildServer.serverSide.SBuild; import jetbrains.buildServer.serverSide.crypt.EncryptUtil; import jetbrains.buildServer.serverSide.crypt.RSACipher; @@ -84,7 +85,13 @@ private MetricExporter buildMetricsExporter(String endpoint, Map private SpanProcessor buildGrpcSpanProcessor(Map headers, String exporterEndpoint, @Nullable MetricExporter metricsExporter) { - var serviceNameResource = Resource.create(Attributes.of(ResourceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME)); + //todo: centralise the definition of this + var serviceNameResource = Resource + .create(Attributes.of( + ServiceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME, + AttributeKey.stringKey("teamcity.node.id"), nodesService.getCurrentNode().getId()) + ); + var meterProvider = OTELMetrics.getOTELMeterProvider(metricsExporter, serviceNameResource); var spanExporterBuilder = OtlpGrpcSpanExporter.builder(); diff --git a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELHelperImpl.java b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELHelperImpl.java index 9d87b58..d48fe4a 100644 --- a/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELHelperImpl.java +++ b/server/src/main/java/com/octopus/teamcity/opentelemetry/server/helpers/OTELHelperImpl.java @@ -12,7 +12,7 @@ import io.opentelemetry.sdk.resources.Resource; import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.SpanProcessor; -import io.opentelemetry.semconv.resource.attributes.ResourceAttributes; +import io.opentelemetry.semconv.ServiceAttributes; import org.apache.log4j.Logger; import javax.annotation.Nullable; @@ -30,7 +30,7 @@ public class OTELHelperImpl implements OTELHelper { public OTELHelperImpl(SpanProcessor spanProcessor, String helperName) { this.helperName = helperName; Resource serviceNameResource = Resource - .create(Attributes.of(ResourceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME)); + .create(Attributes.of(ServiceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME)); this.sdkTracerProvider = SdkTracerProvider.builder() .setResource(Resource.getDefault().merge(serviceNameResource)) .addSpanProcessor(spanProcessor) From d7bb62634a4825ca3a48ce497cec121649a9e483 Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Fri, 29 Nov 2024 16:34:16 +1100 Subject: [PATCH 2/3] Update HoneycombOTELEndpointHandler.java --- .../endpoints/honeycomb/HoneycombOTELEndpointHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 9dd4413..f2af134 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 @@ -88,8 +88,7 @@ private SpanProcessor buildGrpcSpanProcessor(Map headers, String //todo: centralise the definition of this var serviceNameResource = Resource .create(Attributes.of( - ServiceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME, - AttributeKey.stringKey("teamcity.node.id"), nodesService.getCurrentNode().getId()) + ServiceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME ); var meterProvider = OTELMetrics.getOTELMeterProvider(metricsExporter, serviceNameResource); From d00336578d50a1db9bd2cd8087556e3a336e9c7c Mon Sep 17 00:00:00 2001 From: Matt Richardson Date: Fri, 29 Nov 2024 16:43:20 +1100 Subject: [PATCH 3/3] Update HoneycombOTELEndpointHandler.java --- .../endpoints/honeycomb/HoneycombOTELEndpointHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f2af134..a1fc2a7 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 @@ -89,7 +89,7 @@ private SpanProcessor buildGrpcSpanProcessor(Map headers, String var serviceNameResource = Resource .create(Attributes.of( ServiceAttributes.SERVICE_NAME, PluginConstants.SERVICE_NAME - ); + )); var meterProvider = OTELMetrics.getOTELMeterProvider(metricsExporter, serviceNameResource);