From c08a511fc50404bb8be7bf447ac9d72eb18bcf71 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Thu, 11 Jul 2024 14:30:57 +0200 Subject: [PATCH] fix rebase --- .../restlet/v2_0/RestletSingletons.java | 5 ++-- .../restlet/v2_0/RestletTelemetryBuilder.java | 8 ++---- .../v2_0/internal/RestletHeadersGetter.java | 6 +---- .../internal/RestletHttpAttributesGetter.java | 6 +---- .../RestletTelemetryBuilderFactory.java | 26 +++++++++++++++++++ 5 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java diff --git a/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java b/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java index ff57cf52a2e6..59d25f717636 100644 --- a/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java +++ b/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteGetter; -import io.opentelemetry.instrumentation.restlet.v2_0.RestletTelemetry; +import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletTelemetryBuilderFactory; import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath; import org.restlet.Request; @@ -17,7 +17,8 @@ public final class RestletSingletons { private static final Instrumenter INSTRUMENTER = - JavaagentHttpServerInstrumenters.create(RestletTelemetry.create(GlobalOpenTelemetry.get())); + JavaagentHttpServerInstrumenters.create( + RestletTelemetryBuilderFactory.create(GlobalOpenTelemetry.get())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java index d234f84e7a62..6c49897500ed 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java @@ -11,8 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; -import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletHeadersGetter; -import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletHttpAttributesGetter; +import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletTelemetryBuilderFactory; import java.util.List; import java.util.Set; import java.util.function.Function; @@ -25,10 +24,7 @@ public final class RestletTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; RestletTelemetryBuilder(OpenTelemetry openTelemetry) { - builder = - new DefaultHttpServerInstrumenterBuilder<>( - "io.opentelemetry.restlet-2.0", openTelemetry, RestletHttpAttributesGetter.INSTANCE) - .setHeaderGetter(new RestletHeadersGetter()); + builder = RestletTelemetryBuilderFactory.create(openTelemetry); } /** diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHeadersGetter.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHeadersGetter.java index 4026a51d8aa6..50afe5a8406a 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHeadersGetter.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHeadersGetter.java @@ -18,11 +18,7 @@ import org.restlet.Request; import org.restlet.util.Series; -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public final class RestletHeadersGetter implements TextMapGetter { +final class RestletHeadersGetter implements TextMapGetter { private static final MethodHandle GET_ATTRIBUTES; diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHttpAttributesGetter.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHttpAttributesGetter.java index 38c5a96c2ffc..fa5554e81e9f 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHttpAttributesGetter.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletHttpAttributesGetter.java @@ -16,11 +16,7 @@ import org.restlet.Response; import org.restlet.util.Series; -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public enum RestletHttpAttributesGetter implements HttpServerAttributesGetter { +enum RestletHttpAttributesGetter implements HttpServerAttributesGetter { INSTANCE; @Override diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java new file mode 100644 index 000000000000..309149fe2845 --- /dev/null +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java @@ -0,0 +1,26 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.restlet.v2_0.internal; + +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; +import org.restlet.Request; +import org.restlet.Response; + +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public class RestletTelemetryBuilderFactory { + private RestletTelemetryBuilderFactory() {} + + public static DefaultHttpServerInstrumenterBuilder create( + OpenTelemetry openTelemetry) { + return new DefaultHttpServerInstrumenterBuilder<>( + "io.opentelemetry.restlet-2.0", openTelemetry, RestletHttpAttributesGetter.INSTANCE) + .setHeaderGetter(new RestletHeadersGetter()); + } +}