Make public src/main classes final where possible. (#2309)
* Make public src/main classes final where possible. * methods * Spot
This commit is contained in:
parent
2866424b90
commit
8a369e3695
|
|
@ -65,7 +65,7 @@ import java.util.stream.Collectors;
|
|||
* > }
|
||||
* }</pre>
|
||||
*/
|
||||
public class StrictContextStorage implements ContextStorage {
|
||||
public final class StrictContextStorage implements ContextStorage {
|
||||
|
||||
/**
|
||||
* Returns a new {@link StrictContextStorage} which delegates to the provided {@link
|
||||
|
|
|
|||
|
|
@ -144,4 +144,9 @@ public final class JaegerThriftSpanExporter implements SpanExporter {
|
|||
// todo
|
||||
return result.succeed();
|
||||
}
|
||||
|
||||
// Visible for testing
|
||||
Process getProcess() {
|
||||
return process;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import io.opentelemetry.sdk.common.export.ConfigBuilder;
|
|||
import java.util.Map;
|
||||
|
||||
/** Builder utility for this exporter. */
|
||||
public class JaegerThriftSpanExporterBuilder
|
||||
public final class JaegerThriftSpanExporterBuilder
|
||||
extends ConfigBuilder<JaegerThriftSpanExporterBuilder> {
|
||||
|
||||
private static final String KEY_SERVICE_NAME = "otel.exporter.jaeger.service.name";
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
|
|
@ -235,14 +234,12 @@ class JaegerThriftSpanExporterTest {
|
|||
void configTest() {
|
||||
Map<String, String> options = new HashMap<>();
|
||||
String serviceName = "myGreatService";
|
||||
String endpoint = "http://127.0.0.1:9090";
|
||||
options.put("otel.exporter.jaeger.service.name", serviceName);
|
||||
options.put("otel.exporter.jaeger.endpoint", endpoint);
|
||||
JaegerThriftSpanExporterBuilder config = JaegerThriftSpanExporter.builder();
|
||||
JaegerThriftSpanExporterBuilder spy = Mockito.spy(config);
|
||||
spy.fromConfigMap(options, ConfigBuilderTest.getNaming()).build();
|
||||
verify(spy).setServiceName(serviceName);
|
||||
verify(spy).setEndpoint(endpoint);
|
||||
JaegerThriftSpanExporter exporter =
|
||||
JaegerThriftSpanExporter.builder()
|
||||
.fromConfigMap(options, ConfigBuilderTest.getNaming())
|
||||
.build();
|
||||
assertThat(exporter.getProcess().getServiceName()).isEqualTo(serviceName);
|
||||
}
|
||||
|
||||
abstract static class ConfigBuilderTest extends ConfigBuilder<ConfigBuilderTest> {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ public final class JaegerGrpcSpanExporter implements SpanExporter {
|
|||
private static final String IP_KEY = "ip";
|
||||
private static final String IP_DEFAULT = "0.0.0.0";
|
||||
private final CollectorServiceGrpc.CollectorServiceFutureStub stub;
|
||||
|
||||
private final Model.Process.Builder processBuilder;
|
||||
private final ManagedChannel managedChannel;
|
||||
private final long deadlineMs;
|
||||
|
|
@ -208,4 +209,14 @@ public final class JaegerGrpcSpanExporter implements SpanExporter {
|
|||
managedChannel.shutdown();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Visible for testing
|
||||
Model.Process.Builder getProcessBuilder() {
|
||||
return processBuilder;
|
||||
}
|
||||
|
||||
// Visible for testing
|
||||
ManagedChannel getManagedChannel() {
|
||||
return managedChannel;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import io.opentelemetry.sdk.common.export.ConfigBuilder;
|
|||
import java.util.Map;
|
||||
|
||||
/** Builder utility for this exporter. */
|
||||
public class JaegerGrpcSpanExporterBuilder extends ConfigBuilder<JaegerGrpcSpanExporterBuilder> {
|
||||
public final class JaegerGrpcSpanExporterBuilder
|
||||
extends ConfigBuilder<JaegerGrpcSpanExporterBuilder> {
|
||||
private static final String KEY_SERVICE_NAME = "otel.exporter.jaeger.service.name";
|
||||
private static final String KEY_ENDPOINT = "otel.exporter.jaeger.endpoint";
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ import org.junit.jupiter.api.BeforeEach;
|
|||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
class JaegerGrpcSpanExporterTest {
|
||||
private static final String TRACE_ID = "00000000000000000000000000abc123";
|
||||
|
|
@ -264,11 +263,12 @@ class JaegerGrpcSpanExporterTest {
|
|||
String endpoint = "127.0.0.1:9090";
|
||||
options.put("otel.exporter.jaeger.service.name", serviceName);
|
||||
options.put("otel.exporter.jaeger.endpoint", endpoint);
|
||||
JaegerGrpcSpanExporterBuilder config = JaegerGrpcSpanExporter.builder();
|
||||
JaegerGrpcSpanExporterBuilder spy = Mockito.spy(config);
|
||||
spy.fromConfigMap(options, ConfigBuilderTest.getNaming()).build();
|
||||
Mockito.verify(spy).setServiceName(serviceName);
|
||||
Mockito.verify(spy).setEndpoint(endpoint);
|
||||
JaegerGrpcSpanExporter exporter =
|
||||
JaegerGrpcSpanExporter.builder()
|
||||
.fromConfigMap(options, ConfigBuilderTest.getNaming())
|
||||
.build();
|
||||
assertThat(exporter.getProcessBuilder().getServiceName()).isEqualTo(serviceName);
|
||||
assertThat(exporter.getManagedChannel().authority()).isEqualTo(endpoint);
|
||||
}
|
||||
|
||||
abstract static class ConfigBuilderTest extends ConfigBuilder<ConfigBuilderTest> {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import java.util.logging.Handler;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class LoggingMetricExporter implements MetricExporter {
|
||||
public final class LoggingMetricExporter implements MetricExporter {
|
||||
private static final Logger logger = Logger.getLogger(LoggingMetricExporter.class.getName());
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
/** A Span Exporter that logs every span at INFO level using java.util.logging. */
|
||||
public class LoggingSpanExporter implements SpanExporter {
|
||||
public final class LoggingSpanExporter implements SpanExporter {
|
||||
private static final Logger logger = Logger.getLogger(LoggingSpanExporter.class.getName());
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ dependencies {
|
|||
libraries.protobuf,
|
||||
libraries.protobuf_util
|
||||
|
||||
testImplementation project(':opentelemetry-sdk-testing')
|
||||
testImplementation project(':opentelemetry-sdk-testing'),
|
||||
'com.linecorp.armeria:armeria-grpc',
|
||||
'com.linecorp.armeria:armeria-junit5'
|
||||
|
||||
testImplementation "io.grpc:grpc-testing:${grpcVersion}"
|
||||
testRuntime "io.grpc:grpc-netty-shaded:${grpcVersion}"
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ public final class OtlpGrpcSpanExporter implements SpanExporter {
|
|||
Labels.of("exporter", EXPORTER_NAME, "success", "false");
|
||||
|
||||
private final TraceServiceFutureStub traceService;
|
||||
|
||||
private final ManagedChannel managedChannel;
|
||||
private final long deadlineMs;
|
||||
private final LongCounter.BoundLongCounter spansSeen;
|
||||
|
|
@ -188,4 +189,9 @@ public final class OtlpGrpcSpanExporter implements SpanExporter {
|
|||
this.spansExportedFailure.unbind();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Visible for testing
|
||||
long getDeadlineMs() {
|
||||
return deadlineMs;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
/** Builder utility for this exporter. */
|
||||
public class OtlpGrpcSpanExporterBuilder extends ConfigBuilder<OtlpGrpcSpanExporterBuilder> {
|
||||
public final class OtlpGrpcSpanExporterBuilder extends ConfigBuilder<OtlpGrpcSpanExporterBuilder> {
|
||||
|
||||
private static final String KEY_TIMEOUT = "otel.exporter.otlp.span.timeout";
|
||||
private static final String KEY_ENDPOINT = "otel.exporter.otlp.span.endpoint";
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.awaitility.Awaitility.await;
|
||||
|
||||
import com.google.common.io.Closer;
|
||||
import com.linecorp.armeria.common.RequestHeaders;
|
||||
import com.linecorp.armeria.server.ServerBuilder;
|
||||
import com.linecorp.armeria.server.ServiceRequestContext;
|
||||
import com.linecorp.armeria.server.grpc.GrpcService;
|
||||
import com.linecorp.armeria.testing.junit5.server.ServerExtension;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.Server;
|
||||
import io.grpc.Status;
|
||||
|
|
@ -17,6 +22,8 @@ import io.grpc.inprocess.InProcessChannelBuilder;
|
|||
import io.grpc.inprocess.InProcessServerBuilder;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import io.opentelemetry.api.trace.Span.Kind;
|
||||
import io.opentelemetry.api.trace.SpanId;
|
||||
import io.opentelemetry.api.trace.TraceId;
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceResponse;
|
||||
import io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc;
|
||||
|
|
@ -26,6 +33,7 @@ import io.opentelemetry.sdk.testing.trace.TestSpanData;
|
|||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -34,9 +42,42 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
class OtlpGrpcSpanExporterTest {
|
||||
|
||||
@RegisterExtension
|
||||
public static ServerExtension server =
|
||||
new ServerExtension() {
|
||||
@Override
|
||||
protected void configure(ServerBuilder sb) throws Exception {
|
||||
sb.service(
|
||||
GrpcService.builder()
|
||||
.addService(
|
||||
new TraceServiceGrpc.TraceServiceImplBase() {
|
||||
@Override
|
||||
public void export(
|
||||
ExportTraceServiceRequest request,
|
||||
StreamObserver<ExportTraceServiceResponse> responseObserver) {
|
||||
RequestHeaders headers =
|
||||
ServiceRequestContext.current().request().headers();
|
||||
if (headers.get("key").equals("value")
|
||||
&& headers.get("key2").equals("value2=")
|
||||
&& headers.get("key3").equals("val=ue3")
|
||||
&& headers.get("key4").equals("value4")
|
||||
&& !headers.contains("key5")) {
|
||||
responseObserver.onNext(
|
||||
ExportTraceServiceResponse.getDefaultInstance());
|
||||
responseObserver.onCompleted();
|
||||
} else {
|
||||
responseObserver.onError(new AssertionError("Invalid metadata"));
|
||||
}
|
||||
}
|
||||
})
|
||||
.build());
|
||||
}
|
||||
};
|
||||
|
||||
private static final String TRACE_ID = "00000000000000000000000000abc123";
|
||||
private static final String SPAN_ID = "0000000000def456";
|
||||
|
||||
|
|
@ -50,23 +91,36 @@ class OtlpGrpcSpanExporterTest {
|
|||
@Test
|
||||
void configTest() {
|
||||
Map<String, String> options = new HashMap<>();
|
||||
options.put("otel.exporter.otlp.span.timeout", "12");
|
||||
options.put("otel.exporter.otlp.span.endpoint", "http://localhost:6553");
|
||||
String endpoint = "localhost:" + server.httpPort();
|
||||
options.put("otel.exporter.otlp.span.timeout", "5124");
|
||||
options.put("otel.exporter.otlp.span.endpoint", endpoint);
|
||||
options.put("otel.exporter.otlp.span.insecure", "true");
|
||||
options.put(
|
||||
"otel.exporter.otlp.span.headers",
|
||||
"key=value;key2=value2=;key3=val=ue3; key4 = value4 ;key5= ");
|
||||
OtlpGrpcSpanExporterBuilder config = OtlpGrpcSpanExporter.builder();
|
||||
OtlpGrpcSpanExporterBuilder spy = Mockito.spy(config);
|
||||
spy.fromConfigMap(options, OtlpGrpcMetricExporterTest.ConfigBuilderTest.getNaming());
|
||||
Mockito.verify(spy).setDeadlineMs(12);
|
||||
Mockito.verify(spy).setEndpoint("http://localhost:6553");
|
||||
Mockito.verify(spy).setUseTls(false);
|
||||
Mockito.verify(spy).addHeader("key", "value");
|
||||
Mockito.verify(spy).addHeader("key2", "value2=");
|
||||
Mockito.verify(spy).addHeader("key3", "val=ue3");
|
||||
Mockito.verify(spy).addHeader("key4", "value4");
|
||||
Mockito.verify(spy, Mockito.never()).addHeader("key5", "");
|
||||
OtlpGrpcSpanExporter exporter =
|
||||
OtlpGrpcSpanExporter.builder()
|
||||
.fromConfigMap(options, OtlpGrpcMetricExporterTest.ConfigBuilderTest.getNaming())
|
||||
.build();
|
||||
|
||||
assertThat(exporter.getDeadlineMs()).isEqualTo(5124);
|
||||
assertThat(
|
||||
exporter
|
||||
.export(
|
||||
Arrays.asList(
|
||||
TestSpanData.builder()
|
||||
.setTraceId(TraceId.getInvalid())
|
||||
.setSpanId(SpanId.getInvalid())
|
||||
.setName("name")
|
||||
.setKind(Kind.CLIENT)
|
||||
.setStartEpochNanos(1)
|
||||
.setEndEpochNanos(2)
|
||||
.setStatus(SpanData.Status.ok())
|
||||
.setHasEnded(true)
|
||||
.build()))
|
||||
.join(10, TimeUnit.SECONDS)
|
||||
.isSuccess())
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import javax.annotation.Nullable;
|
|||
* .build());
|
||||
* }</pre>
|
||||
*/
|
||||
public class AwsXRayPropagator implements TextMapPropagator {
|
||||
public final class AwsXRayPropagator implements TextMapPropagator {
|
||||
|
||||
// Visible for testing
|
||||
static final String TRACE_HEADER_KEY = "X-Amzn-Trace-Id";
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
* }</pre>
|
||||
*/
|
||||
@Immutable
|
||||
public class B3Propagator implements TextMapPropagator {
|
||||
public final class B3Propagator implements TextMapPropagator {
|
||||
static final String TRACE_ID_HEADER = "X-B3-TraceId";
|
||||
static final String SPAN_ID_HEADER = "X-B3-SpanId";
|
||||
static final String SAMPLED_HEADER = "X-B3-Sampled";
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
* Format</a>.
|
||||
*/
|
||||
@Immutable
|
||||
public class JaegerPropagator implements TextMapPropagator {
|
||||
public final class JaegerPropagator implements TextMapPropagator {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JaegerPropagator.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
* TextMapPropagator</a>.
|
||||
*/
|
||||
@Immutable
|
||||
public class OtTracerPropagator implements TextMapPropagator {
|
||||
public final class OtTracerPropagator implements TextMapPropagator {
|
||||
|
||||
static final String TRACE_ID_HEADER = "ot-tracer-traceid";
|
||||
static final String SPAN_ID_HEADER = "ot-tracer-spanid";
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import javax.annotation.concurrent.Immutable;
|
|||
* }</pre>
|
||||
*/
|
||||
@Immutable
|
||||
public class TraceMultiPropagator implements TextMapPropagator {
|
||||
public final class TraceMultiPropagator implements TextMapPropagator {
|
||||
|
||||
/** Returns a {@link TraceMultiPropagator} for the given {@code propagators}. */
|
||||
public static TextMapPropagator create(TextMapPropagator... propagators) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.logging.Logger;
|
|||
* A {@link ResourceProvider} which provides information about the current EC2 instance if running
|
||||
* on AWS Elastic Beanstalk.
|
||||
*/
|
||||
public class BeanstalkResource extends ResourceProvider {
|
||||
public final class BeanstalkResource extends ResourceProvider {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(BeanstalkResource.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import javax.annotation.Nullable;
|
|||
* A {@link ResourceProvider} which provides information about the current EC2 instance if running
|
||||
* on AWS EC2.
|
||||
*/
|
||||
public class Ec2Resource extends ResourceProvider {
|
||||
public final class Ec2Resource extends ResourceProvider {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Ec2Resource.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import java.util.logging.Logger;
|
|||
* A {@link ResourceProvider} which provides information about the current ECS container if running
|
||||
* on AWS ECS.
|
||||
*/
|
||||
public class EcsResource extends ResourceProvider {
|
||||
public final class EcsResource extends ResourceProvider {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(EcsResource.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class EksResource extends ResourceProvider {
|
||||
public final class EksResource extends ResourceProvider {
|
||||
|
||||
static final String K8S_SVC_URL = "https://kubernetes.default.svc";
|
||||
static final String AUTH_CONFIGMAP_PATH = "/api/v1/namespaces/kube-system/configmaps/aws-auth";
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* href="https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids">Generating
|
||||
* Trace IDs</a>
|
||||
*/
|
||||
public class AwsXrayIdGenerator implements IdGenerator {
|
||||
public final class AwsXrayIdGenerator implements IdGenerator {
|
||||
|
||||
private static final IdGenerator RANDOM_ID_GENERATOR = IdGenerator.random();
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
/** Remote sampler that gets sampling configuration from remote Jaeger server. */
|
||||
public class JaegerRemoteSampler implements Sampler {
|
||||
public final class JaegerRemoteSampler implements Sampler {
|
||||
private static final Logger logger = Logger.getLogger(JaegerRemoteSampler.class.getName());
|
||||
|
||||
private static final String WORKER_THREAD_NAME =
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import io.opentelemetry.context.Context;
|
|||
import io.opentelemetry.context.ContextStorage;
|
||||
import io.opentelemetry.context.Scope;
|
||||
|
||||
public class JfrContextStorageWrapper implements ContextStorage {
|
||||
public final class JfrContextStorageWrapper implements ContextStorage {
|
||||
|
||||
private final ContextStorage wrapped;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import io.opentelemetry.sdk.trace.SpanProcessor;
|
|||
* other SpanProcessor which may affect timings. When possible, register it first before any other
|
||||
* processors to allow the most accurate measurements.
|
||||
*/
|
||||
public class JfrSpanProcessor implements SpanProcessor {
|
||||
public final class JfrSpanProcessor implements SpanProcessor {
|
||||
|
||||
private final WeakConcurrentMap<SpanContext, SpanEvent> spanEvents =
|
||||
new WeakConcurrentMap.WithInlinedExpunction<>();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LogSinkSdkProvider {
|
||||
public final class LogSinkSdkProvider {
|
||||
private final LogSink logSink = new SdkLogSink();
|
||||
private final List<LogProcessor> processors = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.BlockingQueue;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class BatchLogProcessor implements LogProcessor {
|
||||
public final class BatchLogProcessor implements LogProcessor {
|
||||
private static final String WORKER_THREAD_NAME =
|
||||
BatchLogProcessor.class.getSimpleName() + "_WorkerThread";
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import io.opentelemetry.sdk.resources.ResourceProvider;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
/** {@link ResourceProvider} which provides information about the current operating system. */
|
||||
public class OsResource extends ResourceProvider {
|
||||
public final class OsResource extends ResourceProvider {
|
||||
|
||||
@Override
|
||||
protected Attributes getAttributes() {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.lang.management.ManagementFactory;
|
|||
import java.lang.management.RuntimeMXBean;
|
||||
|
||||
/** {@link ResourceProvider} which provides information about the current running process. */
|
||||
public class ProcessResource extends ResourceProvider {
|
||||
public final class ProcessResource extends ResourceProvider {
|
||||
@Override
|
||||
protected Attributes getAttributes() {
|
||||
AttributesBuilder attributes = Attributes.builder();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import io.opentelemetry.spi.OpenTelemetryFactory;
|
|||
* Factory SPI implementation to register a {@link OpenTelemetrySdk} as the default {@link
|
||||
* OpenTelemetry}.
|
||||
*/
|
||||
public class OpenTelemetrySdkFactory implements OpenTelemetryFactory {
|
||||
public final class OpenTelemetrySdkFactory implements OpenTelemetryFactory {
|
||||
@Override
|
||||
public OpenTelemetry create() {
|
||||
return OpenTelemetrySdk.builder().build();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import javax.annotation.concurrent.GuardedBy;
|
|||
* <p>The implementation of Export operations are often asynchronous in nature, hence the need to
|
||||
* convey a result at a later time. CompletableResultCode facilitates this.
|
||||
*/
|
||||
public class CompletableResultCode {
|
||||
public final class CompletableResultCode {
|
||||
/** Returns a {@link CompletableResultCode} that has been completed successfully. */
|
||||
public static CompletableResultCode ofSuccess() {
|
||||
return SUCCESS;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
* A {@link ThreadFactory} that delegates to {@code Executors.defaultThreadFactory()} and marks all
|
||||
* threads as daemon.
|
||||
*/
|
||||
public class DaemonThreadFactory implements ThreadFactory {
|
||||
public final class DaemonThreadFactory implements ThreadFactory {
|
||||
private final String namePrefix;
|
||||
private final AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
|||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
public class Aggregations {
|
||||
public final class Aggregations {
|
||||
|
||||
/**
|
||||
* Returns an {@code Aggregation} that calculates sum of recorded measurements.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
import java.util.ServiceLoader;
|
||||
|
||||
/** A {@link ContextStorageProvider} which can have it's {@link ContextStorage} set at any time. */
|
||||
public class SettableContextStorageProvider implements ContextStorageProvider {
|
||||
public final class SettableContextStorageProvider implements ContextStorageProvider {
|
||||
@Override
|
||||
public ContextStorage get() {
|
||||
return SettableContextStorage.INSTANCE;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import java.util.concurrent.LinkedBlockingQueue;
|
|||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
public class InMemoryMetricExporter implements MetricExporter {
|
||||
public final class InMemoryMetricExporter implements MetricExporter {
|
||||
|
||||
// using LinkedBlockingQueue to avoid manual locks for thread-safe operations
|
||||
private final Queue<MetricData> finishedMetricItems = new LinkedBlockingQueue<>();
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.junit.rules.ExternalResource;
|
|||
* > }
|
||||
* }</pre>
|
||||
*/
|
||||
public class OpenTelemetryRule extends ExternalResource {
|
||||
public final class OpenTelemetryRule extends ExternalResource {
|
||||
|
||||
/**
|
||||
* Returns a {@link OpenTelemetryRule} with a default SDK initialized with an in-memory span
|
||||
|
|
@ -97,7 +97,7 @@ public class OpenTelemetryRule extends ExternalResource {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void before() throws Throwable {
|
||||
protected void before() {
|
||||
previousGlobalOpenTelemetry = GlobalOpenTelemetry.get();
|
||||
GlobalOpenTelemetry.set(openTelemetry);
|
||||
clearSpans();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import org.junit.jupiter.api.extension.ExtensionContext;
|
|||
* > }
|
||||
* }</pre>
|
||||
*/
|
||||
public class OpenTelemetryExtension
|
||||
public final class OpenTelemetryExtension
|
||||
implements BeforeEachCallback, BeforeAllCallback, AfterAllCallback {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
|||
* OpenTelemetry}. However, if you need a custom implementation of the factory, you can create one
|
||||
* as needed.
|
||||
*/
|
||||
public class SdkTracerProvider implements TracerProvider, SdkTracerManagement {
|
||||
public final class SdkTracerProvider implements TracerProvider, SdkTracerManagement {
|
||||
private static final Logger logger = Logger.getLogger(SdkTracerProvider.class.getName());
|
||||
static final String DEFAULT_TRACER_NAME = "unknown";
|
||||
private final TracerSharedState sharedState;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
|
||||
/** Builder for {@link TraceConfig}. */
|
||||
public class TraceConfigBuilder extends ConfigBuilder<TraceConfigBuilder> {
|
||||
public final class TraceConfigBuilder extends ConfigBuilder<TraceConfigBuilder> {
|
||||
private static final String KEY_SAMPLER_PROBABILITY = "otel.config.sampler.probability";
|
||||
private static final String KEY_SPAN_ATTRIBUTE_COUNT_LIMIT = "otel.span.attribute.count.limit";
|
||||
private static final String KEY_SPAN_EVENT_COUNT_LIMIT = "otel.span.event.count.limit";
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
package io.opentelemetry.sdk.trace.samplers;
|
||||
|
||||
/** A builder for creating ParentBased sampler instances. */
|
||||
public class ParentBasedSamplerBuilder {
|
||||
public final class ParentBasedSamplerBuilder {
|
||||
|
||||
private final Sampler root;
|
||||
private Sampler remoteParentSampled;
|
||||
|
|
|
|||
Loading…
Reference in New Issue