Update errorprone (#4346)
This commit is contained in:
parent
0ac1d8e6d7
commit
d78cadabaa
|
|
@ -40,6 +40,8 @@ import javax.annotation.concurrent.ThreadSafe;
|
||||||
* @see TracerProvider
|
* @see TracerProvider
|
||||||
* @see ContextPropagators
|
* @see ContextPropagators
|
||||||
*/
|
*/
|
||||||
|
// We intentionally assign to be use for error reporting.
|
||||||
|
@SuppressWarnings("StaticAssignmentOfThrowable")
|
||||||
public final class GlobalOpenTelemetry {
|
public final class GlobalOpenTelemetry {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(GlobalOpenTelemetry.class.getName());
|
private static final Logger logger = Logger.getLogger(GlobalOpenTelemetry.class.getName());
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,9 @@ tasks {
|
||||||
disableWarningsInGeneratedCode.set(true)
|
disableWarningsInGeneratedCode.set(true)
|
||||||
allDisabledChecksAsWarnings.set(true)
|
allDisabledChecksAsWarnings.set(true)
|
||||||
|
|
||||||
|
// Still Java 8
|
||||||
|
disable("Varifier")
|
||||||
|
|
||||||
// Doesn't currently use Var annotations.
|
// Doesn't currently use Var annotations.
|
||||||
disable("Var") // "-Xep:Var:OFF"
|
disable("Var") // "-Xep:Var:OFF"
|
||||||
|
|
||||||
|
|
@ -49,7 +52,6 @@ tasks {
|
||||||
disable("StaticOrDefaultInterfaceMethod")
|
disable("StaticOrDefaultInterfaceMethod")
|
||||||
|
|
||||||
// Limits APIs
|
// Limits APIs
|
||||||
disable("NoFunctionalReturnType")
|
|
||||||
disable("PreferredInterfaceType")
|
disable("PreferredInterfaceType")
|
||||||
|
|
||||||
// We don't depend on Guava so use normal splitting
|
// We don't depend on Guava so use normal splitting
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ val DEPENDENCY_SETS = listOf(
|
||||||
),
|
),
|
||||||
DependencySet(
|
DependencySet(
|
||||||
"com.google.errorprone",
|
"com.google.errorprone",
|
||||||
"2.11.0",
|
"2.12.1",
|
||||||
listOf("error_prone_annotations", "error_prone_core")
|
listOf("error_prone_annotations", "error_prone_core")
|
||||||
),
|
),
|
||||||
DependencySet(
|
DependencySet(
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ import java.io.OutputStream;
|
||||||
// - No support for writing fields with tag, we alway write tags separately
|
// - No support for writing fields with tag, we alway write tags separately
|
||||||
// - Allow resetting and use a ThreadLocal instance
|
// - Allow resetting and use a ThreadLocal instance
|
||||||
//
|
//
|
||||||
@SuppressWarnings({"UnnecessaryFinal", "UngroupedOverloads", "InlineMeSuggester"})
|
@SuppressWarnings({"UnnecessaryFinal", "UngroupedOverloads", "InlineMeSuggester", "UnusedVariable"})
|
||||||
public abstract class CodedOutputStream {
|
public abstract class CodedOutputStream {
|
||||||
|
|
||||||
/** The buffer size used in {@link #newInstance(OutputStream)}. */
|
/** The buffer size used in {@link #newInstance(OutputStream)}. */
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ final class MetricAdapter {
|
||||||
name,
|
name,
|
||||||
labelNames,
|
labelNames,
|
||||||
labelValues,
|
labelValues,
|
||||||
longPoint.getValue(),
|
(double) longPoint.getValue(),
|
||||||
// Prometheus doesn't support exemplars on SUM/GAUGE
|
// Prometheus doesn't support exemplars on SUM/GAUGE
|
||||||
null,
|
null,
|
||||||
longPoint.getEpochNanos()));
|
longPoint.getEpochNanos()));
|
||||||
|
|
@ -171,7 +171,7 @@ final class MetricAdapter {
|
||||||
name + SAMPLE_SUFFIX_COUNT,
|
name + SAMPLE_SUFFIX_COUNT,
|
||||||
labelNames,
|
labelNames,
|
||||||
labelValues,
|
labelValues,
|
||||||
doubleSummaryPoint.getCount(),
|
(double) doubleSummaryPoint.getCount(),
|
||||||
null,
|
null,
|
||||||
doubleSummaryPoint.getEpochNanos()));
|
doubleSummaryPoint.getEpochNanos()));
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ final class MetricAdapter {
|
||||||
name + SAMPLE_SUFFIX_COUNT,
|
name + SAMPLE_SUFFIX_COUNT,
|
||||||
labelNames,
|
labelNames,
|
||||||
labelValues,
|
labelValues,
|
||||||
histogramPointData.getCount(),
|
(double) histogramPointData.getCount(),
|
||||||
null,
|
null,
|
||||||
histogramPointData.getEpochNanos()));
|
histogramPointData.getEpochNanos()));
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ final class MetricAdapter {
|
||||||
name + SAMPLE_SUFFIX_BUCKET,
|
name + SAMPLE_SUFFIX_BUCKET,
|
||||||
labelNamesWithLe,
|
labelNamesWithLe,
|
||||||
labelValuesWithLe,
|
labelValuesWithLe,
|
||||||
cumulativeCount,
|
(double) cumulativeCount,
|
||||||
filterExemplars(
|
filterExemplars(
|
||||||
histogramPointData.getExemplars(),
|
histogramPointData.getExemplars(),
|
||||||
Serializer.getBucketLowerBound(histogramPointData, i),
|
Serializer.getBucketLowerBound(histogramPointData, i),
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ abstract class Serializer {
|
||||||
writePoint(
|
writePoint(
|
||||||
writer,
|
writer,
|
||||||
name,
|
name,
|
||||||
((LongPointData) point).getValue(),
|
(double) ((LongPointData) point).getValue(),
|
||||||
point.getAttributes(),
|
point.getAttributes(),
|
||||||
point.getEpochNanos());
|
point.getEpochNanos());
|
||||||
break;
|
break;
|
||||||
|
|
@ -164,7 +164,11 @@ abstract class Serializer {
|
||||||
private void writeHistogram(Writer writer, String name, HistogramPointData point)
|
private void writeHistogram(Writer writer, String name, HistogramPointData point)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
writePoint(
|
writePoint(
|
||||||
writer, name + "_count", point.getCount(), point.getAttributes(), point.getEpochNanos());
|
writer,
|
||||||
|
name + "_count",
|
||||||
|
(double) point.getCount(),
|
||||||
|
point.getAttributes(),
|
||||||
|
point.getEpochNanos());
|
||||||
writePoint(writer, name + "_sum", point.getSum(), point.getAttributes(), point.getEpochNanos());
|
writePoint(writer, name + "_sum", point.getSum(), point.getAttributes(), point.getEpochNanos());
|
||||||
|
|
||||||
long cumulativeCount = 0;
|
long cumulativeCount = 0;
|
||||||
|
|
@ -178,7 +182,7 @@ abstract class Serializer {
|
||||||
writePoint(
|
writePoint(
|
||||||
writer,
|
writer,
|
||||||
name + "_bucket",
|
name + "_bucket",
|
||||||
cumulativeCount,
|
(double) cumulativeCount,
|
||||||
point.getAttributes(),
|
point.getAttributes(),
|
||||||
point.getEpochNanos(),
|
point.getEpochNanos(),
|
||||||
"le",
|
"le",
|
||||||
|
|
@ -212,7 +216,11 @@ abstract class Serializer {
|
||||||
|
|
||||||
private void writeSummary(Writer writer, String name, SummaryPointData point) throws IOException {
|
private void writeSummary(Writer writer, String name, SummaryPointData point) throws IOException {
|
||||||
writePoint(
|
writePoint(
|
||||||
writer, name + "_count", point.getCount(), point.getAttributes(), point.getEpochNanos());
|
writer,
|
||||||
|
name + "_count",
|
||||||
|
(double) point.getCount(),
|
||||||
|
point.getAttributes(),
|
||||||
|
point.getEpochNanos());
|
||||||
writePoint(writer, name + "_sum", point.getSum(), point.getAttributes(), point.getEpochNanos());
|
writePoint(writer, name + "_sum", point.getSum(), point.getAttributes(), point.getEpochNanos());
|
||||||
|
|
||||||
List<ValueAtQuantile> valueAtQuantiles = point.getValues();
|
List<ValueAtQuantile> valueAtQuantiles = point.getValues();
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ public final class Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Service {
|
static class Service {
|
||||||
private final WebClient client = WebClient.of();
|
private final WebClient client = WebClient.of();
|
||||||
|
|
||||||
@Post("/verify-tracecontext")
|
@Post("/verify-tracecontext")
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import io.opentelemetry.api.metrics.Meter;
|
||||||
import io.opentelemetry.api.metrics.ObservableDoubleGauge;
|
import io.opentelemetry.api.metrics.ObservableDoubleGauge;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.DoubleAdder;
|
||||||
import java.util.concurrent.atomic.LongAdder;
|
import java.util.concurrent.atomic.LongAdder;
|
||||||
|
|
||||||
final class OpenTelemetryTimer extends AbstractTimer implements RemovableMeter {
|
final class OpenTelemetryTimer extends AbstractTimer implements RemovableMeter {
|
||||||
|
|
@ -80,7 +81,7 @@ final class OpenTelemetryTimer extends AbstractTimer implements RemovableMeter {
|
||||||
@Override
|
@Override
|
||||||
protected void recordNonNegative(long amount, TimeUnit unit) {
|
protected void recordNonNegative(long amount, TimeUnit unit) {
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
long nanos = unit.toNanos(amount);
|
double nanos = (double) unit.toNanos(amount);
|
||||||
double time = TimeUtils.nanosToUnit(nanos, baseTimeUnit);
|
double time = TimeUtils.nanosToUnit(nanos, baseTimeUnit);
|
||||||
otelHistogram.record(time, attributes);
|
otelHistogram.record(time, attributes);
|
||||||
measurements.record(nanos);
|
measurements.record(nanos);
|
||||||
|
|
@ -116,7 +117,7 @@ final class OpenTelemetryTimer extends AbstractTimer implements RemovableMeter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface Measurements {
|
private interface Measurements {
|
||||||
void record(long nanos);
|
void record(double nanos);
|
||||||
|
|
||||||
long count();
|
long count();
|
||||||
|
|
||||||
|
|
@ -129,7 +130,7 @@ final class OpenTelemetryTimer extends AbstractTimer implements RemovableMeter {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(long nanos) {}
|
public void record(double nanos) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long count() {
|
public long count() {
|
||||||
|
|
@ -149,10 +150,10 @@ final class OpenTelemetryTimer extends AbstractTimer implements RemovableMeter {
|
||||||
private static final class MicrometerHistogramMeasurements implements Measurements {
|
private static final class MicrometerHistogramMeasurements implements Measurements {
|
||||||
|
|
||||||
private final LongAdder count = new LongAdder();
|
private final LongAdder count = new LongAdder();
|
||||||
private final LongAdder totalTime = new LongAdder();
|
private final DoubleAdder totalTime = new DoubleAdder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void record(long nanos) {
|
public void record(double nanos) {
|
||||||
count.increment();
|
count.increment();
|
||||||
totalTime.add(nanos);
|
totalTime.add(nanos);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
* io.opentelemetry.api.trace.Status#OK} are categorized into one of these buckets om the traceZ
|
* io.opentelemetry.api.trace.Status#OK} are categorized into one of these buckets om the traceZ
|
||||||
* zPage.
|
* zPage.
|
||||||
*/
|
*/
|
||||||
|
// TODO(anuraaga): Consider renaming the enums that don't follow our standard convention for
|
||||||
|
// constants.
|
||||||
|
@SuppressWarnings("MemberName")
|
||||||
enum LatencyBoundary {
|
enum LatencyBoundary {
|
||||||
/** Stores finished successful requests of duration within the interval [0, 10us). */
|
/** Stores finished successful requests of duration within the interval [0, 10us). */
|
||||||
ZERO_MICROSx10(0, TimeUnit.MICROSECONDS.toNanos(10)),
|
ZERO_MICROSx10(0, TimeUnit.MICROSECONDS.toNanos(10)),
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,13 @@ public enum TestSdk {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tracer getTracer() {
|
public Tracer getTracer() {
|
||||||
return sdkBuilder.buildTracer();
|
return SdkBuilder.buildTracer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private abstract static class SdkBuilder {
|
private abstract static class SdkBuilder {
|
||||||
abstract Meter build();
|
abstract Meter build();
|
||||||
|
|
||||||
protected Tracer buildTracer() {
|
protected static Tracer buildTracer() {
|
||||||
return SdkTracerProvider.builder()
|
return SdkTracerProvider.builder()
|
||||||
.setSampler(Sampler.alwaysOn())
|
.setSampler(Sampler.alwaysOn())
|
||||||
.build()
|
.build()
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import io.opentelemetry.sdk.metrics.InstrumentValueType;
|
||||||
import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
|
import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
@ -74,7 +74,7 @@ class CallbackRegistrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invokeCallback_Long() {
|
void invokeCallback_Long() {
|
||||||
AtomicLong counter = new AtomicLong();
|
AtomicInteger counter = new AtomicInteger();
|
||||||
Consumer<ObservableDoubleMeasurement> callback =
|
Consumer<ObservableDoubleMeasurement> callback =
|
||||||
measurement ->
|
measurement ->
|
||||||
measurement.record(
|
measurement.record(
|
||||||
|
|
@ -92,7 +92,7 @@ class CallbackRegistrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invokeCallback_NoStorage() {
|
void invokeCallback_NoStorage() {
|
||||||
AtomicLong counter = new AtomicLong();
|
AtomicInteger counter = new AtomicInteger();
|
||||||
Consumer<ObservableDoubleMeasurement> callback =
|
Consumer<ObservableDoubleMeasurement> callback =
|
||||||
measurement ->
|
measurement ->
|
||||||
measurement.record(
|
measurement.record(
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,6 @@ public final class ErrorReportingTest {
|
||||||
void testInstrumentationLayer() {
|
void testInstrumentationLayer() {
|
||||||
Span span = tracer.spanBuilder("one").startSpan();
|
Span span = tracer.spanBuilder("one").startSpan();
|
||||||
try (Scope ignored = span.makeCurrent()) {
|
try (Scope ignored = span.makeCurrent()) {
|
||||||
// ScopedRunnable captures the active Span at this time.
|
|
||||||
executor.submit(
|
executor.submit(
|
||||||
new ScopedRunnable(
|
new ScopedRunnable(
|
||||||
() -> {
|
() -> {
|
||||||
|
|
@ -125,8 +124,7 @@ public final class ErrorReportingTest {
|
||||||
} finally {
|
} finally {
|
||||||
Span.current().end();
|
Span.current().end();
|
||||||
}
|
}
|
||||||
},
|
}));
|
||||||
tracer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await()
|
await()
|
||||||
|
|
@ -139,13 +137,11 @@ public final class ErrorReportingTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ScopedRunnable implements Runnable {
|
private static class ScopedRunnable implements Runnable {
|
||||||
Runnable runnable;
|
private final Runnable runnable;
|
||||||
Tracer tracer;
|
private final Span span;
|
||||||
Span span;
|
|
||||||
|
|
||||||
private ScopedRunnable(Runnable runnable, Tracer tracer) {
|
private ScopedRunnable(Runnable runnable) {
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
this.tracer = tracer;
|
|
||||||
this.span = Span.current();
|
this.span = Span.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue