Skip to content

Commit

Permalink
fix: support 'none' value for OTEL_METRICS_EXPORTER (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
seemk authored Sep 20, 2023
1 parent 2408364 commit 8681bfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function recordGcCountMetric(counter: Counter, counters: NativeCounters) {
}
}

const SUPPORTED_EXPORTER_TYPES = ['console', 'otlp'];
const SUPPORTED_EXPORTER_TYPES = ['console', 'otlp', 'none'];

function areValidExporterTypes(types: string[]): boolean {
return types.every((t) => SUPPORTED_EXPORTER_TYPES.includes(t));
Expand Down
6 changes: 6 additions & 0 deletions test/metrics.options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ describe('metrics options', () => {
assert(readers[1]['_exporter'] instanceof ConsoleMetricExporter);
});

it('does not create an exporter for none value', () => {
process.env.OTEL_METRICS_EXPORTER = 'none';
const options = _setDefaultOptions();
assert.deepStrictEqual(options.metricReaderFactory(options), []);
});

it('throws on invalid key', () => {
process.env.OTEL_METRICS_EXPORTER = 'invalid-key';

Expand Down

0 comments on commit 8681bfc

Please sign in to comment.