From 5b625d2e1ffccc641cc1fb1def6b67b9f63e1c57 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Wed, 13 May 2020 08:20:32 -0700 Subject: [PATCH] Avoid unnecessary public classes. (#1211) Signed-off-by: Bogdan Drutu --- .../java/io/opentelemetry/OpenTelemetry.java | 11 ++--- ...aultCorrelationContextManagerProvider.java | 45 ------------------- .../metrics/DefaultMetricsProvider.java | 43 ------------------ .../trace/DefaultTraceProvider.java | 43 ------------------ 4 files changed, 3 insertions(+), 139 deletions(-) delete mode 100644 api/src/main/java/io/opentelemetry/correlationcontext/DefaultCorrelationContextManagerProvider.java delete mode 100644 api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java delete mode 100644 api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java diff --git a/api/src/main/java/io/opentelemetry/OpenTelemetry.java b/api/src/main/java/io/opentelemetry/OpenTelemetry.java index 328deeae1fa..1fa1a1e179d 100644 --- a/api/src/main/java/io/opentelemetry/OpenTelemetry.java +++ b/api/src/main/java/io/opentelemetry/OpenTelemetry.java @@ -20,16 +20,13 @@ import io.opentelemetry.context.propagation.DefaultContextPropagators; import io.opentelemetry.correlationcontext.CorrelationContextManager; import io.opentelemetry.correlationcontext.DefaultCorrelationContextManager; -import io.opentelemetry.correlationcontext.DefaultCorrelationContextManagerProvider; import io.opentelemetry.correlationcontext.spi.CorrelationContextManagerProvider; import io.opentelemetry.internal.Obfuscated; import io.opentelemetry.internal.Utils; import io.opentelemetry.metrics.DefaultMeterProvider; -import io.opentelemetry.metrics.DefaultMetricsProvider; import io.opentelemetry.metrics.Meter; import io.opentelemetry.metrics.MeterProvider; import io.opentelemetry.metrics.spi.MetricsProvider; -import io.opentelemetry.trace.DefaultTraceProvider; import io.opentelemetry.trace.DefaultTracerProvider; import io.opentelemetry.trace.Tracer; import io.opentelemetry.trace.TracerProvider; @@ -206,19 +203,17 @@ private OpenTelemetry() { this.tracerProvider = traceProvider != null ? new ObfuscatedTracerProvider(traceProvider.create()) - : DefaultTraceProvider.getInstance().create(); + : DefaultTracerProvider.getInstance(); MetricsProvider metricsProvider = loadSpi(MetricsProvider.class); meterProvider = - metricsProvider != null - ? metricsProvider.create() - : DefaultMetricsProvider.getInstance().create(); + metricsProvider != null ? metricsProvider.create() : DefaultMeterProvider.getInstance(); CorrelationContextManagerProvider contextManagerProvider = loadSpi(CorrelationContextManagerProvider.class); contextManager = contextManagerProvider != null ? contextManagerProvider.create() - : DefaultCorrelationContextManagerProvider.getInstance().create(); + : DefaultCorrelationContextManager.getInstance(); } /** diff --git a/api/src/main/java/io/opentelemetry/correlationcontext/DefaultCorrelationContextManagerProvider.java b/api/src/main/java/io/opentelemetry/correlationcontext/DefaultCorrelationContextManagerProvider.java deleted file mode 100644 index 885a200d23c..00000000000 --- a/api/src/main/java/io/opentelemetry/correlationcontext/DefaultCorrelationContextManagerProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2020, OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentelemetry.correlationcontext; - -import io.opentelemetry.correlationcontext.spi.CorrelationContextManagerProvider; -import javax.annotation.concurrent.ThreadSafe; - -@ThreadSafe -public final class DefaultCorrelationContextManagerProvider - implements CorrelationContextManagerProvider { - private static final CorrelationContextManagerProvider instance = - new DefaultCorrelationContextManagerProvider(); - - /** - * Returns a {@code CorrelationContextManagerProvider} singleton that is the default - * implementation for {@link CorrelationContextManager}. - * - * @return a {@code CorrelationContextManagerProvider} singleton that is the default - * implementation for {@link CorrelationContextManager}. - */ - public static CorrelationContextManagerProvider getInstance() { - return instance; - } - - @Override - public CorrelationContextManager create() { - return DefaultCorrelationContextManager.getInstance(); - } - - private DefaultCorrelationContextManagerProvider() {} -} diff --git a/api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java b/api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java deleted file mode 100644 index ff186c67d97..00000000000 --- a/api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2019, OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentelemetry.metrics; - -import io.opentelemetry.metrics.spi.MetricsProvider; -import javax.annotation.concurrent.ThreadSafe; - -@ThreadSafe -public final class DefaultMetricsProvider implements MetricsProvider { - private static final MetricsProvider instance = new DefaultMetricsProvider(); - - /** - * Returns a {@code MetricsProvider} singleton that is the default implementation for {@link - * MetricsProvider}. - * - * @return a {@code MetricsProvider} singleton that is the default implementation for {@link - * MetricsProvider}. - */ - public static MetricsProvider getInstance() { - return instance; - } - - @Override - public MeterProvider create() { - return DefaultMeterProvider.getInstance(); - } - - private DefaultMetricsProvider() {} -} diff --git a/api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java b/api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java deleted file mode 100644 index 0431938fb89..00000000000 --- a/api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2019, OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.opentelemetry.trace; - -import io.opentelemetry.trace.spi.TraceProvider; -import javax.annotation.concurrent.ThreadSafe; - -@ThreadSafe -public final class DefaultTraceProvider implements TraceProvider { - private static final TraceProvider instance = new DefaultTraceProvider(); - - /** - * Returns a {@code TraceProvider} singleton that is the default implementation for {@link - * TraceProvider}. - * - * @return a {@code TraceProvider} singleton that is the default implementation for {@link - * TraceProvider}. - */ - public static TraceProvider getInstance() { - return instance; - } - - @Override - public TracerProvider create() { - return DefaultTracerProvider.getInstance(); - } - - private DefaultTraceProvider() {} -}