Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Aug 3, 2023
1 parent 567b176 commit 39b347b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions opencensus-shim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>Implementations must be thread-safe.
*
Expand All @@ -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");
Expand Down

0 comments on commit 39b347b

Please sign in to comment.