From 9804e270c3f087c70eb522140586a4b4e3ff4679 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Tue, 26 Sep 2023 13:52:55 +0800 Subject: [PATCH] Code refinement to remove IDE warnings --- .../o11yphant/trace/TracerConfiguration.java | 17 +++++++++++------ .../FlatTraceMeasureInterceptor.java | 1 - .../FlatTraceWrapperEndInterceptor.java | 1 - .../FlatTraceWrapperInterceptor.java | 1 - .../FlatTraceWrapperStartInterceptor.java | 1 - .../o11yphant/jhttpc/SpanningHttpFactory.java | 1 - .../o11yphant/trace/servlet/TraceFilter.java | 1 - .../org/commonjava/o11yphant/otel/OtelUtil.java | 1 - 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/trace/api/src/main/java/org/commonjava/o11yphant/trace/TracerConfiguration.java b/trace/api/src/main/java/org/commonjava/o11yphant/trace/TracerConfiguration.java index ddfaaf06..4024bac5 100644 --- a/trace/api/src/main/java/org/commonjava/o11yphant/trace/TracerConfiguration.java +++ b/trace/api/src/main/java/org/commonjava/o11yphant/trace/TracerConfiguration.java @@ -19,21 +19,26 @@ import org.slf4j.LoggerFactory; import java.lang.reflect.Method; -import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.Map; import java.util.Set; -import static org.commonjava.o11yphant.metrics.RequestContextConstants.*; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.CLIENT_ADDR; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.CONTENT_TRACKING_ID; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.HTTP_METHOD; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.HTTP_STATUS; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.PACKAGE_TYPE; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.PATH; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.REQUEST_LATENCY_MILLIS; +import static org.commonjava.o11yphant.metrics.RequestContextConstants.REST_ENDPOINT_PATH; public interface TracerConfiguration { Integer DEFAULT_BASE_SAMPLE_RATE = 100; - Set DEFAULT_FIELDS = Collections.unmodifiableSet( - new HashSet<>( Arrays.asList( CONTENT_TRACKING_ID, HTTP_METHOD, HTTP_STATUS, CLIENT_ADDR, - PATH, PACKAGE_TYPE, REST_ENDPOINT_PATH, REQUEST_LATENCY_MILLIS ) ) ); + Set DEFAULT_FIELDS = + Set.of( CONTENT_TRACKING_ID, HTTP_METHOD, HTTP_STATUS, CLIENT_ADDR, PATH, PACKAGE_TYPE, REST_ENDPOINT_PATH, + REQUEST_LATENCY_MILLIS ); boolean isEnabled(); diff --git a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceMeasureInterceptor.java b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceMeasureInterceptor.java index b03cea6e..622b2af6 100644 --- a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceMeasureInterceptor.java +++ b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceMeasureInterceptor.java @@ -40,7 +40,6 @@ public class FlatTraceMeasureInterceptor @Inject private TracerConfiguration config; - @SuppressWarnings( "rawtypes" ) @Inject private TraceManager traceManager; diff --git a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperEndInterceptor.java b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperEndInterceptor.java index 2867592e..96e3cc73 100644 --- a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperEndInterceptor.java +++ b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperEndInterceptor.java @@ -42,7 +42,6 @@ public class FlatTraceWrapperEndInterceptor @Inject private TracerConfiguration config; - @SuppressWarnings( "rawtypes" ) @Inject private TraceManager traceManager; diff --git a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperInterceptor.java b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperInterceptor.java index 994d8fc6..0e8e7cc9 100644 --- a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperInterceptor.java +++ b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperInterceptor.java @@ -42,7 +42,6 @@ public class FlatTraceWrapperInterceptor @Inject private TracerConfiguration config; - @SuppressWarnings( "rawtypes" ) @Inject private TraceManager traceManager; diff --git a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperStartInterceptor.java b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperStartInterceptor.java index d878aa0b..f6cd5f85 100644 --- a/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperStartInterceptor.java +++ b/trace/core/src/main/java/org/commonjava/o11yphant/trace/interceptor/FlatTraceWrapperStartInterceptor.java @@ -42,7 +42,6 @@ public class FlatTraceWrapperStartInterceptor @Inject private TracerConfiguration config; - @SuppressWarnings( "rawtypes" ) @Inject private TraceManager traceManager; diff --git a/trace/helper-jhttpc/src/main/java/org/commonjava/o11yphant/jhttpc/SpanningHttpFactory.java b/trace/helper-jhttpc/src/main/java/org/commonjava/o11yphant/jhttpc/SpanningHttpFactory.java index 10af7ab8..efbb77ca 100644 --- a/trace/helper-jhttpc/src/main/java/org/commonjava/o11yphant/jhttpc/SpanningHttpFactory.java +++ b/trace/helper-jhttpc/src/main/java/org/commonjava/o11yphant/jhttpc/SpanningHttpFactory.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Optional; -@SuppressWarnings( "rawtypes" ) public class SpanningHttpFactory implements HttpFactoryIfc { diff --git a/trace/helper-servlet/src/main/java/org/commonjava/o11yphant/trace/servlet/TraceFilter.java b/trace/helper-servlet/src/main/java/org/commonjava/o11yphant/trace/servlet/TraceFilter.java index 72bd1b21..30c2482d 100644 --- a/trace/helper-servlet/src/main/java/org/commonjava/o11yphant/trace/servlet/TraceFilter.java +++ b/trace/helper-servlet/src/main/java/org/commonjava/o11yphant/trace/servlet/TraceFilter.java @@ -43,7 +43,6 @@ public class TraceFilter implements Filter { - @SuppressWarnings( "rawtypes" ) @Inject private TraceManager traceManager; diff --git a/trace/otel/src/main/java/org/commonjava/o11yphant/otel/OtelUtil.java b/trace/otel/src/main/java/org/commonjava/o11yphant/otel/OtelUtil.java index 4fad3805..fac43626 100644 --- a/trace/otel/src/main/java/org/commonjava/o11yphant/otel/OtelUtil.java +++ b/trace/otel/src/main/java/org/commonjava/o11yphant/otel/OtelUtil.java @@ -21,7 +21,6 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; import io.opentelemetry.context.propagation.ContextPropagators; -import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.exporter.logging.LoggingSpanExporter; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter; import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;