From 6fe852802ef56294ca2ced2d6ce1cf78ab61e8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= <18708370+Flarna@users.noreply.github.com> Date: Thu, 24 Mar 2022 17:12:31 +0100 Subject: [PATCH] fixup! tune api deps for node 16 --- .../package.json | 2 +- .../test/OTLPMetricExporter.test.ts | 29 +++++++++++++++---- .../package.json | 2 +- .../test/node/CollectorMetricExporter.test.ts | 26 ++++++++++++++--- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json index 97197b6e5c..28c2096142 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json @@ -49,7 +49,7 @@ }, "devDependencies": { "@babel/core": "7.16.0", - "@opentelemetry/api": "^1.0.3", + "@opentelemetry/api": "^1.1.0", "@opentelemetry/api-metrics": "0.27.0", "@types/mocha": "8.2.3", "@types/node": "14.17.33", diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/test/OTLPMetricExporter.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/test/OTLPMetricExporter.test.ts index 569bd2e500..45f1b9fd31 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/test/OTLPMetricExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/test/OTLPMetricExporter.test.ts @@ -20,7 +20,7 @@ import { ObservableGauge, Histogram, } from '@opentelemetry/api-metrics'; -import { diag } from '@opentelemetry/api'; +import { diag, DiagLogger } from '@opentelemetry/api'; import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http'; import * as metrics from '@opentelemetry/sdk-metrics-base'; import * as assert from 'assert'; @@ -164,24 +164,41 @@ const testOTLPMetricExporter = (params: TestParams) => }); describe('instance', () => { + let warnStub: sinon.SinonStub; + + beforeEach(() => { + // Need to stub/spy on the underlying logger as the "diag" instance is global + warnStub = sinon.stub(); + const nop = () => {}; + const diagLogger: DiagLogger = { + debug: nop, + error: nop, + info: nop, + verbose: nop, + warn: warnStub + }; + diag.setLogger(diagLogger); + }); + + afterEach(() => { + diag.disable(); + }); + it('should warn about headers', () => { - // Need to stub/spy on the underlying logger as the 'diag' instance is global - const spyLoggerWarn = sinon.stub(diag, 'warn'); collectorExporter = new OTLPMetricExporter({ url: `http://${address}`, headers: { foo: 'bar', }, }); - const args = spyLoggerWarn.args[0]; + const args = warnStub.args[0]; assert.strictEqual(args[0], 'Headers cannot be set when using grpc'); }); it('should warn about path in url', () => { - const spyLoggerWarn = sinon.stub(diag, 'warn'); collectorExporter = new OTLPMetricExporter({ url: `http://${address}/v1/metrics` }); - const args = spyLoggerWarn.args[0]; + const args = warnStub.args[0]; assert.strictEqual( args[0], 'URL path should not be set when using grpc, the path part of the URL will be ignored.' diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json index dc4add04e3..c09f3250b0 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json @@ -62,7 +62,7 @@ }, "devDependencies": { "@babel/core": "7.16.0", - "@opentelemetry/api": "^1.0.3", + "@opentelemetry/api": "^1.1.0", "@types/mocha": "8.2.3", "@types/node": "14.17.33", "@types/sinon": "10.0.6", diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/node/CollectorMetricExporter.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/node/CollectorMetricExporter.test.ts index 8bae6eab8c..2e04d70d39 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/node/CollectorMetricExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/node/CollectorMetricExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { diag } from '@opentelemetry/api'; +import { diag, DiagLogger } from '@opentelemetry/api'; import { Counter, ObservableGauge, @@ -66,15 +66,33 @@ describe('OTLPMetricExporter - node with json over http', () => { }); describe('instance', () => { + let warnStub: sinon.SinonStub; + + beforeEach(() => { + // Need to stub/spy on the underlying logger as the "diag" instance is global + warnStub = sinon.stub(); + const nop = () => {}; + const diagLogger: DiagLogger = { + debug: nop, + error: nop, + info: nop, + verbose: nop, + warn: warnStub + }; + diag.setLogger(diagLogger); + }); + + afterEach(() => { + diag.disable(); + }); + it('should warn about metadata when using json', () => { const metadata = 'foo'; - // Need to stub/spy on the underlying logger as the "diag" instance is global - const spyLoggerWarn = sinon.stub(diag, 'warn'); collectorExporter = new OTLPMetricExporter({ url: address, metadata, } as any); - const args = spyLoggerWarn.args[0]; + const args = warnStub.args[0]; assert.strictEqual(args[0], 'Metadata cannot be set when using http'); }); });