diff --git a/package-lock.json b/package-lock.json index 9606105e64..ba0d938162 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7734,15 +7734,6 @@ "node": ">=14" } }, - "node_modules/@opentelemetry/api-metrics": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api-metrics/-/api-metrics-0.27.0.tgz", - "integrity": "sha512-tB79288bwjkdhPNpw4UdOEy3bacVwtol6Que7cAu8KEJ9ULjRfSiwpYEwJY/oER3xZ7zNFz0uiJ7N1jSiotpVA==", - "deprecated": "Please use @opentelemetry/api >= 1.3.0", - "engines": { - "node": ">=8.0.0" - } - }, "node_modules/@opentelemetry/auto-instrumentations-node": { "resolved": "metapackages/auto-instrumentations-node", "link": true @@ -34539,19 +34530,20 @@ }, "plugins/node/opentelemetry-instrumentation-express/examples": { "name": "express-example", - "version": "0.28.0", + "version": "0.34.1", "license": "Apache-2.0", "dependencies": { - "@opentelemetry/api": "^1.0.0", - "@opentelemetry/exporter-jaeger": "^1.0.0", - "@opentelemetry/exporter-zipkin": "^1.0.0", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/exporter-jaeger": "^1.18.1", + "@opentelemetry/exporter-trace-otlp-proto": "^0.46.0", + "@opentelemetry/exporter-zipkin": "^1.18.1", "@opentelemetry/instrumentation": "^0.46.0", - "@opentelemetry/instrumentation-express": "0.28.0", + "@opentelemetry/instrumentation-express": "^0.34.1", "@opentelemetry/instrumentation-http": "^0.46.0", - "@opentelemetry/resources": "^1.0.0", - "@opentelemetry/sdk-trace-base": "^1.0.0", - "@opentelemetry/sdk-trace-node": "^1.0.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/resources": "^1.18.1", + "@opentelemetry/sdk-trace-base": "^1.18.1", + "@opentelemetry/sdk-trace-node": "^1.18.1", + "@opentelemetry/semantic-conventions": "^1.18.1", "axios": "^1.6.0", "cross-env": "^7.0.3", "express": "^4.17.1" @@ -34618,48 +34610,6 @@ } } }, - "plugins/node/opentelemetry-instrumentation-express/node_modules/@opentelemetry/instrumentation-express": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-express/-/instrumentation-express-0.28.0.tgz", - "integrity": "sha512-pXdoisqncu8IJ0uEVAv9ZDHpZW5ocYh44lSTc5ROkkF1M/9Wl8C6VbdRCLcTU0RUA6ARpn9/xBRSatHy++chxQ==", - "dependencies": { - "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", - "@opentelemetry/semantic-conventions": "^1.0.0", - "@types/express": "4.17.13" - }, - "engines": { - "node": ">=8.5.0" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.2" - } - }, - "plugins/node/opentelemetry-instrumentation-express/node_modules/@opentelemetry/instrumentation-express/node_modules/@opentelemetry/instrumentation": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.27.0.tgz", - "integrity": "sha512-dUwY/VoDptdK8AYigwS3IKblG+unV5xIdV4VQKy+nX5aT3f7vd5PMYs4arCQSYLbLRe0s7GxK6S9dtjai/TsHQ==", - "dependencies": { - "@opentelemetry/api-metrics": "0.27.0", - "require-in-the-middle": "^5.0.3", - "semver": "^7.3.2", - "shimmer": "^1.2.1" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - } - }, - "plugins/node/opentelemetry-instrumentation-express/node_modules/@opentelemetry/instrumentation-express/node_modules/@types/express": { - "version": "4.17.13", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", - "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.18", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, "plugins/node/opentelemetry-instrumentation-express/node_modules/@types/express": { "version": "4.17.18", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.18.tgz", @@ -34828,40 +34778,6 @@ "node": ">= 0.8" } }, - "plugins/node/opentelemetry-instrumentation-express/node_modules/require-in-the-middle": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-5.2.0.tgz", - "integrity": "sha512-efCx3b+0Z69/LGJmm9Yvi4cqEdxnoGnxYxGxBghkkTTFeXRtTCmmhO0AnAfHz59k957uTSuy8WaHqOs8wbYUWg==", - "dependencies": { - "debug": "^4.1.1", - "module-details-from-path": "^1.0.3", - "resolve": "^1.22.1" - }, - "engines": { - "node": ">=6" - } - }, - "plugins/node/opentelemetry-instrumentation-express/node_modules/require-in-the-middle/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "plugins/node/opentelemetry-instrumentation-express/node_modules/require-in-the-middle/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, "plugins/node/opentelemetry-instrumentation-express/node_modules/send": { "version": "0.17.2", "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", @@ -43164,11 +43080,6 @@ "@opentelemetry/api": "^1.0.0" } }, - "@opentelemetry/api-metrics": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api-metrics/-/api-metrics-0.27.0.tgz", - "integrity": "sha512-tB79288bwjkdhPNpw4UdOEy3bacVwtol6Que7cAu8KEJ9ULjRfSiwpYEwJY/oER3xZ7zNFz0uiJ7N1jSiotpVA==" - }, "@opentelemetry/auto-instrumentations-node": { "version": "file:metapackages/auto-instrumentations-node", "requires": { @@ -43793,41 +43704,6 @@ "typescript": "4.4.4" }, "dependencies": { - "@opentelemetry/instrumentation-express": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-express/-/instrumentation-express-0.28.0.tgz", - "integrity": "sha512-pXdoisqncu8IJ0uEVAv9ZDHpZW5ocYh44lSTc5ROkkF1M/9Wl8C6VbdRCLcTU0RUA6ARpn9/xBRSatHy++chxQ==", - "requires": { - "@opentelemetry/core": "^1.0.0", - "@opentelemetry/instrumentation": "^0.27.0", - "@opentelemetry/semantic-conventions": "^1.0.0", - "@types/express": "4.17.13" - }, - "dependencies": { - "@opentelemetry/instrumentation": { - "version": "0.27.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.27.0.tgz", - "integrity": "sha512-dUwY/VoDptdK8AYigwS3IKblG+unV5xIdV4VQKy+nX5aT3f7vd5PMYs4arCQSYLbLRe0s7GxK6S9dtjai/TsHQ==", - "requires": { - "@opentelemetry/api-metrics": "0.27.0", - "require-in-the-middle": "^5.0.3", - "semver": "^7.3.2", - "shimmer": "^1.2.1" - } - }, - "@types/express": { - "version": "4.17.13", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", - "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", - "requires": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.18", - "@types/qs": "*", - "@types/serve-static": "*" - } - } - } - }, "@types/express": { "version": "4.17.18", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.18.tgz", @@ -43963,31 +43839,6 @@ "unpipe": "1.0.0" } }, - "require-in-the-middle": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-5.2.0.tgz", - "integrity": "sha512-efCx3b+0Z69/LGJmm9Yvi4cqEdxnoGnxYxGxBghkkTTFeXRtTCmmhO0AnAfHz59k957uTSuy8WaHqOs8wbYUWg==", - "requires": { - "debug": "^4.1.1", - "module-details-from-path": "^1.0.3", - "resolve": "^1.22.1" - }, - "dependencies": { - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "requires": { - "ms": "2.1.2" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - } - } - }, "send": { "version": "0.17.2", "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", @@ -51903,16 +51754,17 @@ "express-example": { "version": "file:plugins/node/opentelemetry-instrumentation-express/examples", "requires": { - "@opentelemetry/api": "^1.0.0", - "@opentelemetry/exporter-jaeger": "^1.0.0", - "@opentelemetry/exporter-zipkin": "^1.0.0", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/exporter-jaeger": "^1.18.1", + "@opentelemetry/exporter-trace-otlp-proto": "^0.46.0", + "@opentelemetry/exporter-zipkin": "^1.18.1", "@opentelemetry/instrumentation": "^0.46.0", - "@opentelemetry/instrumentation-express": "0.28.0", + "@opentelemetry/instrumentation-express": "^0.34.1", "@opentelemetry/instrumentation-http": "^0.46.0", - "@opentelemetry/resources": "^1.0.0", - "@opentelemetry/sdk-trace-base": "^1.0.0", - "@opentelemetry/sdk-trace-node": "^1.0.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/resources": "^1.18.1", + "@opentelemetry/sdk-trace-base": "^1.18.1", + "@opentelemetry/sdk-trace-node": "^1.18.1", + "@opentelemetry/semantic-conventions": "^1.18.1", "@types/express": "^4.17.13", "axios": "^1.6.0", "cross-env": "^7.0.3", diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/README.md b/plugins/node/opentelemetry-instrumentation-express/examples/README.md index acc6f74269..dd72656ff5 100644 --- a/plugins/node/opentelemetry-instrumentation-express/examples/README.md +++ b/plugins/node/opentelemetry-instrumentation-express/examples/README.md @@ -13,8 +13,11 @@ shows key aspects of tracing such as ## Installation ```sh -# from this directory -npm install +# from this directory, install all necessary dependencies from the workspace +npm run setup + +# OR alternatively, install dependencies from npm as a standalone example app +npm install --workspaces=false ``` Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html) diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/package.json b/plugins/node/opentelemetry-instrumentation-express/examples/package.json index 2f20268e96..14210b7970 100644 --- a/plugins/node/opentelemetry-instrumentation-express/examples/package.json +++ b/plugins/node/opentelemetry-instrumentation-express/examples/package.json @@ -1,19 +1,20 @@ { "name": "express-example", "private": true, - "version": "0.28.0", + "version": "0.34.1", "description": "Example of Express integration with OpenTelemetry", - "main": "index.js", "scripts": { "zipkin:server": "cross-env EXPORTER=zipkin ts-node src/server.ts", "zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts", "jaeger:server": "cross-env EXPORTER=jaeger ts-node src/server.ts", "jaeger:client": "cross-env EXPORTER=jaeger ts-node src/client.ts", - "compile": "tsc -p ." + "compile": "tsc -p .", + "setup": "cd ../../../../ && npm ci && cd plugins/node/opentelemetry-instrumentation-express && npm run compile && cd examples && npm run compile" }, "repository": { "type": "git", - "url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js.git" + "url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js-contrib.git", + "directory": "plugins/node/opentelemetry-instrumentation-express" }, "keywords": [ "opentelemetry", @@ -26,24 +27,25 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "bugs": { - "url": "https://github.com/open-telemetry/opentelemetry-js/issues" + "url": "https://github.com/open-telemetry/opentelemetry-js-contrib/issues" }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express/examples#readme", "dependencies": { - "@opentelemetry/api": "^1.0.0", - "@opentelemetry/exporter-jaeger": "^1.0.0", - "@opentelemetry/exporter-zipkin": "^1.0.0", + "@opentelemetry/api": "^1.3.0", + "@opentelemetry/exporter-jaeger": "^1.18.1", + "@opentelemetry/exporter-trace-otlp-proto": "^0.46.0", + "@opentelemetry/exporter-zipkin": "^1.18.1", "@opentelemetry/instrumentation": "^0.46.0", - "@opentelemetry/instrumentation-express": "0.28.0", + "@opentelemetry/instrumentation-express": "^0.34.1", "@opentelemetry/instrumentation-http": "^0.46.0", - "@opentelemetry/resources": "^1.0.0", - "@opentelemetry/sdk-trace-base": "^1.0.0", - "@opentelemetry/sdk-trace-node": "^1.0.0", - "@opentelemetry/semantic-conventions": "^1.0.0", + "@opentelemetry/resources": "^1.18.1", + "@opentelemetry/sdk-trace-base": "^1.18.1", + "@opentelemetry/sdk-trace-node": "^1.18.1", + "@opentelemetry/semantic-conventions": "^1.18.1", "axios": "^1.6.0", "cross-env": "^7.0.3", "express": "^4.17.1" }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", "devDependencies": { "@types/express": "^4.17.13", "ts-node": "^10.6.0", diff --git a/plugins/node/opentelemetry-instrumentation-express/examples/src/tracer.ts b/plugins/node/opentelemetry-instrumentation-express/examples/src/tracer.ts index ccc05682b6..93a1515f69 100644 --- a/plugins/node/opentelemetry-instrumentation-express/examples/src/tracer.ts +++ b/plugins/node/opentelemetry-instrumentation-express/examples/src/tracer.ts @@ -1,6 +1,6 @@ 'use strict'; -import { Sampler, SpanKind } from "@opentelemetry/api"; +import { SpanKind, Attributes } from "@opentelemetry/api"; const opentelemetry = require('@opentelemetry/api'); @@ -8,17 +8,15 @@ const opentelemetry = require('@opentelemetry/api'); const { diag, DiagConsoleLogger, DiagLogLevel } = opentelemetry; diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO); -import { AlwaysOnSampler } from '@opentelemetry/core'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; -import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'; -import { JaegerExporter } from '@opentelemetry/exporter-jaeger'; +import { Sampler, AlwaysOnSampler, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'; +import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; import { Resource } from '@opentelemetry/resources'; import { SemanticAttributes, SemanticResourceAttributes as ResourceAttributesSC } from '@opentelemetry/semantic-conventions'; -import { SpanAttributes } from "@opentelemetry/api/build/src/trace/attributes"; -const Exporter = (process.env.EXPORTER || '').toLowerCase().startsWith('z') ? ZipkinExporter : JaegerExporter; +const Exporter = (process.env.EXPORTER || '').toLowerCase().startsWith('z') ? ZipkinExporter : OTLPTraceExporter; import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'; const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); @@ -50,7 +48,7 @@ export const setupTracing = (serviceName: string) => { return opentelemetry.trace.getTracer(serviceName); }; -type FilterFunction = (spanName: string, spanKind: SpanKind, attributes: SpanAttributes) => boolean; +type FilterFunction = (spanName: string, spanKind: SpanKind, attributes: Attributes) => boolean; function filterSampler(filterFn: FilterFunction, parent: Sampler): Sampler { return { @@ -66,6 +64,6 @@ function filterSampler(filterFn: FilterFunction, parent: Sampler): Sampler { } } -function ignoreHealthCheck(spanName: string, spanKind: SpanKind, attributes: SpanAttributes) { +function ignoreHealthCheck(spanName: string, spanKind: SpanKind, attributes: Attributes) { return spanKind !== opentelemetry.SpanKind.SERVER || attributes[SemanticAttributes.HTTP_ROUTE] !== "/health"; }