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