cleanup work (#2172)

* remove 3 classes that got left behind in a repackaging

* actually disable the stress test
This commit is contained in:
John Watson 2020-12-01 17:03:32 -08:00 committed by GitHub
parent 6bbe8d47dc
commit 4d73431a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 354 deletions

View File

@ -35,9 +35,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Ignore;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
@ -134,7 +134,7 @@ public class OtlpPipelineStressTest {
}
@Test
@Ignore("we don't want to run this with every build.")
@Disabled("we don't want to run this with every build.")
void oltpExportWithFlakyCollector() throws IOException, InterruptedException {
ToxicList toxics = collectorProxy.toxics();
// Latency latency = toxics.latency("jittery_latency", ToxicDirection.UPSTREAM, 500);

View File

@ -1,47 +0,0 @@
/*
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.opentelemetry.sdk.metrics.view;
import com.google.auto.value.AutoValue;
import io.opentelemetry.metrics.Instrument;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
@AutoValue
@Immutable
public abstract class AggregationConfiguration {
public static AggregationConfiguration create(Aggregation aggregation, Temporality temporality) {
return new AutoValue_AggregationConfiguration(aggregation, temporality);
}
/** Returns the {@link Aggregation} that should be used for this View. */
@Nullable
public abstract Aggregation aggregation();
/** Returns the {@link Temporality} that should be used for this View (delta vs. cumulative). */
@Nullable
public abstract Temporality temporality();
/** An enumeration which describes the time period over which metrics should be aggregated. */
public enum Temporality {
/** Metrics will be aggregated only over the most recent collection interval. */
DELTA,
/** Metrics will be aggregated over the lifetime of the associated {@link Instrument}. */
CUMULATIVE
}
}

View File

@ -1,54 +0,0 @@
/*
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.opentelemetry.sdk.metrics.view;
import com.google.auto.value.AutoValue;
import com.google.auto.value.extension.memoized.Memoized;
import io.opentelemetry.sdk.metrics.common.InstrumentType;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
@AutoValue
@Immutable
public abstract class InstrumentSelector {
public static Builder newBuilder() {
return new AutoValue_InstrumentSelector.Builder();
}
@Nullable
public abstract InstrumentType instrumentType();
@Nullable
public abstract String instrumentNameRegex();
@Memoized
@Nullable
public Pattern instrumentNamePattern() {
return instrumentNameRegex() == null ? null : Pattern.compile(instrumentNameRegex());
}
@AutoValue.Builder
public interface Builder {
Builder instrumentType(InstrumentType instrumentType);
Builder instrumentNameRegex(String regex);
InstrumentSelector build();
}
}

View File

@ -1,251 +0,0 @@
/*
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.opentelemetry.sdk.metrics;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
import io.opentelemetry.common.Labels;
import io.opentelemetry.sdk.internal.TestClock;
import io.opentelemetry.sdk.metrics.aggregator.DoubleLastValueAggregator;
import io.opentelemetry.sdk.metrics.aggregator.DoubleMinMaxSumCount;
import io.opentelemetry.sdk.metrics.aggregator.DoubleSumAggregator;
import io.opentelemetry.sdk.metrics.aggregator.LongLastValueAggregator;
import io.opentelemetry.sdk.metrics.aggregator.LongMinMaxSumCount;
import io.opentelemetry.sdk.metrics.aggregator.LongSumAggregator;
import io.opentelemetry.sdk.metrics.common.InstrumentType;
import io.opentelemetry.sdk.metrics.common.InstrumentValueType;
import io.opentelemetry.sdk.metrics.view.AggregationConfiguration;
import io.opentelemetry.sdk.metrics.view.AggregationConfiguration.Temporality;
import io.opentelemetry.sdk.metrics.view.Aggregations;
import io.opentelemetry.sdk.metrics.view.InstrumentSelector;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class ViewRegistryTest {
@Mock private MeterSharedState meterSharedState;
@Mock private MeterProviderSharedState meterProviderSharedState;
@Before
public void setUp() {
when(meterProviderSharedState.getClock()).thenReturn(TestClock.create());
}
@Test
public void defaultAggregations() {
ViewRegistry viewRegistry = new ViewRegistry();
verifyCorrect(
viewRegistry,
InstrumentType.VALUE_RECORDER,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ true,
DoubleMinMaxSumCount.class);
verifyCorrect(
viewRegistry,
InstrumentType.VALUE_RECORDER,
InstrumentValueType.LONG,
/* expectedDeltas=*/ true,
LongMinMaxSumCount.class);
verifyCorrect(
viewRegistry,
InstrumentType.VALUE_OBSERVER,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ true,
DoubleMinMaxSumCount.class);
verifyCorrect(
viewRegistry,
InstrumentType.VALUE_OBSERVER,
InstrumentValueType.LONG,
/* expectedDeltas=*/ true,
LongMinMaxSumCount.class);
verifyCorrect(
viewRegistry,
InstrumentType.COUNTER,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ false,
DoubleSumAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.COUNTER,
InstrumentValueType.LONG,
/* expectedDeltas=*/ false,
LongSumAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.UP_DOWN_COUNTER,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ false,
DoubleSumAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.UP_DOWN_COUNTER,
InstrumentValueType.LONG,
/* expectedDeltas=*/ false,
LongSumAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.SUM_OBSERVER,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ false,
DoubleLastValueAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.SUM_OBSERVER,
InstrumentValueType.LONG,
/* expectedDeltas=*/ false,
LongLastValueAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.UP_DOWN_SUM_OBSERVER,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ false,
DoubleLastValueAggregator.class);
verifyCorrect(
viewRegistry,
InstrumentType.UP_DOWN_SUM_OBSERVER,
InstrumentValueType.LONG,
/* expectedDeltas=*/ false,
LongLastValueAggregator.class);
}
@Test
public void selectByInstrumentType() {
ViewRegistry viewRegistry = new ViewRegistry();
InstrumentType instrumentType = InstrumentType.VALUE_RECORDER;
InstrumentSelector selector =
InstrumentSelector.newBuilder().instrumentType(instrumentType).build();
AggregationConfiguration view =
AggregationConfiguration.create(Aggregations.sum(), Temporality.CUMULATIVE);
viewRegistry.registerView(selector, view);
verifyCorrect(
viewRegistry,
instrumentType,
InstrumentValueType.DOUBLE,
/* expectedDeltas=*/ false,
DoubleSumAggregator.class);
}
@Test
public void selectByInstrumentName() {
ViewRegistry viewRegistry = new ViewRegistry();
InstrumentSelector selector =
InstrumentSelector.newBuilder().instrumentNameRegex("http.*duration").build();
AggregationConfiguration view =
AggregationConfiguration.create(Aggregations.sum(), Temporality.CUMULATIVE);
viewRegistry.registerView(selector, view);
InstrumentType instrumentType = InstrumentType.VALUE_RECORDER;
// this one matches on name
verifyCorrect(
viewRegistry,
createDescriptor(instrumentType, InstrumentValueType.DOUBLE, "http.server.duration"),
/* expectedDeltas= */ false,
DoubleSumAggregator.class);
// this one does not match on name
verifyCorrect(
viewRegistry,
createDescriptor(instrumentType, InstrumentValueType.DOUBLE, "foo.bar.duration"),
/* expectedDeltas=*/ true,
DoubleMinMaxSumCount.class);
}
@Test
public void selectByInstrumentNameAndType() {
ViewRegistry viewRegistry = new ViewRegistry();
InstrumentSelector selector =
InstrumentSelector.newBuilder()
.instrumentType(InstrumentType.VALUE_RECORDER)
.instrumentNameRegex("http.*duration")
.build();
AggregationConfiguration view =
AggregationConfiguration.create(Aggregations.sum(), Temporality.CUMULATIVE);
viewRegistry.registerView(selector, view);
// this one matches on name
verifyCorrect(
viewRegistry,
createDescriptor(
InstrumentType.VALUE_RECORDER, InstrumentValueType.DOUBLE, "http.server.duration"),
/* expectedDeltas= */ false,
DoubleSumAggregator.class);
// this one does not match on name, but does on type, so should get the default
verifyCorrect(
viewRegistry,
createDescriptor(
InstrumentType.VALUE_RECORDER, InstrumentValueType.DOUBLE, "foo.bar.duration"),
/* expectedDeltas=*/ true,
DoubleMinMaxSumCount.class);
// this one does not match on type, but does on name, so should get the default
verifyCorrect(
viewRegistry,
createDescriptor(
InstrumentType.SUM_OBSERVER, InstrumentValueType.DOUBLE, "http.bar.duration"),
/* expectedDeltas=*/ false,
DoubleLastValueAggregator.class);
}
private void verifyCorrect(
ViewRegistry viewRegistry,
InstrumentType instrumentType,
InstrumentValueType valueType,
boolean expectedDeltas,
Class<?> expectedAggregator) {
verifyCorrect(
viewRegistry,
createDescriptor(instrumentType, valueType, "foo"),
expectedDeltas,
expectedAggregator);
}
private void verifyCorrect(
ViewRegistry viewRegistry,
InstrumentDescriptor descriptor,
boolean expectedDeltas,
Class<?> expectedAggregator) {
Batcher batcher =
viewRegistry.createBatcher(meterProviderSharedState, meterSharedState, descriptor);
assertThat(batcher.generatesDeltas()).isEqualTo(expectedDeltas);
assertThat(batcher.getAggregator()).isInstanceOf(expectedAggregator);
}
private static InstrumentDescriptor createDescriptor(
InstrumentType instrumentType,
InstrumentValueType instrumentValueType,
String instrumentName) {
return InstrumentDescriptor.create(
instrumentName, "foo desc", "ms", Labels.empty(), instrumentType, instrumentValueType);
}
}