From d4cf312671304183007c2781dd21a459c61545af Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 28 Jan 2020 10:23:40 -0800 Subject: [PATCH] Rename spi providers to match {}Provider name (#800) Signed-off-by: Bogdan Cristian Drutu --- .../java/io/opentelemetry/OpenTelemetry.java | 26 ++++---- ...vider.java => DefaultMetricsProvider.java} | 8 +-- ...stryProvider.java => MetricsProvider.java} | 2 +- ...rovider.java => DefaultTraceProvider.java} | 8 +-- ...gistryProvider.java => TraceProvider.java} | 2 +- .../io/opentelemetry/OpenTelemetryTest.java | 64 +++++++++---------- ...yProvider.java => SdkMetricsProvider.java} | 6 +- ...tryProvider.java => SdkTraceProvider.java} | 4 +- ...elemetry.metrics.spi.MeterRegistryProvider | 1 - ....opentelemetry.metrics.spi.MetricsProvider | 1 + .../io.opentelemetry.trace.spi.TraceProvider | 1 + ...telemetry.trace.spi.TracerRegistryProvider | 1 - .../sdk/metrics/MeterSdkProviderTest.java | 2 +- .../sdk/trace/TracerSdkProviderTest.java | 2 +- 14 files changed, 62 insertions(+), 66 deletions(-) rename api/src/main/java/io/opentelemetry/metrics/{DefaultMeterRegistryProvider.java => DefaultMetricsProvider.java} (73%) rename api/src/main/java/io/opentelemetry/metrics/spi/{MeterRegistryProvider.java => MetricsProvider.java} (97%) rename api/src/main/java/io/opentelemetry/trace/{DefaultTracerRegistryProvider.java => DefaultTraceProvider.java} (72%) rename api/src/main/java/io/opentelemetry/trace/spi/{TracerRegistryProvider.java => TraceProvider.java} (96%) rename sdk/src/main/java/io/opentelemetry/sdk/metrics/{MeterSdkRegistryProvider.java => SdkMetricsProvider.java} (81%) rename sdk/src/main/java/io/opentelemetry/sdk/trace/{TracerSdkRegistryProvider.java => SdkTraceProvider.java} (86%) delete mode 100644 sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MeterRegistryProvider create mode 100644 sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MetricsProvider create mode 100644 sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TraceProvider delete mode 100644 sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TracerRegistryProvider diff --git a/api/src/main/java/io/opentelemetry/OpenTelemetry.java b/api/src/main/java/io/opentelemetry/OpenTelemetry.java index 4d9165a179d..5e53554e1e3 100644 --- a/api/src/main/java/io/opentelemetry/OpenTelemetry.java +++ b/api/src/main/java/io/opentelemetry/OpenTelemetry.java @@ -20,15 +20,15 @@ import io.opentelemetry.correlationcontext.DefaultCorrelationContextManager; import io.opentelemetry.correlationcontext.spi.CorrelationContextManagerProvider; import io.opentelemetry.metrics.DefaultMeterRegistry; -import io.opentelemetry.metrics.DefaultMeterRegistryProvider; +import io.opentelemetry.metrics.DefaultMetricsProvider; import io.opentelemetry.metrics.Meter; import io.opentelemetry.metrics.MeterRegistry; -import io.opentelemetry.metrics.spi.MeterRegistryProvider; +import io.opentelemetry.metrics.spi.MetricsProvider; +import io.opentelemetry.trace.DefaultTraceProvider; import io.opentelemetry.trace.DefaultTracerRegistry; -import io.opentelemetry.trace.DefaultTracerRegistryProvider; import io.opentelemetry.trace.Tracer; import io.opentelemetry.trace.TracerRegistry; -import io.opentelemetry.trace.spi.TracerRegistryProvider; +import io.opentelemetry.trace.spi.TraceProvider; import java.util.ServiceLoader; import javax.annotation.Nullable; import javax.annotation.concurrent.ThreadSafe; @@ -40,7 +40,7 @@ *

The telemetry objects are lazy-loaded singletons resolved via {@link ServiceLoader} mechanism. * * @see TracerRegistry - * @see MeterRegistryProvider + * @see MetricsProvider * @see CorrelationContextManagerProvider */ @ThreadSafe @@ -102,17 +102,17 @@ private static OpenTelemetry getInstance() { } private OpenTelemetry() { - TracerRegistryProvider tracerRegistryProvider = loadSpi(TracerRegistryProvider.class); + TraceProvider traceProvider = loadSpi(TraceProvider.class); this.tracerRegistry = - tracerRegistryProvider != null - ? tracerRegistryProvider.create() - : DefaultTracerRegistryProvider.getInstance().create(); + traceProvider != null + ? traceProvider.create() + : DefaultTraceProvider.getInstance().create(); - MeterRegistryProvider meterRegistryProvider = loadSpi(MeterRegistryProvider.class); + MetricsProvider metricsProvider = loadSpi(MetricsProvider.class); meterRegistry = - meterRegistryProvider != null - ? meterRegistryProvider.create() - : DefaultMeterRegistryProvider.getInstance().create(); + metricsProvider != null + ? metricsProvider.create() + : DefaultMetricsProvider.getInstance().create(); CorrelationContextManagerProvider contextManagerProvider = loadSpi(CorrelationContextManagerProvider.class); contextManager = diff --git a/api/src/main/java/io/opentelemetry/metrics/DefaultMeterRegistryProvider.java b/api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java similarity index 73% rename from api/src/main/java/io/opentelemetry/metrics/DefaultMeterRegistryProvider.java rename to api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java index a74fc74f519..116b740626f 100644 --- a/api/src/main/java/io/opentelemetry/metrics/DefaultMeterRegistryProvider.java +++ b/api/src/main/java/io/opentelemetry/metrics/DefaultMetricsProvider.java @@ -16,12 +16,12 @@ package io.opentelemetry.metrics; -import io.opentelemetry.metrics.spi.MeterRegistryProvider; +import io.opentelemetry.metrics.spi.MetricsProvider; -public class DefaultMeterRegistryProvider implements MeterRegistryProvider { - private static final MeterRegistryProvider instance = new DefaultMeterRegistryProvider(); +public class DefaultMetricsProvider implements MetricsProvider { + private static final MetricsProvider instance = new DefaultMetricsProvider(); - public static MeterRegistryProvider getInstance() { + public static MetricsProvider getInstance() { return instance; } diff --git a/api/src/main/java/io/opentelemetry/metrics/spi/MeterRegistryProvider.java b/api/src/main/java/io/opentelemetry/metrics/spi/MetricsProvider.java similarity index 97% rename from api/src/main/java/io/opentelemetry/metrics/spi/MeterRegistryProvider.java rename to api/src/main/java/io/opentelemetry/metrics/spi/MetricsProvider.java index 07b682055b9..e3af54f542a 100644 --- a/api/src/main/java/io/opentelemetry/metrics/spi/MeterRegistryProvider.java +++ b/api/src/main/java/io/opentelemetry/metrics/spi/MetricsProvider.java @@ -30,7 +30,7 @@ * @see io.opentelemetry.OpenTelemetry */ @ThreadSafe -public interface MeterRegistryProvider { +public interface MetricsProvider { /** * Creates a new meter registry instance. diff --git a/api/src/main/java/io/opentelemetry/trace/DefaultTracerRegistryProvider.java b/api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java similarity index 72% rename from api/src/main/java/io/opentelemetry/trace/DefaultTracerRegistryProvider.java rename to api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java index b6b9e8b21bf..9b72cd62bbd 100644 --- a/api/src/main/java/io/opentelemetry/trace/DefaultTracerRegistryProvider.java +++ b/api/src/main/java/io/opentelemetry/trace/DefaultTraceProvider.java @@ -16,12 +16,12 @@ package io.opentelemetry.trace; -import io.opentelemetry.trace.spi.TracerRegistryProvider; +import io.opentelemetry.trace.spi.TraceProvider; -public class DefaultTracerRegistryProvider implements TracerRegistryProvider { - private static final TracerRegistryProvider instance = new DefaultTracerRegistryProvider(); +public class DefaultTraceProvider implements TraceProvider { + private static final TraceProvider instance = new DefaultTraceProvider(); - public static TracerRegistryProvider getInstance() { + public static TraceProvider getInstance() { return instance; } diff --git a/api/src/main/java/io/opentelemetry/trace/spi/TracerRegistryProvider.java b/api/src/main/java/io/opentelemetry/trace/spi/TraceProvider.java similarity index 96% rename from api/src/main/java/io/opentelemetry/trace/spi/TracerRegistryProvider.java rename to api/src/main/java/io/opentelemetry/trace/spi/TraceProvider.java index ae17da668d2..5dc16a4cc97 100644 --- a/api/src/main/java/io/opentelemetry/trace/spi/TracerRegistryProvider.java +++ b/api/src/main/java/io/opentelemetry/trace/spi/TraceProvider.java @@ -30,7 +30,7 @@ * @see io.opentelemetry.OpenTelemetry */ @ThreadSafe -public interface TracerRegistryProvider { +public interface TraceProvider { /** * Creates a new TracerRegistry. diff --git a/api/src/test/java/io/opentelemetry/OpenTelemetryTest.java b/api/src/test/java/io/opentelemetry/OpenTelemetryTest.java index bf015331a4d..ec3b029fecb 100644 --- a/api/src/test/java/io/opentelemetry/OpenTelemetryTest.java +++ b/api/src/test/java/io/opentelemetry/OpenTelemetryTest.java @@ -39,13 +39,13 @@ import io.opentelemetry.metrics.LongObserver; import io.opentelemetry.metrics.Meter; import io.opentelemetry.metrics.MeterRegistry; -import io.opentelemetry.metrics.spi.MeterRegistryProvider; +import io.opentelemetry.metrics.spi.MetricsProvider; import io.opentelemetry.trace.DefaultTracer; import io.opentelemetry.trace.Span; import io.opentelemetry.trace.SpanContext; import io.opentelemetry.trace.Tracer; import io.opentelemetry.trace.TracerRegistry; -import io.opentelemetry.trace.spi.TracerRegistryProvider; +import io.opentelemetry.trace.spi.TraceProvider; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -75,8 +75,8 @@ public static void beforeClass() { @After public void after() { OpenTelemetry.reset(); - System.clearProperty(TracerRegistryProvider.class.getName()); - System.clearProperty(MeterRegistryProvider.class.getName()); + System.clearProperty(TraceProvider.class.getName()); + System.clearProperty(MetricsProvider.class.getName()); System.clearProperty(CorrelationContextManagerProvider.class.getName()); } @@ -98,12 +98,11 @@ public void testDefault() { @Test public void testTracerLoadArbitrary() throws IOException { File serviceFile = - createService( - TracerRegistryProvider.class, FirstTracerRegistry.class, SecondTracerRegistry.class); + createService(TraceProvider.class, FirstTraceProvider.class, SecondTraceProvider.class); try { assertTrue( - (OpenTelemetry.getTracerRegistry() instanceof FirstTracerRegistry) - || (OpenTelemetry.getTracerRegistry() instanceof SecondTracerRegistry)); + (OpenTelemetry.getTracerRegistry() instanceof FirstTraceProvider) + || (OpenTelemetry.getTracerRegistry() instanceof SecondTraceProvider)); } finally { serviceFile.delete(); } @@ -112,12 +111,10 @@ public void testTracerLoadArbitrary() throws IOException { @Test public void testTracerSystemProperty() throws IOException { File serviceFile = - createService( - TracerRegistryProvider.class, FirstTracerRegistry.class, SecondTracerRegistry.class); - System.setProperty( - TracerRegistryProvider.class.getName(), SecondTracerRegistry.class.getName()); + createService(TraceProvider.class, FirstTraceProvider.class, SecondTraceProvider.class); + System.setProperty(TraceProvider.class.getName(), SecondTraceProvider.class.getName()); try { - assertThat(OpenTelemetry.getTracerRegistry()).isInstanceOf(SecondTracerRegistry.class); + assertThat(OpenTelemetry.getTracerRegistry()).isInstanceOf(SecondTraceProvider.class); } finally { serviceFile.delete(); } @@ -125,7 +122,7 @@ public void testTracerSystemProperty() throws IOException { @Test public void testTracerNotFound() { - System.setProperty(TracerRegistryProvider.class.getName(), "io.does.not.exists"); + System.setProperty(TraceProvider.class.getName(), "io.does.not.exists"); thrown.expect(IllegalStateException.class); OpenTelemetry.getTracerRegistry().get("testTracer"); } @@ -134,11 +131,11 @@ public void testTracerNotFound() { public void testMeterLoadArbitrary() throws IOException { File serviceFile = createService( - MeterRegistryProvider.class, FirstMeterRegistry.class, SecondMeterRegistry.class); + MetricsProvider.class, FirstMetricsProvider.class, SecondMetricsProvider.class); try { assertTrue( - (OpenTelemetry.getMeterRegistry() instanceof FirstMeterRegistry) - || (OpenTelemetry.getMeterRegistry() instanceof SecondMeterRegistry)); + (OpenTelemetry.getMeterRegistry() instanceof FirstMetricsProvider) + || (OpenTelemetry.getMeterRegistry() instanceof SecondMetricsProvider)); assertThat(OpenTelemetry.getMeterRegistry()).isEqualTo(OpenTelemetry.getMeterRegistry()); } finally { serviceFile.delete(); @@ -149,10 +146,10 @@ public void testMeterLoadArbitrary() throws IOException { public void testMeterSystemProperty() throws IOException { File serviceFile = createService( - MeterRegistryProvider.class, FirstMeterRegistry.class, SecondMeterRegistry.class); - System.setProperty(MeterRegistryProvider.class.getName(), SecondMeterRegistry.class.getName()); + MetricsProvider.class, FirstMetricsProvider.class, SecondMetricsProvider.class); + System.setProperty(MetricsProvider.class.getName(), SecondMetricsProvider.class.getName()); try { - assertThat(OpenTelemetry.getMeterRegistry()).isInstanceOf(SecondMeterRegistry.class); + assertThat(OpenTelemetry.getMeterRegistry()).isInstanceOf(SecondMetricsProvider.class); assertThat(OpenTelemetry.getMeterRegistry()).isEqualTo(OpenTelemetry.getMeterRegistry()); } finally { serviceFile.delete(); @@ -161,7 +158,7 @@ public void testMeterSystemProperty() throws IOException { @Test public void testMeterNotFound() { - System.setProperty(MeterRegistryProvider.class.getName(), "io.does.not.exists"); + System.setProperty(MetricsProvider.class.getName(), "io.does.not.exists"); thrown.expect(IllegalStateException.class); OpenTelemetry.getMeterRegistry(); } @@ -227,10 +224,10 @@ private static File createService(Class service, Class... impls) throws IO return file; } - public static class SecondTracerRegistry extends FirstTracerRegistry { + public static class SecondTraceProvider extends FirstTraceProvider { @Override public Tracer get(String instrumentationName) { - return new SecondTracerRegistry(); + return new SecondTraceProvider(); } @Override @@ -240,15 +237,14 @@ public Tracer get(String instrumentationName, String instrumentationVersion) { @Override public TracerRegistry create() { - return new SecondTracerRegistry(); + return new SecondTraceProvider(); } } - public static class FirstTracerRegistry - implements Tracer, TracerRegistry, TracerRegistryProvider { + public static class FirstTraceProvider implements Tracer, TracerRegistry, TraceProvider { @Override public Tracer get(String instrumentationName) { - return new FirstTracerRegistry(); + return new FirstTraceProvider(); } @Override @@ -288,14 +284,14 @@ public HttpTextFormat getHttpTextFormat() { @Override public TracerRegistry create() { - return new FirstTracerRegistry(); + return new FirstTraceProvider(); } } - public static class SecondMeterRegistry extends FirstMeterRegistry { + public static class SecondMetricsProvider extends FirstMetricsProvider { @Override public Meter get(String instrumentationName) { - return new SecondMeterRegistry(); + return new SecondMetricsProvider(); } @Override @@ -305,14 +301,14 @@ public Meter get(String instrumentationName, String instrumentationVersion) { @Override public MeterRegistry create() { - return new SecondMeterRegistry(); + return new SecondMetricsProvider(); } } - public static class FirstMeterRegistry implements Meter, MeterRegistryProvider, MeterRegistry { + public static class FirstMetricsProvider implements Meter, MetricsProvider, MeterRegistry { @Override public MeterRegistry create() { - return new FirstMeterRegistry(); + return new FirstMetricsProvider(); } @Nullable @@ -383,7 +379,7 @@ public LabelSet createLabelSet(@Nonnull Map labels) { @Override public Meter get(String instrumentationName) { - return new FirstMeterRegistry(); + return new FirstMetricsProvider(); } @Override diff --git a/sdk/src/main/java/io/opentelemetry/sdk/metrics/MeterSdkRegistryProvider.java b/sdk/src/main/java/io/opentelemetry/sdk/metrics/SdkMetricsProvider.java similarity index 81% rename from sdk/src/main/java/io/opentelemetry/sdk/metrics/MeterSdkRegistryProvider.java rename to sdk/src/main/java/io/opentelemetry/sdk/metrics/SdkMetricsProvider.java index 0af918680ca..8f01e8fe696 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/metrics/MeterSdkRegistryProvider.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/metrics/SdkMetricsProvider.java @@ -17,15 +17,15 @@ package io.opentelemetry.sdk.metrics; import io.opentelemetry.metrics.MeterRegistry; -import io.opentelemetry.metrics.spi.MeterRegistryProvider; +import io.opentelemetry.metrics.spi.MetricsProvider; /** - * {@code MeterRegistry} provider implementation for {@link MeterRegistryProvider}. + * {@code MeterRegistry} provider implementation for {@link MetricsProvider}. * *

This class is not intended to be used in application code and it is used only by {@link * io.opentelemetry.OpenTelemetry}. */ -public class MeterSdkRegistryProvider implements MeterRegistryProvider { +public class SdkMetricsProvider implements MetricsProvider { @Override public MeterRegistry create() { diff --git a/sdk/src/main/java/io/opentelemetry/sdk/trace/TracerSdkRegistryProvider.java b/sdk/src/main/java/io/opentelemetry/sdk/trace/SdkTraceProvider.java similarity index 86% rename from sdk/src/main/java/io/opentelemetry/sdk/trace/TracerSdkRegistryProvider.java rename to sdk/src/main/java/io/opentelemetry/sdk/trace/SdkTraceProvider.java index c0eb39cb262..267bb6ee53b 100644 --- a/sdk/src/main/java/io/opentelemetry/sdk/trace/TracerSdkRegistryProvider.java +++ b/sdk/src/main/java/io/opentelemetry/sdk/trace/SdkTraceProvider.java @@ -17,10 +17,10 @@ package io.opentelemetry.sdk.trace; import io.opentelemetry.trace.TracerRegistry; -import io.opentelemetry.trace.spi.TracerRegistryProvider; +import io.opentelemetry.trace.spi.TraceProvider; /** SDK implementation of the TracerProviderFactory for SPI. */ -public class TracerSdkRegistryProvider implements TracerRegistryProvider { +public class SdkTraceProvider implements TraceProvider { @Override public TracerRegistry create() { return TracerSdkRegistry.builder().build(); diff --git a/sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MeterRegistryProvider b/sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MeterRegistryProvider deleted file mode 100644 index 40b8af609bb..00000000000 --- a/sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MeterRegistryProvider +++ /dev/null @@ -1 +0,0 @@ -io.opentelemetry.sdk.metrics.MeterSdkRegistryProvider diff --git a/sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MetricsProvider b/sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MetricsProvider new file mode 100644 index 00000000000..fbb2daa2f69 --- /dev/null +++ b/sdk/src/main/resources/META-INF/services/io.opentelemetry.metrics.spi.MetricsProvider @@ -0,0 +1 @@ +io.opentelemetry.sdk.metrics.SdkMetricsProvider diff --git a/sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TraceProvider b/sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TraceProvider new file mode 100644 index 00000000000..2fa2cb59c4e --- /dev/null +++ b/sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TraceProvider @@ -0,0 +1 @@ +io.opentelemetry.sdk.trace.SdkTraceProvider diff --git a/sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TracerRegistryProvider b/sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TracerRegistryProvider deleted file mode 100644 index 9913cf7938f..00000000000 --- a/sdk/src/main/resources/META-INF/services/io.opentelemetry.trace.spi.TracerRegistryProvider +++ /dev/null @@ -1 +0,0 @@ -io.opentelemetry.sdk.trace.TracerSdkRegistryProvider diff --git a/sdk/src/test/java/io/opentelemetry/sdk/metrics/MeterSdkProviderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/metrics/MeterSdkProviderTest.java index 32a6b300e18..a71a527941d 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/metrics/MeterSdkProviderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/metrics/MeterSdkProviderTest.java @@ -27,6 +27,6 @@ public class MeterSdkProviderTest { @Test public void testDefault() { - assertThat(new MeterSdkRegistryProvider().create()).isInstanceOf(MeterSdkRegistry.class); + assertThat(new SdkMetricsProvider().create()).isInstanceOf(MeterSdkRegistry.class); } } diff --git a/sdk/src/test/java/io/opentelemetry/sdk/trace/TracerSdkProviderTest.java b/sdk/src/test/java/io/opentelemetry/sdk/trace/TracerSdkProviderTest.java index b32a8318a52..3bf6f886257 100644 --- a/sdk/src/test/java/io/opentelemetry/sdk/trace/TracerSdkProviderTest.java +++ b/sdk/src/test/java/io/opentelemetry/sdk/trace/TracerSdkProviderTest.java @@ -24,7 +24,7 @@ @RunWith(JUnit4.class) public class TracerSdkProviderTest { - private final TracerSdkRegistryProvider tracerFactoryProvider = new TracerSdkRegistryProvider(); + private final SdkTraceProvider tracerFactoryProvider = new SdkTraceProvider(); @Test public void testDefault() {