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
  • Loading branch information
aabmass committed Aug 18, 2023
1 parent b400c2e commit 15690f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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 15690f4

Please sign in to comment.