Skip to content

Commit

Permalink
feat: update PeriodicExportingMetricReader and PrometheusExporter to …
Browse files Browse the repository at this point in the history
…accept optional metric producers (#4077)

Co-authored-by: Daniel Dyla <[email protected]>
Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
3 people authored Aug 29, 2023
1 parent 0cc9a0b commit a793321
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
### :rocket: (Enhancement)

* feat(sdk-metrics): implement MetricProducer specification [#4007](https://github.com/open-telemetry/opentelemetry-js/pull/4007)
* feat: update PeriodicExportingMetricReader and PrometheusExporter to accept optional metric producers [#4077](https://github.com/open-telemetry/opentelemetry-js/pull/4077) @aabmass

### :bug: (Bug Fix)

Expand Down
2 changes: 2 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ All notable changes to experimental packages in this project will be documented

### :rocket: (Enhancement)

* feat: update PeriodicExportingMetricReader and PrometheusExporter to accept optional metric producers [#4077](https://github.com/open-telemetry/opentelemetry-js/pull/4077) @aabmass

### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class PrometheusExporter extends MetricReader {
aggregationSelector: _instrumentType => Aggregation.Default(),
aggregationTemporalitySelector: _instrumentType =>
AggregationTemporality.CUMULATIVE,
metricProducers: config.metricProducers,
});
this._host =
config.host ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import { MetricProducer } from '@opentelemetry/sdk-metrics';

/**
* Configuration interface for prometheus exporter
*/
Expand Down Expand Up @@ -56,4 +58,12 @@ export interface ExporterConfig {
* @default false
*/
preventServerStart?: boolean;

/**
* **Note, this option is experimental**. Additional MetricProducers to use as a source of
* aggregated metric data in addition to the SDK's metric data. The resource returned by
* these MetricProducers is ignored; the SDK's resource will be used instead.
* @experimental
*/
metricProducers?: MetricProducer[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { MetricReader } from './MetricReader';
import { PushMetricExporter } from './MetricExporter';
import { callWithTimeout, TimeoutError } from '../utils';
import { diag } from '@opentelemetry/api';
import { MetricProducer } from './MetricProducer';

export type PeriodicExportingMetricReaderOptions = {
/**
Expand All @@ -40,6 +41,13 @@ export type PeriodicExportingMetricReaderOptions = {
* Milliseconds for the async observable callback to timeout.
*/
exportTimeoutMillis?: number;
/**
* **Note, this option is experimental**. Additional MetricProducers to use as a source of
* aggregated metric data in addition to the SDK's metric data. The resource returned by
* these MetricProducers is ignored; the SDK's resource will be used instead.
* @experimental
*/
metricProducers?: MetricProducer[];
};

/**
Expand All @@ -59,6 +67,7 @@ export class PeriodicExportingMetricReader extends MetricReader {
),
aggregationTemporalitySelector:
options.exporter.selectAggregationTemporality?.bind(options.exporter),
metricProducers: options.metricProducers,
});

if (
Expand Down

0 comments on commit a793321

Please sign in to comment.