diff --git a/.github/workflows/daily-test.yml b/.github/workflows/daily-test.yml index d5e02e8b..ef68e6ce 100644 --- a/.github/workflows/daily-test.yml +++ b/.github/workflows/daily-test.yml @@ -31,14 +31,6 @@ jobs: env: NEO4J_AUTH: neo4j/test - rabbitmq: - image: rabbitmq:3 - ports: - - 22221:5672 - env: - RABBITMQ_DEFAULT_USER: username - RABBITMQ_DEFAULT_PASS: password - steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2b8665ba..e828c309 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,14 +30,6 @@ jobs: env: NEO4J_AUTH: neo4j/test - rabbitmq: - image: rabbitmq:3 - ports: - - 22221:5672 - env: - RABBITMQ_DEFAULT_USER: username - RABBITMQ_DEFAULT_PASS: password - steps: - uses: actions/checkout@v2 @@ -47,8 +39,13 @@ jobs: - name: Fetch all history for all tags and branches run: git fetch + - name: Use Node.js 14 + uses: actions/setup-node@v1 + with: + node-version: 14 + - name: Install Dependencies - run: yarn + run: yarn install - name: Build run: yarn build:ci diff --git a/README.md b/README.md index 272e0296..c77938fc 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The instrumentations in this repo are: - strictly complies with [open telemetry semantic conventions](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/trace/semantic_conventions) - up to date with latest SDK version -**Compatible with [SDK stable v1.0.1](https://github.com/open-telemetry/opentelemetry-js/releases/tag/stable%2Fv1.0.1) and [SDK experimental v0.27.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.27.0)** +**Compatible with [SDK stable ^1.0.0](https://github.com/open-telemetry/opentelemetry-js/tree/stable/v1.0.0) and [SDK experimental ^0.28.0](https://github.com/open-telemetry/opentelemetry-js/tree/v0.28.0/experimental/packages)** ## Instrumentations | Instrumentation Package | Instrumented Lib | NPM | | --- | --- | --- | @@ -64,6 +64,7 @@ The instrumentations in this repo are: | Instrumentations Version | OpenTelemetry Core | OpenTelemetry Experimental | | --- | --- | --- | +| 0.28.x | ^1.0.0 | ^0.28.0 | | 0.27.x | ^1.0.1 | ^0.27.0 | | 0.26.x | ^1.0.0 | ^0.26.0 | | 0.25.x | 0.25.0 | --- | diff --git a/detectors/node/resource-detector-deployment/package.json b/detectors/node/resource-detector-deployment/package.json index e9645f5d..8edcf96e 100644 --- a/detectors/node/resource-detector-deployment/package.json +++ b/detectors/node/resource-detector-deployment/package.json @@ -21,7 +21,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha", "watch": "tsc -w", @@ -33,7 +33,7 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/resources": "^1.0.0", @@ -41,7 +41,7 @@ "opentelemetry-resource-detector-sync-api": "^0.26.0" }, "devDependencies": { - "@opentelemetry/api": "^1.0.2", + "@opentelemetry/api": "^1.0.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", diff --git a/detectors/node/resource-detector-git/package.json b/detectors/node/resource-detector-git/package.json index 2d870ac7..06808d1a 100644 --- a/detectors/node/resource-detector-git/package.json +++ b/detectors/node/resource-detector-git/package.json @@ -22,7 +22,7 @@ "scripts": { "postinstall": "node dist/src/persist-on-post-install.js || exit 0", "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha", "watch": "tsc -w", @@ -34,7 +34,7 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/resources": "^1.0.0", @@ -43,7 +43,7 @@ "uuid": "^8.3.2" }, "devDependencies": { - "@opentelemetry/api": "^1.0.2", + "@opentelemetry/api": "^1.0.0", "@types/mocha": "^8.2.2", "@types/node": "^14.0.0", "expect": "^26.6.2", diff --git a/detectors/node/resource-detector-service/package.json b/detectors/node/resource-detector-service/package.json index 8d644ceb..bba98b5d 100644 --- a/detectors/node/resource-detector-service/package.json +++ b/detectors/node/resource-detector-service/package.json @@ -21,7 +21,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha", "watch": "tsc -w", @@ -33,7 +33,7 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/resources": "^1.0.0", @@ -42,7 +42,7 @@ "uuid": "^8.3.2" }, "devDependencies": { - "@opentelemetry/api": "^1.0.2", + "@opentelemetry/api": "^1.0.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", diff --git a/detectors/resource-detector-sync-api/package.json b/detectors/resource-detector-sync-api/package.json index ec5ddd98..69580f1a 100644 --- a/detectors/resource-detector-sync-api/package.json +++ b/detectors/resource-detector-sync-api/package.json @@ -21,7 +21,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "watch": "tsc -w", "version:update": "node ../../scripts/version-update.js", "version": "yarn run version:update" @@ -30,13 +30,14 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/resources": "^1.0.0" }, "devDependencies": { "ts-node": "^9.1.1", - "typescript": "4.3.4" + "typescript": "4.3.4", + "@opentelemetry/api": "^1.0.0" } } diff --git a/packages/instrumentation-elasticsearch/.tav.yml b/packages/instrumentation-elasticsearch/.tav.yml index 2641e4f1..58c3bd98 100644 --- a/packages/instrumentation-elasticsearch/.tav.yml +++ b/packages/instrumentation-elasticsearch/.tav.yml @@ -1,4 +1,4 @@ '@elastic/elasticsearch': - versions: "*" + versions: ">=5 <8" commands: - yarn test diff --git a/packages/instrumentation-elasticsearch/package.json b/packages/instrumentation-elasticsearch/package.json index 6d3199db..f8ef8980 100644 --- a/packages/instrumentation-elasticsearch/package.json +++ b/packages/instrumentation-elasticsearch/package.json @@ -29,7 +29,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "watch": "tsc -w", "version:update": "node ../../scripts/version-update.js", "version": "yarn run version:update", @@ -42,17 +42,17 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { "@elastic/elasticsearch": "^7.8.0", - "@opentelemetry/api": "^1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", "@types/chai": "^4.2.15", "@types/mocha": "^8.2.2", "chai": "^4.3.0", diff --git a/packages/instrumentation-elasticsearch/src/elasticsearch.ts b/packages/instrumentation-elasticsearch/src/elasticsearch.ts index 54355d4e..54a8eb8d 100644 --- a/packages/instrumentation-elasticsearch/src/elasticsearch.ts +++ b/packages/instrumentation-elasticsearch/src/elasticsearch.ts @@ -41,7 +41,7 @@ export class ElasticsearchInstrumentation extends InstrumentationBase new InstrumentationNodeModuleFile( `@elastic/elasticsearch/api/${path}`, - ['*'], + ['>=5 <8'], this.patch.bind(this, operationClassName), this.unpatch.bind(this) ) diff --git a/packages/instrumentation-express/package.json b/packages/instrumentation-express/package.json index bf52eddd..c1ae4459 100644 --- a/packages/instrumentation-express/package.json +++ b/packages/instrumentation-express/package.json @@ -19,7 +19,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", "watch": "tsc -w", @@ -32,20 +32,20 @@ "access": "public" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/instrumentation-http": "^0.27.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/instrumentation-http": "^0.28.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/express": "4.17.8", "@types/mocha": "^8.2.2", "axios": "0.21.1", @@ -54,6 +54,7 @@ "express": "4.17.1", "mocha": "^8.4.0", "opentelemetry-instrumentation-mocha": "0.0.1-rc.7", + "ts-node": "^9.1.1", "test-all-versions": "^5.0.1", "typescript": "4.3.4" }, 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/package.json b/packages/instrumentation-kafkajs/package.json index 19efed06..40e4e7c9 100644 --- a/packages/instrumentation-kafkajs/package.json +++ b/packages/instrumentation-kafkajs/package.json @@ -23,7 +23,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", "test:ci": "yarn test", @@ -35,16 +35,16 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "kafkajs": "^1.12.0", 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/package.json b/packages/instrumentation-mongoose/package.json index 9d36c086..2034b9f7 100644 --- a/packages/instrumentation-mongoose/package.json +++ b/packages/instrumentation-mongoose/package.json @@ -28,7 +28,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", "test:ci": "yarn test", @@ -41,17 +41,17 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "@types/node": "^14.0.0", "expect": "^26.6.2", 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/package.json b/packages/instrumentation-neo4j/package.json index 346debe4..b1b78843 100644 --- a/packages/instrumentation-neo4j/package.json +++ b/packages/instrumentation-neo4j/package.json @@ -28,7 +28,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", "test:ci": "tav", @@ -41,16 +41,16 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", 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-node-cache/package.json b/packages/instrumentation-node-cache/package.json index d94bccba..e954cdf4 100644 --- a/packages/instrumentation-node-cache/package.json +++ b/packages/instrumentation-node-cache/package.json @@ -27,7 +27,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", "test:ci": "tav", @@ -39,17 +39,17 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", diff --git a/packages/instrumentation-sequelize/package.json b/packages/instrumentation-sequelize/package.json index 0915fc0d..c085555d 100644 --- a/packages/instrumentation-sequelize/package.json +++ b/packages/instrumentation-sequelize/package.json @@ -27,7 +27,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", "test:ci": "yarn test", @@ -39,17 +39,17 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", 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/package.json b/packages/instrumentation-socket.io/package.json index 7befa196..2f405c8f 100644 --- a/packages/instrumentation-socket.io/package.json +++ b/packages/instrumentation-socket.io/package.json @@ -28,7 +28,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test:ci": "yarn test-all-versions", "test": "mocha --require @opentelemetry/contrib-test-utils", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", @@ -41,24 +41,25 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0", "is-promise": "^4.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/instrumentation-http": "^0.27.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/instrumentation-http": "^0.28.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", "opentelemetry-instrumentation-mocha": "0.0.1-rc.7", "socket.io": "^4.1.3", "socket.io-client": "^4.1.3", + "ts-node": "^9.1.1", "test-all-versions": "^5.0.1", "typescript": "4.3.4" }, 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(); diff --git a/packages/instrumentation-typeorm/package.json b/packages/instrumentation-typeorm/package.json index 0b66d692..14063ed5 100644 --- a/packages/instrumentation-typeorm/package.json +++ b/packages/instrumentation-typeorm/package.json @@ -22,7 +22,7 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha --require @opentelemetry/contrib-test-utils", "test-all-versions": "tav", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha --require @opentelemetry/contrib-test-utils", @@ -35,18 +35,18 @@ "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" }, "dependencies": { "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", + "@opentelemetry/instrumentation": "^0.28.0", "@opentelemetry/semantic-conventions": "^1.0.0", "is-promise": "^4.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", - "@opentelemetry/contrib-test-utils": "^0.28.0", - "@opentelemetry/sdk-trace-base": "1.0.1", + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/contrib-test-utils": "^0.30.0", + "@opentelemetry/sdk-trace-base": "1.2.0", "@types/mocha": "^8.2.2", "expect": "^26.6.2", "mocha": "^8.4.0", diff --git a/packages/instrumentation-typeorm/src/typeorm.ts b/packages/instrumentation-typeorm/src/typeorm.ts index d4dcb3f1..5f93296e 100644 --- a/packages/instrumentation-typeorm/src/typeorm.ts +++ b/packages/instrumentation-typeorm/src/typeorm.ts @@ -1,4 +1,4 @@ -import { Span, SpanKind, SpanStatusCode, trace, context, diag, createContextKey, Context } from '@opentelemetry/api'; +import { Span, SpanKind, SpanStatusCode, trace, context, diag } from '@opentelemetry/api'; import { suppressTracing } from '@opentelemetry/core'; import { SemanticAttributes } from '@opentelemetry/semantic-conventions'; import { ExtendedDatabaseAttribute, TypeormInstrumentationConfig } from './types'; @@ -49,14 +49,14 @@ const entityManagerMethods: EntityManagerMethods[] = [ ...functionsUsingQueryBuilder, ]; -export class TypeormInstrumentation extends InstrumentationBase { +export class TypeormInstrumentation extends InstrumentationBase { protected override _config!: TypeormInstrumentationConfig; constructor(config: TypeormInstrumentationConfig = {}) { super('opentelemetry-instrumentation-typeorm', VERSION, Object.assign({}, config)); } - protected init(): InstrumentationModuleDefinition { - const selectQueryBuilder = new InstrumentationNodeModuleFile( + protected init(): InstrumentationModuleDefinition { + const selectQueryBuilder = new InstrumentationNodeModuleFile( 'typeorm/query-builder/SelectQueryBuilder.js', ['>0.2.28'], (moduleExports, moduleVersion) => { @@ -83,9 +83,9 @@ export class TypeormInstrumentation extends InstrumentationBase } ); - const connection = new InstrumentationNodeModuleFile( + const connection = new InstrumentationNodeModuleFile( 'typeorm/connection/Connection.js', - ['>0.2.28'], + ['>0.2.28 <0.3.0'], (moduleExports, moduleVersion) => { if (isWrapped(moduleExports.Connection.prototype?.[rawQueryFuncName])) { this._unwrap(moduleExports.Connection.prototype, rawQueryFuncName); @@ -102,7 +102,26 @@ export class TypeormInstrumentation extends InstrumentationBase } ); - const entityManager = new InstrumentationNodeModuleFile( + const dataSource = new InstrumentationNodeModuleFile( + 'typeorm/data-source/DataSource.js', + ['>=0.3.0'], + (moduleExports, moduleVersion) => { + if (isWrapped(moduleExports.DataSource.prototype?.[rawQueryFuncName])) { + this._unwrap(moduleExports.DataSource.prototype, rawQueryFuncName); + } + this._wrap(moduleExports.DataSource.prototype, rawQueryFuncName, this._patchRawQuery(moduleVersion)); + + return moduleExports; + }, + (moduleExports) => { + if (isWrapped(moduleExports.DataSource.prototype?.[rawQueryFuncName])) { + this._unwrap(moduleExports.DataSource.prototype, rawQueryFuncName); + } + return moduleExports; + } + ); + + const entityManager = new InstrumentationNodeModuleFile( 'typeorm/entity-manager/EntityManager.js', ['>0.2.28'], (moduleExports, moduleVersion) => { @@ -129,10 +148,11 @@ export class TypeormInstrumentation extends InstrumentationBase } ); - const module = new InstrumentationNodeModuleDefinition('typeorm', ['>0.2.28'], null, null, [ + const module = new InstrumentationNodeModuleDefinition('typeorm', ['>0.2.28'], null, null, [ selectQueryBuilder, entityManager, connection, + dataSource, ]); return module; } diff --git a/packages/instrumentation-typeorm/test/EntityManager.spec.ts b/packages/instrumentation-typeorm/test/EntityManager.spec.ts index 5f936c79..1c29663a 100644 --- a/packages/instrumentation-typeorm/test/EntityManager.spec.ts +++ b/packages/instrumentation-typeorm/test/EntityManager.spec.ts @@ -120,7 +120,7 @@ describe('EntityManager', () => { }); describe('multiple connections', () => { - const options2: typeorm.ConnectionOptions = { + const options2: any = { name: 'connection2', type: 'sqlite', database: 'connection2.db', diff --git a/packages/instrumentation-typeorm/test/utils.ts b/packages/instrumentation-typeorm/test/utils.ts index 33367a1e..dec901ab 100644 --- a/packages/instrumentation-typeorm/test/utils.ts +++ b/packages/instrumentation-typeorm/test/utils.ts @@ -18,7 +18,9 @@ export class User { } } -export const defaultOptions: typeorm.ConnectionOptions = { +// type is typeorm.ConnectionOptions for <0.3.0 +// and typeorm.DataSourceOptions for >=0.3.0 +export const defaultOptions: any = { type: 'sqlite', database: ':memory:', dropSchema: true, @@ -26,7 +28,7 @@ export const defaultOptions: typeorm.ConnectionOptions = { entities: [User], }; -export const rawQueryOptions: typeorm.ConnectionOptions = { +export const rawQueryOptions: any = { type: 'sqlite', database: ':memory:', dropSchema: true, diff --git a/packages/propagation-utils/package.json b/packages/propagation-utils/package.json index a8c438a8..006d842b 100644 --- a/packages/propagation-utils/package.json +++ b/packages/propagation-utils/package.json @@ -27,18 +27,18 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "watch": "tsc -w" }, "bugs": { "url": "https://github.com/aspecto-io/opentelemetry-ext-js/issues" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", + "@opentelemetry/api": "^1.0.0", "@types/node": "^14.14.8", "typescript": "4.3.4" }, "peerDependencies": { - "@opentelemetry/api": "^1.0.1" + "@opentelemetry/api": "^1.0.0" } } diff --git a/packages/span-transformations/package.json b/packages/span-transformations/package.json index b02884f6..013158fb 100644 --- a/packages/span-transformations/package.json +++ b/packages/span-transformations/package.json @@ -19,19 +19,20 @@ }, "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "watch": "tsc -w", "test": "mocha" }, "dependencies": { - "@opentelemetry/api": "^1.0.2", - "@opentelemetry/core": "^1.0.1", - "@opentelemetry/sdk-trace-base": "^1.0.1" + "@opentelemetry/api": "^1.0.0", + "@opentelemetry/core": "^1.0.0", + "@opentelemetry/sdk-trace-base": "^1.0.0" }, "devDependencies": { "expect": "^26.6.2", "mocha": "^8.4.0", - "ts-node": "^10.4.0", + "@types/mocha": "^8.2.2", + "ts-node": "^9.1.1", "typescript": "4.3.4" }, "mocha": { diff --git a/propagators/propagator-selective/package.json b/propagators/propagator-selective/package.json index b78a37b8..742d5438 100644 --- a/propagators/propagator-selective/package.json +++ b/propagators/propagator-selective/package.json @@ -18,7 +18,7 @@ ], "scripts": { "build": "tsc", - "prepare": "yarn run build", + "prepare": "yarn build", "test": "mocha", "test:jaeger": "OTEL_EXPORTER_JAEGER_AGENT_HOST=localhost mocha", "watch": "tsc -w", @@ -31,9 +31,10 @@ "@opentelemetry/api": "^1.0.0" }, "devDependencies": { - "@opentelemetry/api": "1.0.2", + "@opentelemetry/api": "^1.0.0", "expect": "^26.6.2", "mocha": "^8.4.0", + "@types/mocha": "^8.2.2", "sinon": "^12.0.1", "ts-node": "^9.1.1", "typescript": "4.3.4"