From b531acffbf9c4c8f5fcddb699efb736053d6485e Mon Sep 17 00:00:00 2001 From: moander Date: Fri, 22 Oct 2021 21:21:07 +0200 Subject: [PATCH 1/2] docs: expose existing comments (#2555) --- .../src/xhr.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts b/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts index 09d8a0c588..d2d126be8e 100644 --- a/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts +++ b/experimental/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts @@ -57,13 +57,15 @@ export type XHRCustomAttributeFunction = ( */ export interface XMLHttpRequestInstrumentationConfig extends InstrumentationConfig { - // the number of timing resources is limited, after the limit - // (chrome 250, safari 150) the information is not collected anymore - // the only way to prevent that is to regularly clean the resources - // whenever it is possible, this is needed only when PerformanceObserver - // is not available + /** + * The number of timing resources is limited, after the limit + * (chrome 250, safari 150) the information is not collected anymore. + * The only way to prevent that is to regularly clean the resources + * whenever it is possible. This is needed only when PerformanceObserver + * is not available + */ clearTimingResources?: boolean; - // urls which should include trace headers when origin doesn't match + /** URLs which should include trace headers when origin doesn't match */ propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls; /** * URLs that partially match any regex in ignoreUrls will not be traced. From c1939a79a9773f6155eb04bc4d0aa261b057a934 Mon Sep 17 00:00:00 2001 From: Jack <57678801+mothershipper@users.noreply.github.com> Date: Tue, 26 Oct 2021 12:35:57 -0700 Subject: [PATCH 2/2] fix(@opentelemetry/exporter-prometheus): unref prometheus server to prevent process running indefinitely (#2558) --- .../src/PrometheusExporter.ts | 3 ++- .../test/PrometheusExporter.test.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts index 35c1de5bd9..3028f22723 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts @@ -68,7 +68,8 @@ export class PrometheusExporter implements MetricExporter { typeof config.appendTimestamp === 'boolean' ? config.appendTimestamp : PrometheusExporter.DEFAULT_OPTIONS.appendTimestamp; - this._server = createServer(this._requestHandler); + // unref to prevent prometheus exporter from holding the process open on exit + this._server = createServer(this._requestHandler).unref(); this._serializer = new PrometheusSerializer( this._prefix, this._appendTimestamp diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts index 3b5f044be3..9860d82eed 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts @@ -36,6 +36,7 @@ describe('PrometheusExporter', () => { mockAggregator(HistogramAggregator); afterEach(() => { + sinon.restore(); delete process.env.OTEL_EXPORTER_PROMETHEUS_HOST; delete process.env.OTEL_EXPORTER_PROMETHEUS_PORT; }); @@ -116,6 +117,16 @@ describe('PrometheusExporter', () => { ); }); + it('should unref the server to allow graceful termination', () => { + const mockServer = sinon.createStubInstance(http.Server); + const createStub = sinon.stub(http, 'createServer'); + createStub.returns((mockServer as any) as http.Server); + const exporter = new PrometheusExporter({}, async () => { + await exporter.shutdown(); + }); + sinon.assert.calledOnce(mockServer.unref); + }); + it('should listen on environmentally set host and port', () => { process.env.OTEL_EXPORTER_PROMETHEUS_HOST = '127.0.0.1'; process.env.OTEL_EXPORTER_PROMETHEUS_PORT = '1234';