-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stabilize MetricProducer, allow custom MetricReaders (#5835)
- Loading branch information
Showing
21 changed files
with
242 additions
and
276 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
docs/apidiffs/current_vs_latest/opentelemetry-sdk-metrics.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
Comparing source compatibility of against | ||
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.metrics.export.CollectionRegistration (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
+++ NEW METHOD: PUBLIC(+) java.util.Collection<io.opentelemetry.sdk.metrics.data.MetricData> collectAllMetrics() | ||
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.metrics.export.CollectionRegistration noop() | ||
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.metrics.export.MetricExporter (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.export.MemoryMode getMemoryMode() | ||
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.metrics.export.MetricProducer (not serializable) | ||
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
+++ NEW SUPERCLASS: java.lang.Object | ||
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.Collection<io.opentelemetry.sdk.metrics.data.MetricData> produce(io.opentelemetry.sdk.resources.Resource) | ||
*** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.metrics.export.MetricReader (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.export.MemoryMode getMemoryMode() | ||
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.metrics.export.PeriodicMetricReader (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.common.export.MemoryMode getMemoryMode() | ||
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder (not serializable) | ||
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder registerMetricProducer(io.opentelemetry.sdk.metrics.export.MetricProducer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/OpenCensusMetricProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.opencensusshim; | ||
|
||
import io.opencensus.metrics.Metrics; | ||
import io.opencensus.metrics.export.MetricProducerManager; | ||
import io.opentelemetry.opencensusshim.internal.metrics.MetricAdapter; | ||
import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; | ||
import io.opentelemetry.sdk.metrics.data.MetricData; | ||
import io.opentelemetry.sdk.metrics.export.MetricProducer; | ||
import io.opentelemetry.sdk.metrics.export.MetricReader; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* {@link MetricProducer} for OpenCensus metrics, which allows {@link MetricReader}s to read from | ||
* both OpenTelemetry and OpenCensus metrics. | ||
* | ||
* <p>To use, register with {@link SdkMeterProviderBuilder#registerMetricProducer(MetricProducer)}. | ||
*/ | ||
public final class OpenCensusMetricProducer implements MetricProducer { | ||
private final MetricProducerManager openCensusMetricStorage; | ||
|
||
OpenCensusMetricProducer(MetricProducerManager openCensusMetricStorage) { | ||
this.openCensusMetricStorage = openCensusMetricStorage; | ||
} | ||
|
||
/** | ||
* Constructs a new {@link OpenCensusMetricProducer} that reports against the given {@link | ||
* Resource}. | ||
*/ | ||
public static MetricProducer create() { | ||
return new OpenCensusMetricProducer(Metrics.getExportComponent().getMetricProducerManager()); | ||
} | ||
|
||
@Override | ||
public Collection<MetricData> produce(Resource resource) { | ||
List<MetricData> result = new ArrayList<>(); | ||
openCensusMetricStorage | ||
.getAllMetricProducer() | ||
.forEach( | ||
producer -> | ||
producer | ||
.getMetrics() | ||
.forEach(metric -> result.add(MetricAdapter.convert(resource, metric)))); | ||
return result; | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
...ensus-shim/src/main/java/io/opentelemetry/opencensusshim/metrics/MultiMetricProducer.java
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...rc/main/java/io/opentelemetry/opencensusshim/metrics/OpenCensusAttachingMetricReader.java
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
...-shim/src/main/java/io/opentelemetry/opencensusshim/metrics/OpenCensusMetricProducer.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/metrics/OpenCensusMetrics.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.