diff --git a/packages/network-of-terms-query/src/instrumentation.ts b/packages/network-of-terms-query/src/instrumentation.ts index abbfdb62b..e21114d07 100644 --- a/packages/network-of-terms-query/src/instrumentation.ts +++ b/packages/network-of-terms-query/src/instrumentation.ts @@ -4,7 +4,7 @@ import { } from '@opentelemetry/sdk-metrics'; import {Resource} from '@opentelemetry/resources'; import {OTLPMetricExporter} from '@opentelemetry/exporter-metrics-otlp-proto'; -import {SemanticResourceAttributes} from '@opentelemetry/semantic-conventions'; +import {SEMRESATTRS_SERVICE_NAME} from '@opentelemetry/semantic-conventions'; import {metrics, ValueType} from '@opentelemetry/api'; const sourceQueriesHistogramName = 'queries.source'; @@ -12,20 +12,22 @@ const sourceQueriesHistogramName = 'queries.source'; const meterProvider = new MeterProvider({ resource: Resource.default().merge( new Resource({ - [SemanticResourceAttributes.SERVICE_NAME]: 'network-of-terms', + [SEMRESATTRS_SERVICE_NAME]: 'network-of-terms', }) ), + readers: + 'test' === process.env.NODE_ENV + ? [] + : [ + new PeriodicExportingMetricReader({ + exporter: new OTLPMetricExporter(), + exportIntervalMillis: + (process.env.OTEL_METRIC_EXPORT_INTERVAL as unknown as number) ?? + 60000, + }), + ], }); -if ('test' !== process.env.NODE_ENV) { - meterProvider.addMetricReader( - new PeriodicExportingMetricReader({ - exporter: new OTLPMetricExporter(), - exportIntervalMillis: - (process.env.OTEL_METRIC_EXPORT_INTERVAL as unknown as number) ?? 60000, - }) - ); -} metrics.setGlobalMeterProvider(meterProvider); const meter = metrics.getMeter('default');