Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
obecny committed Dec 15, 2020
1 parent fc82e25 commit 5b2015f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { NodeTracerProvider } from '@opentelemetry/node';
import { plugin } from '../../src/dns';
import * as dns from 'dns';
import * as utils from '../utils/utils';
import * as semver from 'semver';
import { assertSpan } from '../utils/assertSpan';
import { StatusCode } from '@opentelemetry/api';

Expand Down Expand Up @@ -139,27 +138,15 @@ describe('dns.promises.lookup()', () => {
const [span] = spans;

assert.strictEqual(spans.length, 1);
if (semver.lt(process.versions.node, '9.0.0')) {
assertSpan(span, {
addresses: [],
// tslint:disable-next-line:no-any
hostname: hostname as any,
forceStatus: {
code: StatusCode.ERROR,
message: error!.message,
},
});
} else {
assertSpan(span, {
addresses: [],
// tslint:disable-next-line:no-any
hostname: hostname as any,
forceStatus: {
code: StatusCode.ERROR,
message: error!.message,
},
});
}
assertSpan(span, {
addresses: [],
// tslint:disable-next-line:no-any
hostname: hostname as any,
forceStatus: {
code: StatusCode.ERROR,
message: error!.message,
},
});
}
});

Expand All @@ -174,27 +161,15 @@ describe('dns.promises.lookup()', () => {
const [span] = spans;

assert.strictEqual(spans.length, 1);
if (semver.lt(process.versions.node, '9.0.0')) {
assertSpan(span, {
addresses: [],
// tslint:disable-next-line:no-any
hostname: hostname as any,
forceStatus: {
code: StatusCode.ERROR,
message: error!.message,
},
});
} else {
assertSpan(span, {
addresses: [],
// tslint:disable-next-line:no-any
hostname: hostname as any,
forceStatus: {
code: StatusCode.ERROR,
message: error!.message,
},
});
}
assertSpan(span, {
addresses: [],
// tslint:disable-next-line:no-any
hostname: hostname as any,
forceStatus: {
code: StatusCode.ERROR,
message: error!.message,
},
});
}
});
});
Expand Down
24 changes: 12 additions & 12 deletions plugins/node/opentelemetry-plugin-ioredis/test/ioredis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const DEFAULT_ATTRIBUTES = {
[GeneralAttribute.NET_PEER_ADDRESS]: URL,
};

const spanStatus: Status = {
const unsetStatus: Status = {
code: StatusCode.UNSET,
};

Expand Down Expand Up @@ -121,7 +121,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
span.end();
assert.strictEqual(endedSpans.length, 3);
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
done();
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
} catch (error) {
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
done();
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
} catch (error) {
Expand Down Expand Up @@ -378,7 +378,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
done();
Expand Down Expand Up @@ -414,7 +414,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
done();
Expand Down Expand Up @@ -448,7 +448,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
done();
Expand Down Expand Up @@ -476,7 +476,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
} catch (error) {
Expand Down Expand Up @@ -505,7 +505,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
} catch (error) {
Expand Down Expand Up @@ -564,7 +564,7 @@ describe('ioredis', () => {
SpanKind.CLIENT,
attributes,
[],
spanStatus
unsetStatus
);
testUtils.assertPropagation(endedSpans[0], span);
done();
Expand Down
1 change: 0 additions & 1 deletion plugins/node/opentelemetry-plugin-pg-pool/src/pg-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export class PostgresPoolPlugin extends BasePlugin<typeof pgPoolTypes> {
.then((result: any) => {
// Return a pass-along promise which ends the span and then goes to user's orig resolvers
return new Promise((resolve, _) => {
span.setStatus({ code: StatusCode.OK });
span.end();
resolve(result);
});
Expand Down
2 changes: 1 addition & 1 deletion plugins/node/opentelemetry-plugin-redis/test/redis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('[email protected]', () => {
const provider = new NodeTracerProvider();
const tracer = provider.getTracer('external');
let redis: typeof redisTypes;
const shouldTestLocal = process.env.RUN_REDIS_TESTS_LOCAL || true;
const shouldTestLocal = process.env.RUN_REDIS_TESTS_LOCAL;
const shouldTest = process.env.RUN_REDIS_TESTS || shouldTestLocal;

let contextManager: AsyncHooksContextManager;
Expand Down

0 comments on commit 5b2015f

Please sign in to comment.