Skip to content

Commit

Permalink
move the ViewRegistry up one package, and clean up the visibility of …
Browse files Browse the repository at this point in the history
…other classes
  • Loading branch information
jwatson committed Jul 14, 2020
1 parent 080782e commit a51d0f9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@AutoValue
@Immutable
abstract class InstrumentDescriptor {
public static InstrumentDescriptor create(
static InstrumentDescriptor create(
String name,
String description,
String unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static MeterProviderSharedState create(Clock clock, Resource resource) {
return new AutoValue_MeterProviderSharedState(clock, resource);
}

public abstract Clock getClock();
abstract Clock getClock();

abstract Resource getResource();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.export.MetricProducer;
import io.opentelemetry.sdk.metrics.view.InstrumentSelector;
import io.opentelemetry.sdk.metrics.view.ViewRegistry;
import io.opentelemetry.sdk.metrics.view.ViewSpecification;
import io.opentelemetry.sdk.resources.EnvVarResource;
import io.opentelemetry.sdk.resources.Resource;
Expand Down
13 changes: 8 additions & 5 deletions sdk/src/main/java/io/opentelemetry/sdk/metrics/ViewRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import io.opentelemetry.sdk.metrics.view.Aggregation;
import io.opentelemetry.sdk.metrics.view.Aggregations;
import io.opentelemetry.sdk.metrics.view.InstrumentSelector;
import io.opentelemetry.sdk.metrics.view.ViewSpecification;
import io.opentelemetry.sdk.metrics.view.ViewSpecification.Temporality;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -41,11 +43,11 @@
*/
class ViewRegistry {

public static final ViewSpecification CUMULATIVE_SUM =
private static final ViewSpecification CUMULATIVE_SUM =
ViewSpecification.create(Aggregations.sum(), Temporality.CUMULATIVE);
public static final ViewSpecification DELTA_SUMMARY =
private static final ViewSpecification DELTA_SUMMARY =
ViewSpecification.create(Aggregations.minMaxSumCount(), Temporality.DELTA);
public static final ViewSpecification CUMULATIVE_LAST_VALUE =
private static final ViewSpecification CUMULATIVE_LAST_VALUE =
ViewSpecification.create(Aggregations.lastValue(), Temporality.CUMULATIVE);

private final Map<InstrumentSelector, ViewSpecification> configuration =
Expand Down Expand Up @@ -92,6 +94,8 @@ private static ViewSpecification getDefaultSpecification(InstrumentDescriptor de
case COUNTER:
case UP_DOWN_COUNTER:
return CUMULATIVE_SUM;
// TODO: Revisit the batcher used here for value observers,
// currently this does not remove duplicate records in the same cycle.
case VALUE_OBSERVER:
case VALUE_RECORDER:
return DELTA_SUMMARY;
Expand All @@ -102,8 +106,7 @@ private static ViewSpecification getDefaultSpecification(InstrumentDescriptor de
throw new IllegalArgumentException("Unknown descriptor type: " + descriptor.getType());
}

/** todo: javadoc me. */
public void registerView(InstrumentSelector selector, ViewSpecification specification) {
void registerView(InstrumentSelector selector, ViewSpecification specification) {
configuration.put(selector, specification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@
* limitations under the License.
*/

package io.opentelemetry.sdk.metrics.view;
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.Batcher;
import io.opentelemetry.sdk.metrics.InstrumentDescriptor;
import io.opentelemetry.sdk.metrics.MeterProviderSharedState;
import io.opentelemetry.sdk.metrics.MeterSharedState;
import io.opentelemetry.sdk.metrics.aggregator.DoubleLastValueAggregator;
import io.opentelemetry.sdk.metrics.aggregator.DoubleMinMaxSumCount;
import io.opentelemetry.sdk.metrics.aggregator.DoubleSumAggregator;
Expand All @@ -33,6 +29,9 @@
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.Aggregations;
import io.opentelemetry.sdk.metrics.view.InstrumentSelector;
import io.opentelemetry.sdk.metrics.view.ViewSpecification;
import io.opentelemetry.sdk.metrics.view.ViewSpecification.Temporality;
import org.junit.Before;
import org.junit.Test;
Expand Down

0 comments on commit a51d0f9

Please sign in to comment.