diff --git a/opencensus-shim/README.md b/opencensus-shim/README.md index 69c9f3319cd..91d5608bf9a 100644 --- a/opencensus-shim/README.md +++ b/opencensus-shim/README.md @@ -23,10 +23,7 @@ To allow the shim to work for metrics, add the shim as a dependency. Applications also need to attach OpenCensus metrics to their metric readers on registration. ```java -PeriodicMetricReader reader = ... -SdkMeterProvider.builder() - .registerMetricReader(OpenCensusMetrics.attachTo(reader)) - .buildAndRegisterGlobal(); +SdkMeterProvider.builder().registerMetricReader(PeriodicMetricReader.builder(exporter).addMetricProducer(OpenCensusMetricProducer.create()).build()) ``` For example, if a logging exporter were configured, the following would be diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/export/MetricProducer.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/export/MetricProducer.java index b7cd7629dc6..94ba787e8b3 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/export/MetricProducer.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/export/MetricProducer.java @@ -14,8 +14,8 @@ /** * {@code MetricProducer} is the interface that is used to make metric data available to the {@link - * MetricReader}s. Implementations should be stateful, in that each call to {@link - * #produce()} will return any metric generated since the last call was made. + * MetricReader}s. Implementations should be stateful, in that each call to {@link #produce()} will + * return any metric generated since the last call was made. * *
Implementations must be thread-safe. * @@ -26,7 +26,7 @@ public interface MetricProducer extends CollectionRegistration { /** Cast the registration to a {@link MetricProducer}. */ -static MetricProducer asMetricProducer(CollectionRegistration registration) { + static MetricProducer asMetricProducer(CollectionRegistration registration) { if (!(registration instanceof MetricProducer)) { throw new IllegalArgumentException( "unrecognized CollectionRegistration, custom MetricReader implementations are not currently supported");