Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.api.internal;

import static java.util.Objects.requireNonNull;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.AttributeType;
import java.nio.charset.StandardCharsets;
Expand All @@ -25,14 +27,8 @@ public final class InternalAttributeKeyImpl<T> implements AttributeKey<T> {
@Nullable private byte[] keyUtf8;

private InternalAttributeKeyImpl(AttributeType type, String key) {
if (type == null) {
throw new NullPointerException("Null type");
}
this.type = type;
if (key == null) {
throw new NullPointerException("Null key");
}
this.key = key;
this.type = requireNonNull(type, "Null type");
this.key = requireNonNull(key, "Null key");
this.hashCode = buildHashCode(type, key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.opentelemetry.api.logs.LoggerBuilder;
import io.opentelemetry.api.logs.LoggerProvider;

/** A no-op logger provider supporting the incubating logs API. */
public class ExtendedDefaultLoggerProvider implements LoggerProvider {

private static final LoggerProvider INSTANCE = new ExtendedDefaultLoggerProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.opentelemetry.api.trace.TracerProvider;
import javax.annotation.concurrent.ThreadSafe;

/** A no-op tracer provider supporting the incubating tracing API. */
@ThreadSafe
public class ExtendedDefaultTracerProvider implements TracerProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ tasks {
excludedPaths.set(".*/build/generated/.*|.*/internal/shaded/.*")

// Still Java 8
disable("TraditionalJavadocToMarkdown")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a preference to use java 25+ markdown javadoc, which we can't do bc java 8 language level

disable("Varifier")

// Doesn't currently use Var annotations.
Expand Down Expand Up @@ -91,6 +92,8 @@ tasks {
disable("MemberName")
// Internal javadoc not needed for test or jmh classes
disable("OtelInternalJavadoc")
// Javadoc not required for test or jmh classes
disable("MissingJavadoc")
}

option("NullAway:CustomContractAnnotations", "io.opentelemetry.api.internal.Contract")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.Nullable;
import javax.lang.model.element.Modifier;

/** Enforces API stability disclaimers on public types in impl packages. */
@BugPattern(
summary =
"This public impl class is missing the required javadoc disclaimer: \""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.Nullable;
import javax.lang.model.element.Modifier;

/** Enforces API stability disclaimers on public types in internal packages. */
@BugPattern(
summary =
"This public internal class doesn't contain any of the applicable javadoc disclaimers: \""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.google.errorprone.matchers.Description;
import com.sun.source.tree.ClassTree;

/** Enforces private constructors on utility classes, including classes with a main method. */
@BugPattern(
summary =
"Classes which are not intended to be instantiated should be made non-instantiable with a private constructor. This includes utility classes (classes with only static members), and the main class.",
Expand Down
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rootProject.extra["versions"] = dependencyVersions


val autoValueVersion = "1.11.1"
val errorProneVersion = "2.50.0"
val errorProneVersion = "2.51.0"
val jmhVersion = "1.37"
// Mockito 5.x.x requires Java 11 https://github.com/mockito/mockito/releases/tag/v5.0.0
val mockitoVersion = "4.11.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public static void configureOtlpExporterBuilder(
boolean isHttpProtobuf,
Consumer<InternalTelemetryVersion> internalTelemetryVersionConsumer,
Runnable setNoopMeterProvider) {
if (!(baseConfig instanceof ExtendedDeclarativeConfigProperties)) {
throw new IllegalArgumentException("Expected ExtendedDeclarativeConfigProperties");
}
checkArgument(
baseConfig instanceof ExtendedDeclarativeConfigProperties,
"Expected ExtendedDeclarativeConfigProperties");
ExtendedDeclarativeConfigProperties config = (ExtendedDeclarativeConfigProperties) baseConfig;

setComponentLoader.accept(config.getComponentLoader());
Expand Down Expand Up @@ -169,5 +169,11 @@ private static InternalTelemetryVersion getInternalTelemetryVersion(
}
}

private static void checkArgument(boolean isValid, String message) {
if (!isValid) {
throw new IllegalArgumentException(message);
}
}

private OtlpDeclarativeConfigUtil() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
import org.slf4j.event.Level;
import org.slf4j.event.LoggingEvent;

/** Shared OTLP gRPC exporter tests for all telemetry signals. */
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractGrpcTelemetryExporterTest<T, U extends Message> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
import org.slf4j.event.Level;
import org.slf4j.event.LoggingEvent;

/** Shared OTLP HTTP exporter tests for all telemetry signals. */
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class AbstractHttpTelemetryExporterTest<T, U extends Message> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Collections;
import java.util.concurrent.TimeUnit;

/** Creates sample telemetry for OTLP exporter tests. */
public class FakeTelemetryUtil {

private static final String TRACE_ID = "00000000000000000000000000abc123";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Collection;
import java.util.concurrent.TimeUnit;

/** A signal-independent exporter interface for shared OTLP exporter tests. */
public interface TelemetryExporter<T> extends AutoCloseable {

/** Wraps a SpanExporter. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;

/** A signal-independent exporter builder for shared OTLP exporter tests. */
public interface TelemetryExporterBuilder<T> {

static TelemetryExporterBuilder<SpanData> wrap(OtlpGrpcSpanExporterBuilder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ public class UpstreamGrpcSenderProvider implements GrpcSenderProvider {

@Override
public GrpcSender createSender(GrpcSenderConfig grpcSenderConfig) {
if (!(grpcSenderConfig instanceof ExtendedGrpcSenderConfig)) {
throw new IllegalStateException(
"grpcSenderConfig must be an instance of ExtendedGrpcSenderConfig for UpstreamGrpcSenderProvider");
}
checkState(
grpcSenderConfig instanceof ExtendedGrpcSenderConfig,
"grpcSenderConfig must be an instance of ExtendedGrpcSenderConfig for UpstreamGrpcSenderProvider");
ExtendedGrpcSenderConfig extendedSenderConfig = (ExtendedGrpcSenderConfig) grpcSenderConfig;

boolean shutdownChannel = false;
Object configManagedChannel = extendedSenderConfig.getManagedChannel();
ManagedChannel managedChannel;
if (configManagedChannel != null) {
if (!(configManagedChannel instanceof ManagedChannel)) {
throw new IllegalStateException(
"managedChannel must be an instance of ManagedChannel for UpstreamGrpcSenderProvider");
}
checkState(
configManagedChannel instanceof ManagedChannel,
"managedChannel must be an instance of ManagedChannel for UpstreamGrpcSenderProvider");
managedChannel = (ManagedChannel) configManagedChannel;
} else {
// Shutdown the channel as part of the exporter shutdown sequence if we created it.
Expand Down Expand Up @@ -74,4 +72,10 @@ private static ManagedChannel minimalFallbackManagedChannel(URI endpoint) {
}
return channelBuilder.build();
}

private static void checkState(boolean isValid, String message) {
if (!isValid) {
throw new IllegalStateException(message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nullable;

/** HTTP server for the W3C trace context conformance tests. */
public final class Application {
private static final Logger logger = Logger.getLogger(Application.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.List;
import javax.annotation.Nullable;

/** An outbound request in a trace context conformance test, including any nested requests. */
public final class Request {
@Nullable private String url;
@Nullable private List<Request> arguments;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.javadocs;

/** Maven coordinates of an artifact whose Javadoc is crawled. */
public class Artifact {
private final String group;
private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.opentelemetry.sdk.resources.Resource;
import java.util.Collections;

/** Detects entities set from {@code OTEL_ENTITIES} for declarative configuration. */
public class EntitiesEnvResourceDetector implements ComponentProvider {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Collections;
import java.util.UUID;

/** Detects the service name and generates a service instance ID for declarative configuration. */
public class ServiceResourceDetector implements ComponentProvider {

// multiple calls to this resource provider should return the same value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public boolean isStartRequired() {
return false;
}

/** Callback invoked when a span ends. */
@FunctionalInterface
public interface OnEnd {
void apply(ReadableSpan span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public boolean isEndRequired() {
return false;
}

/** Callback invoked when a span starts. */
@FunctionalInterface
public interface OnStart {
void apply(Context context, ReadWriteSpan span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

/** Autoconfiguration provider for the {@code jaeger_remote} sampler. */
public class JaegerRemoteSamplerProvider implements ConfigurableSamplerProvider {

private static final Logger LOGGER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package io.opentelemetry.sdk.metrics.internal.state;

import static java.util.Objects.requireNonNull;

import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -38,9 +40,7 @@ public ArrayBasedStack() {
* @throws NullPointerException if {@code element} is null
*/
public void push(T element) {
if (element == null) {
throw new NullPointerException("Null is not permitted as element in the stack");
}
requireNonNull(element, "Null is not permitted as element in the stack");
if (size == array.length) {
resizeArray(array.length * 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,31 @@ public static AttributeAssertion equalTo(AttributeKey<Long> key, int value) {
// Unique interfaces to prevent generic functional interface clash. These are not interesting at
// all but are required to be able to use the same method name in methods like satisfies above.

/** Assertions on a string attribute value. */
public interface StringAssertConsumer extends Consumer<AbstractStringAssert<?>> {}

/** Assertions on a boolean attribute value. */
public interface BooleanAssertConsumer extends Consumer<AbstractBooleanAssert<?>> {}

/** Assertions on a long attribute value. */
public interface LongAssertConsumer extends Consumer<AbstractLongAssert<?>> {}

/** Assertions on a double attribute value. */
public interface DoubleAssertConsumer extends Consumer<AbstractDoubleAssert<?>> {}

/** Assertions on a string array attribute value. */
public interface StringListAssertConsumer extends Consumer<ListAssert<String>> {}

/** Assertions on a boolean array attribute value. */
public interface BooleanListAssertConsumer extends Consumer<ListAssert<Boolean>> {}

/** Assertions on a long array attribute value. */
public interface LongListAssertConsumer extends Consumer<ListAssert<Long>> {}

/** Assertions on a double array attribute value. */
public interface DoubleListAssertConsumer extends Consumer<ListAssert<Double>> {}

/** Assertions on a structured attribute value. */
public interface ValueAssertConsumer extends Consumer<ObjectAssert<Value<?>>> {}

private static List<Boolean> toList(boolean... values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/** The names of {@link java.util.logging.Logger}s to be suppressed. */
String loggerName() default "";

/** Container for repeated {@link SuppressLogger} annotations. */
@Retention(RetentionPolicy.RUNTIME)
@interface SuppressLoggers {
SuppressLogger[] value();
Expand Down
Loading