From d3306d621841f3fc8cbabde9c92458b2744015d2 Mon Sep 17 00:00:00 2001 From: naseemkullah Date: Mon, 12 Apr 2021 21:45:21 -0400 Subject: [PATCH] fix: use globalErrorHandler Signed-off-by: naseemkullah --- .../src/util.ts | 15 +++++++++------ .../src/export/Controller.ts | 3 +-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/opentelemetry-exporter-collector-grpc/src/util.ts b/packages/opentelemetry-exporter-collector-grpc/src/util.ts index 642c9308482..1d99b02a444 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/util.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/util.ts @@ -14,18 +14,19 @@ * limitations under the License. */ -import { diag } from '@opentelemetry/api'; +import * as grpc from '@grpc/grpc-js'; import * as protoLoader from '@grpc/proto-loader'; +import { diag } from '@opentelemetry/api'; +import { globalErrorHandler } from '@opentelemetry/core'; import { collectorTypes } from '@opentelemetry/exporter-collector'; -import * as grpc from '@grpc/grpc-js'; import * as path from 'path'; - +import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { CollectorExporterConfigNode, GRPCQueueItem, - ServiceClientType, + ServiceClientType } from './types'; -import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; + export function onInit( collector: CollectorExporterNodeBase, @@ -38,7 +39,6 @@ export function onInit( const includeDirs = [path.resolve(__dirname, '..', 'protos')]; - // eslint-disable-next-line @typescript-eslint/no-floating-promises protoLoader .load(collector.getServiceProtoPath(), { keepCase: false, @@ -69,6 +69,9 @@ export function onInit( collector.send(item.objects, item.onSuccess, item.onError); }); } + }) + .catch(err => { + globalErrorHandler(err); }); } diff --git a/packages/opentelemetry-metrics/src/export/Controller.ts b/packages/opentelemetry-metrics/src/export/Controller.ts index 7e84684bbdd..e6bd2eda7f8 100644 --- a/packages/opentelemetry-metrics/src/export/Controller.ts +++ b/packages/opentelemetry-metrics/src/export/Controller.ts @@ -37,8 +37,7 @@ export class PushController extends Controller { ) { super(); this._timer = setInterval(() => { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this._collect(); + this._collect().catch(err => {globalErrorHandler(err)}); }, interval); unrefTimer(this._timer); }