Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename TracerRegistry -> Tracer Provider #879

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions api/src/main/java/io/opentelemetry/OpenTelemetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import io.opentelemetry.metrics.MeterProvider;
import io.opentelemetry.metrics.spi.MetricsProvider;
import io.opentelemetry.trace.DefaultTraceProvider;
import io.opentelemetry.trace.DefaultTracerRegistry;
import io.opentelemetry.trace.DefaultTracerProvider;
import io.opentelemetry.trace.Tracer;
import io.opentelemetry.trace.TracerRegistry;
import io.opentelemetry.trace.TracerProvider;
import io.opentelemetry.trace.spi.TraceProvider;
import java.util.ServiceLoader;
import javax.annotation.Nullable;
Expand All @@ -39,7 +39,7 @@
*
* <p>The telemetry objects are lazy-loaded singletons resolved via {@link ServiceLoader} mechanism.
*
* @see TracerRegistry
* @see TracerProvider
* @see MetricsProvider
* @see CorrelationContextManagerProvider
*/
Expand All @@ -48,20 +48,20 @@ public final class OpenTelemetry {

@Nullable private static volatile OpenTelemetry instance;

private final TracerRegistry tracerRegistry;
private final TracerProvider tracerProvider;
private final MeterProvider meterProvider;
private final CorrelationContextManager contextManager;

/**
* Returns a singleton {@link TracerRegistry}.
* Returns a singleton {@link TracerProvider}.
*
* @return registered TracerRegistry of default via {@link DefaultTracerRegistry#getInstance()}.
* @throws IllegalStateException if a specified TracerRegistry (via system properties) could not
* @return registered TracerProvider of default via {@link DefaultTracerProvider#getInstance()}.
* @throws IllegalStateException if a specified TracerProvider (via system properties) could not
* be found.
* @since 0.1.0
*/
public static TracerRegistry getTracerRegistry() {
return getInstance().tracerRegistry;
public static TracerProvider getTracerRegistry() {
return getInstance().tracerProvider;
}

/**
Expand Down Expand Up @@ -103,7 +103,7 @@ private static OpenTelemetry getInstance() {

private OpenTelemetry() {
TraceProvider traceProvider = loadSpi(TraceProvider.class);
this.tracerRegistry =
this.tracerProvider =
traceProvider != null
? traceProvider.create()
: DefaultTraceProvider.getInstance().create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static TraceProvider getInstance() {
}

@Override
public TracerRegistry create() {
return DefaultTracerRegistry.getInstance();
public TracerProvider create() {
return DefaultTracerProvider.getInstance();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package io.opentelemetry.trace;

public class DefaultTracerRegistry implements TracerRegistry {
public class DefaultTracerProvider implements TracerProvider {

private static final TracerRegistry instance = new DefaultTracerRegistry();
private static final TracerProvider instance = new DefaultTracerProvider();

public static TracerRegistry getInstance() {
public static TracerProvider getInstance() {
return instance;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
import javax.annotation.concurrent.ThreadSafe;

/**
* A registry for creating named {@link Tracer}s.
* A registry for creating named {@link Tracer}s. Although the class is provided at runtime via
* {@link io.opentelemetry.trace.spi.TraceProvider}, the name <i>Provider</i> is for consistency
* with other languages.
*
* @see io.opentelemetry.OpenTelemetry
* @see io.opentelemetry.trace.Tracer
* @since 0.1.0
*/
@ThreadSafe
public interface TracerRegistry {
public interface TracerProvider {
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved

/**
* Gets or creates a named tracer instance.
Expand Down
16 changes: 8 additions & 8 deletions api/src/main/java/io/opentelemetry/trace/spi/TraceProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@

package io.opentelemetry.trace.spi;

import io.opentelemetry.trace.TracerRegistry;
import io.opentelemetry.trace.TracerProvider;
import javax.annotation.concurrent.ThreadSafe;

/**
* TracerRegistryProvider is a service provider for a {@link TracerRegistry}. Fully qualified class
* name of the implementation should be registered in {@code
* META-INF/services/io.opentelemetry.trace.spi.TracerRegistryProvider}. <br>
* TracerProvider is a service provider for a {@link TracerProvider}. Fully qualified class name of
* the implementation should be registered in {@code
* META-INF/services/io.opentelemetry.trace.spi.TracerProvider}. <br>
* <br>
* A specific implementation can be selected by a system property {@code
* io.opentelemetry.trace.spi.TracerRegistryProvider} with value of fully qualified class name.
* io.opentelemetry.trace.spi.TracerProvider} with value of fully qualified class name.
*
* @see io.opentelemetry.OpenTelemetry
*/
@ThreadSafe
public interface TraceProvider {

/**
* Creates a new TracerRegistry.
* Creates a new TracerProvider.
*
* @return a new TracerRegistry.
* @return a new TracerProvider.
* @since 0.1.0
*/
TracerRegistry create();
TracerProvider create();
}
8 changes: 4 additions & 4 deletions api/src/test/java/io/opentelemetry/OpenTelemetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.SpanContext;
import io.opentelemetry.trace.Tracer;
import io.opentelemetry.trace.TracerRegistry;
import io.opentelemetry.trace.TracerProvider;
import io.opentelemetry.trace.spi.TraceProvider;
import java.io.File;
import java.io.FileWriter;
Expand Down Expand Up @@ -234,12 +234,12 @@ public Tracer get(String instrumentationName, String instrumentationVersion) {
}

@Override
public TracerRegistry create() {
public TracerProvider create() {
return new SecondTraceProvider();
}
}

public static class FirstTraceProvider implements Tracer, TracerRegistry, TraceProvider {
public static class FirstTraceProvider implements Tracer, TracerProvider, TraceProvider {
@Override
public Tracer get(String instrumentationName) {
return new FirstTraceProvider();
Expand Down Expand Up @@ -281,7 +281,7 @@ public HttpTextFormat<SpanContext> getHttpTextFormat() {
}

@Override
public TracerRegistry create() {
public TracerProvider create() {
return new FirstTraceProvider();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package io.opentelemetry.exporters.inmemory;

import io.opentelemetry.internal.Utils;
import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
import java.util.List;
Expand All @@ -44,7 +44,7 @@
* @since 0.1.0
*/
public final class InMemoryTracing {
private final TracerSdkRegistry tracerSdkRegistry;
private final TracerSdkProvider tracerSdkProvider;
private final InMemorySpanExporter exporter;

/**
Expand All @@ -53,22 +53,22 @@ public final class InMemoryTracing {
* @since 0.1.0
*/
public InMemoryTracing() {
this(TracerSdkRegistry.builder().build());
this(TracerSdkProvider.builder().build());
}

/**
* Creates a new {@code InMemoryTracing} with the specified {@code TracerSdk}.
*
* @param tracerSdkRegistry the {@code TracerSdkRegistry} to be used.
* @param tracerSdkProvider the {@code TracerSdkProvider} to be used.
* @throws NullPointerException if {@code tracer} is {@code null}.
* @since 0.1.0
*/
public InMemoryTracing(TracerSdkRegistry tracerSdkRegistry) {
Utils.checkNotNull(tracerSdkRegistry, "tracerSdkFactory");
public InMemoryTracing(TracerSdkProvider tracerSdkProvider) {
Utils.checkNotNull(tracerSdkProvider, "tracerSdkFactory");

this.tracerSdkRegistry = tracerSdkRegistry;
this.tracerSdkProvider = tracerSdkProvider;
this.exporter = InMemorySpanExporter.create();
tracerSdkRegistry.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build());
tracerSdkProvider.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build());
}

/**
Expand All @@ -78,8 +78,8 @@ public InMemoryTracing(TracerSdkRegistry tracerSdkRegistry) {
* @return the {@code Tracer} to be used to create {@code Span}s.
* @since 0.1.0
*/
public TracerSdkRegistry getTracerRegistry() {
return tracerSdkRegistry;
public TracerSdkProvider getTracerRegistry() {
return tracerSdkProvider;
}

/**
Expand Down Expand Up @@ -108,6 +108,6 @@ public List<SpanData> getFinishedSpanItems() {
* @since 0.1.0
*/
public void shutdown() {
tracerSdkRegistry.shutdown();
tracerSdkProvider.shutdown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static com.google.common.truth.Truth.assertThat;

import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
import io.opentelemetry.sdk.trace.export.SpanExporter.ResultCode;
Expand All @@ -33,13 +33,13 @@
/** Unit tests for {@link InMemorySpanExporter}. */
@RunWith(JUnit4.class)
public class InMemorySpanExporterTest {
private final TracerSdkRegistry tracerSdkRegistry = TracerSdkRegistry.builder().build();
private final Tracer tracer = tracerSdkRegistry.get("InMemorySpanExporterTest");
private final TracerSdkProvider tracerSdkProvider = TracerSdkProvider.builder().build();
private final Tracer tracer = tracerSdkProvider.get("InMemorySpanExporterTest");
private final InMemorySpanExporter exporter = InMemorySpanExporter.create();

@Before
public void setup() {
tracerSdkRegistry.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build());
tracerSdkProvider.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static com.google.common.truth.Truth.assertThat;

import io.opentelemetry.sdk.trace.Samplers;
import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.sdk.trace.config.TraceConfig;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.trace.Tracer;
Expand All @@ -45,7 +45,7 @@ public void defaultFinishedSpanItems() {

@Test
public void ctor_tracer() {
TracerSdkRegistry tracerSdkFactory = TracerSdkRegistry.builder().build();
TracerSdkProvider tracerSdkFactory = TracerSdkProvider.builder().build();
InMemoryTracing tracing = new InMemoryTracing(tracerSdkFactory);
assertThat(tracing.getTracerRegistry()).isSameInstanceAs(tracerSdkFactory);
}
Expand All @@ -69,7 +69,7 @@ public void getFinishedSpanItems() {
@Test
public void getFinishedSpanItems_sampled() {
tracer.spanBuilder("A").startSpan().end();
TracerSdkRegistry tracerSdkFactory = tracing.getTracerRegistry();
TracerSdkProvider tracerSdkFactory = tracing.getTracerRegistry();
TraceConfig originalConfig = tracerSdkFactory.getActiveTraceConfig();
tracerSdkFactory.updateActiveTraceConfig(
originalConfig.toBuilder().setSampler(Samplers.alwaysOff()).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.opentelemetry.correlationcontext.CorrelationContextManager;
import io.opentelemetry.internal.Utils;
import io.opentelemetry.trace.Tracer;
import io.opentelemetry.trace.TracerRegistry;
import io.opentelemetry.trace.TracerProvider;

public final class TraceShim {
private TraceShim() {}
Expand All @@ -43,19 +43,19 @@ public static io.opentracing.Tracer createTracerShim() {
* Creates a {@code io.opentracing.Tracer} shim out the specified {@code Tracer} and {@code
* CorrelationContextManager}.
*
* @param tracerRegistry the {@code TracerRegistry} used by this shim.
* @param tracerProvider the {@code TracerProvider} used by this shim.
* @param contextManager the {@code CorrelationContextManager} used by this shim.
* @return a {@code io.opentracing.Tracer}.
* @since 0.1.0
*/
public static io.opentracing.Tracer createTracerShim(
TracerRegistry tracerRegistry, CorrelationContextManager contextManager) {
Utils.checkNotNull(tracerRegistry, "tracerRegistry");
TracerProvider tracerProvider, CorrelationContextManager contextManager) {
Utils.checkNotNull(tracerProvider, "tracerProvider");
Utils.checkNotNull(contextManager, "contextManager");
return new TracerShim(new TelemetryInfo(getTracer(tracerRegistry), contextManager));
return new TracerShim(new TelemetryInfo(getTracer(tracerProvider), contextManager));
}

private static Tracer getTracer(TracerRegistry tracerRegistry) {
return tracerRegistry.get("opentracingshim");
private static Tracer getTracer(TracerProvider tracerProvider) {
return tracerProvider.get("opentracingshim");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import static org.junit.Assert.assertFalse;

import io.opentelemetry.sdk.correlationcontext.CorrelationContextManagerSdk;
import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.trace.Tracer;
import org.junit.Test;

public class SpanBuilderShimTest {
private final TracerSdkRegistry tracerSdkFactory = TracerSdkRegistry.builder().build();
private final TracerSdkProvider tracerSdkFactory = TracerSdkProvider.builder().build();
private final Tracer tracer = tracerSdkFactory.get("SpanShimTest");
private final TelemetryInfo telemetryInfo =
new TelemetryInfo(tracer, new CorrelationContextManagerSdk());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
import static org.junit.Assert.assertTrue;

import io.opentelemetry.sdk.correlationcontext.CorrelationContextManagerSdk;
import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.trace.Tracer;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SpanShimTest {
private final TracerSdkRegistry tracerSdkFactory = TracerSdkRegistry.builder().build();
private final TracerSdkProvider tracerSdkFactory = TracerSdkProvider.builder().build();
private final Tracer tracer = tracerSdkFactory.get("SpanShimTest");
private final TelemetryInfo telemetryInfo =
new TelemetryInfo(tracer, new CorrelationContextManagerSdk());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.sdk.correlationcontext.CorrelationContextManagerSdk;
import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import org.junit.Test;

public class TraceShimTest {
Expand All @@ -44,7 +44,7 @@ public void createTracerShim_nullContextManager() {

@Test
public void createTracerShim() {
TracerSdkRegistry sdk = TracerSdkRegistry.builder().build();
TracerSdkProvider sdk = TracerSdkProvider.builder().build();
CorrelationContextManagerSdk contextManager = new CorrelationContextManagerSdk();
TracerShim tracerShim = (TracerShim) TraceShim.createTracerShim(sdk, contextManager);
assertEquals(sdk.get("opentracingshim"), tracerShim.tracer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.opentelemetry.correlationcontext.DefaultCorrelationContextManager;
import io.opentelemetry.exporters.inmemory.InMemorySpanExporter;
import io.opentelemetry.opentracingshim.TraceShim;
import io.opentelemetry.sdk.trace.TracerSdkRegistry;
import io.opentelemetry.sdk.trace.TracerSdkProvider;
import io.opentelemetry.sdk.trace.data.SpanData;
import io.opentelemetry.sdk.trace.export.SimpleSpansProcessor;
import io.opentelemetry.trace.DefaultSpan;
Expand All @@ -34,7 +34,7 @@
import org.junit.Test;

public class OpenTelemetryInteroperabilityTest {
private final TracerSdkRegistry sdk = TracerSdkRegistry.builder().build();
private final TracerSdkProvider sdk = TracerSdkProvider.builder().build();
private final io.opentelemetry.trace.Tracer tracer = sdk.get("opentracingshim");
private final InMemorySpanExporter spanExporter = InMemorySpanExporter.create();
private final Tracer otTracer =
Expand Down
Loading