From 801df25b9bf7cf91c5cbfff2e9d3edd1b3d8cfb0 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Fri, 24 Jan 2020 10:02:12 -0500 Subject: [PATCH] fix: unref jaeger socket to prevent process running indefinitely (#715) --- packages/opentelemetry-exporter-jaeger/src/jaeger.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index 1b1f50e6b3..4ae500f74e 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import { SpanExporter, ReadableSpan } from '@opentelemetry/tracing'; import { ExportResult } from '@opentelemetry/base'; -import * as jaegerTypes from './types'; import { NoopLogger } from '@opentelemetry/core'; +import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing'; import * as types from '@opentelemetry/types'; +import { Socket } from 'dgram'; import { spanToThrift } from './transform'; +import * as jaegerTypes from './types'; /** * Format and sends span information to Jaeger Exporter. @@ -40,6 +41,11 @@ export class JaegerExporter implements SpanExporter { typeof config.flushTimeout === 'number' ? config.flushTimeout : 2000; this._sender = new jaegerTypes.UDPSender(config); + if (this._sender._client instanceof Socket) { + // unref socket to prevent it from keeping the process running + this._sender._client.unref(); + } + this._process = { serviceName: config.serviceName, tags: jaegerTypes.ThriftUtils.getThriftTags(tags),