Skip to content

Commit

Permalink
fixup! tune api deps for node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
Flarna committed Mar 24, 2022
1 parent ad0e805 commit 6fe8528
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { diag } from '@opentelemetry/api';
import { diag, DiagLogger } from '@opentelemetry/api';
import {
Counter,
ObservableGauge,
Expand Down Expand Up @@ -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');
});
});
Expand Down

0 comments on commit 6fe8528

Please sign in to comment.