From e880a4d861e435d8da0e058598ec7c930c9dc191 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Sun, 29 May 2022 18:14:44 +0300 Subject: [PATCH] chore: cast typescript in tests to workaround 1.3.0 compatiblity issues --- .../instrumentation-express/test/utils.ts | 2 +- .../test/kafkajs.spec.ts | 8 +- .../test/mongoose.spec.ts | 123 +++++++++--------- .../instrumentation-neo4j/test/neo4j.spec.ts | 33 ++--- .../test/sequelize.spec.ts | 2 +- .../instrumentation-socket.io/test/utils.ts | 2 +- 6 files changed, 86 insertions(+), 84 deletions(-) diff --git a/packages/instrumentation-express/test/utils.ts b/packages/instrumentation-express/test/utils.ts index 51fdb457..7e6e27e8 100644 --- a/packages/instrumentation-express/test/utils.ts +++ b/packages/instrumentation-express/test/utils.ts @@ -74,5 +74,5 @@ export const errorMiddleware = (_req: express.Request, res: express.Response, ne }; export const getExpressSpans = (): ReadableSpan[] => { - return getTestSpans().filter((s) => s.instrumentationLibrary.name?.endsWith('express')); + return getTestSpans().filter((s) => s.instrumentationLibrary.name?.endsWith('express')) as ReadableSpan[]; }; diff --git a/packages/instrumentation-kafkajs/test/kafkajs.spec.ts b/packages/instrumentation-kafkajs/test/kafkajs.spec.ts index 90d285bc..c9e954dd 100644 --- a/packages/instrumentation-kafkajs/test/kafkajs.spec.ts +++ b/packages/instrumentation-kafkajs/test/kafkajs.spec.ts @@ -126,7 +126,7 @@ describe('instrumentation-kafkajs', () => { expect(span.attributes[SemanticAttributes.MESSAGING_DESTINATION]).toStrictEqual('topic-name-1'); expect(messagesSent.length).toBe(1); - expectKafkaHeadersToMatchSpanContext(messagesSent[0], span); + expectKafkaHeadersToMatchSpanContext(messagesSent[0], span as ReadableSpan); }); it('send two messages', async () => { @@ -148,8 +148,8 @@ describe('instrumentation-kafkajs', () => { expect(spans[1].name).toStrictEqual('topic-name-1'); expect(messagesSent.length).toBe(2); - expectKafkaHeadersToMatchSpanContext(messagesSent[0], spans[0]); - expectKafkaHeadersToMatchSpanContext(messagesSent[1], spans[1]); + expectKafkaHeadersToMatchSpanContext(messagesSent[0], spans[0] as ReadableSpan); + expectKafkaHeadersToMatchSpanContext(messagesSent[1], spans[1] as ReadableSpan); }); it('send batch', async () => { @@ -185,7 +185,7 @@ describe('instrumentation-kafkajs', () => { expect(messagesSent.length).toBe(3); for (let i = 0; i < 3; i++) { - expectKafkaHeadersToMatchSpanContext(messagesSent[i], spans[i]); + expectKafkaHeadersToMatchSpanContext(messagesSent[i], spans[i] as ReadableSpan); } }); }); diff --git a/packages/instrumentation-mongoose/test/mongoose.spec.ts b/packages/instrumentation-mongoose/test/mongoose.spec.ts index 872c6947..0e8ca090 100644 --- a/packages/instrumentation-mongoose/test/mongoose.spec.ts +++ b/packages/instrumentation-mongoose/test/mongoose.spec.ts @@ -4,6 +4,7 @@ import { context, ROOT_CONTEXT } from '@opentelemetry/api'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; import { MongooseInstrumentation } from '../src'; import { getTestSpans, registerInstrumentationTesting } from '@opentelemetry/contrib-test-utils'; +import type { ReadableSpan } from '@opentelemetry/sdk-trace-base'; const instrumentation = registerInstrumentationTesting(new MongooseInstrumentation()); @@ -53,9 +54,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('save'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.document).toEqual(expect.objectContaining(document)); }); @@ -71,9 +72,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('save'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.document).toEqual(expect.objectContaining(document)); done(); }); @@ -84,9 +85,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.condition).toEqual({ id: '_test' }); }); @@ -95,8 +96,8 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); - assertSpan(spans[0]); - assertSpan(spans[1]); + assertSpan(spans[0] as ReadableSpan); + assertSpan(spans[1] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); expect(spans[0].attributes[SemanticAttributes.DB_STATEMENT]).toMatch(/.*{"id":"_test[1-2]"}.*/g); expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); @@ -108,9 +109,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('find'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.condition).toEqual({ id: '_test' }); expect(statement.options).toEqual({ skip: 1, limit: 2, sort: { email: 1 } }); }); @@ -121,7 +122,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); - assertSpan(spans[1]); + assertSpan(spans[1] as ReadableSpan); expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('remove'); }); @@ -130,9 +131,9 @@ describe('mongoose instrumentation', () => { user!.remove({ overwrite: true }, () => { const spans = getTestSpans(); expect(spans.length).toBe(2); - assertSpan(spans[1]); + assertSpan(spans[1] as ReadableSpan); expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('remove'); - expect(getStatement(spans[1]).options).toEqual({ overwrite: true }); + expect(getStatement(spans[1] as ReadableSpan).options).toEqual({ overwrite: true }); done(); }) ); @@ -143,7 +144,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('deleteOne'); }); @@ -153,10 +154,10 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); - assertSpan(spans[1]); + assertSpan(spans[1] as ReadableSpan); expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('updateOne'); - const statement = getStatement(spans[1]); + const statement = getStatement(spans[1] as ReadableSpan); expect(statement.options).toEqual({ skip: 0 }); expect(statement.updates).toEqual({ $inc: { age: 1 } }); expect(statement.condition._id).toBeDefined(); @@ -167,10 +168,10 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('updateOne'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({ skip: 0 }); expect(statement.updates).toEqual({ $inc: { age: 1 } }); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); @@ -181,9 +182,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('count'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({}); }); @@ -193,9 +194,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('countDocuments'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); }); @@ -205,9 +206,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('estimatedDocumentCount'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({}); }); @@ -217,9 +218,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('deleteMany'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({}); }); @@ -229,9 +230,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('findOne'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); }); @@ -241,9 +242,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('update'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); expect(statement.updates).toEqual({ email: 'john.doe2@example.com' }); @@ -254,9 +255,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('updateOne'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); expect(statement.updates).toEqual({ age: 55 }); @@ -267,9 +268,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('updateMany'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ age: 18 }); expect(statement.updates).toEqual({ isDeleted: true }); @@ -280,9 +281,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('findOneAndDelete'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); }); @@ -292,11 +293,11 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(2); - assertSpan(spans[0]); - assertSpan(spans[1]); + assertSpan(spans[0] as ReadableSpan); + assertSpan(spans[1] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('findOne'); expect(spans[1].attributes[SemanticAttributes.DB_OPERATION]).toBe('findOneAndUpdate'); - const statement = getStatement(spans[1]); + const statement = getStatement(spans[1] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); expect(statement.updates).toEqual({ isUpdated: true }); @@ -307,9 +308,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('findOneAndRemove'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.condition).toEqual({ email: 'john.doe@example.com' }); }); @@ -320,9 +321,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('save'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.options).toEqual({}); expect(statement.document).toEqual(expect.objectContaining(document)); }); @@ -335,9 +336,9 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('aggregate'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.aggregatePipeline).toEqual([ { $match: { firstName: 'John' } }, { $group: { _id: 'John', total: { $sum: '$amount' } } }, @@ -350,9 +351,9 @@ describe('mongoose instrumentation', () => { () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_OPERATION]).toBe('aggregate'); - const statement = getStatement(spans[0]); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.aggregatePipeline).toEqual([ { $match: { firstName: 'John' } }, { $group: { _id: 'John', total: { $sum: '$amount' } } }, @@ -367,8 +368,8 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); - const statement = getStatement(spans[0]); + assertSpan(spans[0] as ReadableSpan); + const statement = getStatement(spans[0] as ReadableSpan); expect(statement.condition).toEqual({ id: '_test' }); expect(statement.options).toEqual({ skip: 1, limit: 2, sort: { email: 1 } }); }); @@ -381,7 +382,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[SemanticAttributes.DB_STATEMENT]).toBe(undefined); }); @@ -395,7 +396,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); const reqPayload = JSON.parse(spans[0].attributes[SemanticAttributes.DB_STATEMENT] as string); expect(reqPayload.fields).toStrictEqual(projection); }); @@ -414,7 +415,7 @@ describe('mongoose instrumentation', () => { await User.deleteOne({ email: 'john.doe@example.com' }); const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(JSON.parse(spans[0].attributes[RESPONSE] as string)).toEqual({ n: 1, ok: 1, deletedCount: 1 }); }); @@ -422,7 +423,7 @@ describe('mongoose instrumentation', () => { User.deleteOne({ email: 'john.doe@example.com' }, { lean: 1 }, () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(JSON.parse(spans[0].attributes[RESPONSE] as string)).toEqual({ n: 1, ok: 1, @@ -442,7 +443,7 @@ describe('mongoose instrumentation', () => { const createdUser = await user.save(); const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[RESPONSE]).toEqual(JSON.stringify(createdUser)); }); @@ -456,7 +457,7 @@ describe('mongoose instrumentation', () => { user.save((_err, createdUser) => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[RESPONSE]).toEqual(JSON.stringify(createdUser)); done(); }); @@ -470,7 +471,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(JSON.parse(spans[0].attributes[RESPONSE] as string)).toEqual([{ _id: 'John', total: 0 }]); }); @@ -480,7 +481,7 @@ describe('mongoose instrumentation', () => { () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(JSON.parse(spans[0].attributes[RESPONSE] as string)).toEqual([{ _id: 'John', total: 0 }]); done(); } @@ -498,7 +499,7 @@ describe('mongoose instrumentation', () => { await User.deleteOne({ email: 'john.doe@example.com' }); const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[RESPONSE]).toBe(undefined); }); }); @@ -517,7 +518,7 @@ describe('mongoose instrumentation', () => { await User.deleteOne({ email: 'john.doe@example.com' }); const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[VERSION_ATTR]).toMatch(/\d{1,4}\.\d{1,4}\.\d{1,5}.*/); }); @@ -531,7 +532,7 @@ describe('mongoose instrumentation', () => { await user.save(); const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[VERSION_ATTR]).toMatch(/\d{1,4}\.\d{1,4}\.\d{1,5}.*/); }); @@ -543,7 +544,7 @@ describe('mongoose instrumentation', () => { const spans = getTestSpans(); expect(spans.length).toBe(1); - assertSpan(spans[0]); + assertSpan(spans[0] as ReadableSpan); expect(spans[0].attributes[VERSION_ATTR]).toMatch(/\d{1,4}\.\d{1,4}\.\d{1,5}.*/); }); }); diff --git a/packages/instrumentation-neo4j/test/neo4j.spec.ts b/packages/instrumentation-neo4j/test/neo4j.spec.ts index a26a1363..01189d7e 100644 --- a/packages/instrumentation-neo4j/test/neo4j.spec.ts +++ b/packages/instrumentation-neo4j/test/neo4j.spec.ts @@ -14,6 +14,7 @@ instrumentation.enable(); instrumentation.disable(); import neo4j, { Driver } from 'neo4j-driver'; +import { ReadableSpan } from '@opentelemetry/sdk-trace-base'; /** * Tests require neo4j to run, and expose bolt port of 11011 @@ -75,7 +76,7 @@ describe('neo4j instrumentation', function () { expect((res.records[0].toObject() as any).n.labels).toEqual(['MyLabel']); const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.name).toBe('CREATE neo4j'); expect(span.attributes[SemanticAttributes.DB_OPERATION]).toBe('CREATE'); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe('CREATE (n:MyLabel) RETURN n'); @@ -88,7 +89,7 @@ describe('neo4j instrumentation', function () { .subscribe({ onCompleted: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_OPERATION]).toBe('CREATE'); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe('CREATE (n:MyLabel) RETURN n'); done(); @@ -129,7 +130,7 @@ describe('neo4j instrumentation', function () { .subscribe({ onKeys: (keys) => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(keys).toEqual(['n']); done(); }, @@ -151,7 +152,7 @@ describe('neo4j instrumentation', function () { }, onCompleted: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes['test']).toBe('cool'); done(); }, @@ -167,7 +168,7 @@ describe('neo4j instrumentation', function () { const spans = getTestSpans(); expect(spans.length).toBe(3); for (let span of spans) { - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_OPERATION]).toBe('MATCH'); } }); @@ -228,7 +229,7 @@ describe('neo4j instrumentation', function () { expect(res.records.length).toBe(1); const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(JSON.parse(span.attributes['db.response'] as string)).toEqual([ { b: { labels: ['Meeseeks'], properties: { purpose: 'help' } }, @@ -253,7 +254,7 @@ describe('neo4j instrumentation', function () { .subscribe({ onCompleted: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(JSON.parse(span.attributes['db.response'] as string)).toEqual([ { b: { labels: ['Meeseeks'], properties: { purpose: 'help' } }, @@ -276,7 +277,7 @@ describe('neo4j instrumentation', function () { instrumentation.enable(); await driver.session().run('CREATE (n:MyLabel) RETURN n'); const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); }); }); @@ -286,7 +287,7 @@ describe('neo4j instrumentation', function () { return txc.run('MATCH (person:Person) RETURN person.name AS name'); }); const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_OPERATION]).toBe('MATCH'); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe( 'MATCH (person:Person) RETURN person.name AS name' @@ -298,7 +299,7 @@ describe('neo4j instrumentation', function () { return txc.run('MATCH (person:Person) RETURN person.name AS name'); }); const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_OPERATION]).toBe('MATCH'); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe( 'MATCH (person:Person) RETURN person.name AS name' @@ -325,7 +326,7 @@ describe('neo4j instrumentation', function () { .subscribe({ complete: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); done(); }, }); @@ -343,7 +344,7 @@ describe('neo4j instrumentation', function () { next: () => {}, complete: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe( 'MERGE (james:Person {name: $nameParam}) RETURN james.name AS name' ); @@ -369,7 +370,7 @@ describe('neo4j instrumentation', function () { .subscribe({ complete: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes['db.response']).toBe(`[{"n":{"labels":["MyLabel"],"properties":{}}}]`); done(); }, @@ -391,7 +392,7 @@ describe('neo4j instrumentation', function () { next: () => {}, complete: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe( 'MATCH (person:Person) RETURN person.name AS name' ); @@ -414,7 +415,7 @@ describe('neo4j instrumentation', function () { next: () => {}, complete: () => { const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); expect(span.attributes[SemanticAttributes.DB_STATEMENT]).toBe( 'MATCH (person:Person) RETURN person.name AS name' ); @@ -485,7 +486,7 @@ describe('neo4j instrumentation', function () { await routingDriver.session().run('CREATE (n:MyLabel) RETURN n'); const span = getSingleSpan(); - assertSpan(span); + assertSpan(span as ReadableSpan); }); }); }); diff --git a/packages/instrumentation-sequelize/test/sequelize.spec.ts b/packages/instrumentation-sequelize/test/sequelize.spec.ts index f52d9d1a..0d40edd9 100644 --- a/packages/instrumentation-sequelize/test/sequelize.spec.ts +++ b/packages/instrumentation-sequelize/test/sequelize.spec.ts @@ -15,7 +15,7 @@ import * as sequelize from 'sequelize'; describe('instrumentation-sequelize', () => { const getSequelizeSpans = (): ReadableSpan[] => { - return getTestSpans().filter((s) => s.instrumentationLibrary.name.includes('sequelize')); + return getTestSpans().filter((s) => s.instrumentationLibrary.name.includes('sequelize')) as ReadableSpan[]; }; beforeEach(() => { diff --git a/packages/instrumentation-socket.io/test/utils.ts b/packages/instrumentation-socket.io/test/utils.ts index 25e03802..a1c9c5d3 100644 --- a/packages/instrumentation-socket.io/test/utils.ts +++ b/packages/instrumentation-socket.io/test/utils.ts @@ -38,7 +38,7 @@ export const createServerInstance = (server?: http.Server) => { }; export const getSocketIoSpans = (): ReadableSpan[] => - getTestSpans().filter((s) => s.attributes[SemanticAttributes.MESSAGING_SYSTEM] === 'socket.io'); + getTestSpans().filter((s) => s.attributes[SemanticAttributes.MESSAGING_SYSTEM] === 'socket.io') as ReadableSpan[]; export const expectSpan = (spanName: string, callback?: (span: ReadableSpan) => void, spanCount?: number) => { const spans = getSocketIoSpans();