diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index a3599e25c2..e70aeb73b0 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -33,7 +33,7 @@ jobs: packages/*/package-lock.json experimental/packages/*/node_modules experimental/packages/*/package-lock.json - key: node-tests-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04142022 + key: node-tests-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04292022 - name: Bootstrap run: | @@ -72,7 +72,7 @@ jobs: packages/*/package-lock.json experimental/packages/*/node_modules experimental/packages/*/package-lock.json - key: browser-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04142022 + key: browser-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04292022 - name: Bootstrap run: | @@ -112,7 +112,7 @@ jobs: packages/*/package-lock.json experimental/packages/*/node_modules experimental/packages/*/package-lock.json - key: webworker-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04142022 + key: webworker-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04292022 - name: Bootstrap run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc0c59756..523099cf3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. ### :rocket: (Enhancement) +* feat(ConsoleSpanExporter): export span links [#2917](https://github.com/open-telemetry/opentelemetry-js/pull/2917) @trentm +* feat: warn when hooked module is already loaded [#2926](https://github.com/open-telemetry/opentelemetry-js/pull/2926) @nozik + ### :bug: (Bug Fix) ### :books: (Refine Doc) @@ -36,6 +39,7 @@ All notable changes to this project will be documented in this file. * chore: require changelog entry to merge PR [#2847](https://github.com/open-telemetry/opentelemetry-js/pull/2847) @dyladan * chore: remove peer API check [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan * chore: merge lerna subdirectories into a single monorepo [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan +* chore: indent the code with eslint [#2923](https://github.com/open-telemetry/opentelemetry-js/pull/2923) @blumamir * `opentelemetry-propagator-jaeger` * [#2906](https://github.com/open-telemetry/opentelemetry-js/pull/2906) fix: support extract one digit '0' in jaeger traceFlag ([@shmilyoo](https://github.com/shmilyoo)) diff --git a/eslint.config.js b/eslint.config.js index 61d75e5009..80f6b9242f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -10,6 +10,7 @@ module.exports = { "project": "./tsconfig.json" }, rules: { + "indent": ["error", 2, { "SwitchCase": 1 }], "no-trailing-spaces": "error", "eol-last": "error", "quotes": [2, "single", { "avoidEscape": true }], diff --git a/examples/prometheus/images/prom-counter.png b/examples/prometheus/images/prom-counter.png deleted file mode 100644 index 8d05e0fe59..0000000000 Binary files a/examples/prometheus/images/prom-counter.png and /dev/null differ diff --git a/examples/prometheus/images/prom-updowncounter.png b/examples/prometheus/images/prom-updowncounter.png deleted file mode 100644 index 3caa89ba19..0000000000 Binary files a/examples/prometheus/images/prom-updowncounter.png and /dev/null differ diff --git a/examples/prometheus/index.js b/examples/prometheus/index.js deleted file mode 100644 index 8f638d66a1..0000000000 --- a/examples/prometheus/index.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const { MeterProvider } = require('@opentelemetry/sdk-metrics-base'); -const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); - -const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS; - -const exporter = new PrometheusExporter({}, () => { - console.log( - `prometheus scrape endpoint: http://localhost:${port}${endpoint}`, - ); -}); - -const meter = new MeterProvider({ - exporter, - interval: 1000, -}).getMeter('example-prometheus'); - -const requestCounter = meter.createCounter('requests', { - description: 'Example of a Counter', -}); - -const upDownCounter = meter.createUpDownCounter('test_up_down_counter', { - description: 'Example of a UpDownCounter', -}); - -const labels = { pid: process.pid, environment: 'staging' }; - -setInterval(() => { - requestCounter.add(1, labels); - upDownCounter.add(Math.random() > 0.5 ? 1 : -1, labels); -}, 1000); diff --git a/experimental/examples/.eslintrc.js b/experimental/examples/.eslintrc.js new file mode 100644 index 0000000000..7927fa0c36 --- /dev/null +++ b/experimental/examples/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + "env": { + "mocha": true, + "node": true + }, + ...require('../../eslint.config.js') +} diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/README.md b/experimental/examples/README.md similarity index 100% rename from experimental/packages/opentelemetry-sdk-metrics-base/examples/README.md rename to experimental/examples/README.md diff --git a/examples/prometheus/README.md b/experimental/examples/prometheus/README.md similarity index 100% rename from examples/prometheus/README.md rename to experimental/examples/prometheus/README.md diff --git a/experimental/examples/prometheus/images/prom-counter.png b/experimental/examples/prometheus/images/prom-counter.png new file mode 100644 index 0000000000..2628066088 Binary files /dev/null and b/experimental/examples/prometheus/images/prom-counter.png differ diff --git a/experimental/examples/prometheus/images/prom-updowncounter.png b/experimental/examples/prometheus/images/prom-updowncounter.png new file mode 100644 index 0000000000..9f595b806c Binary files /dev/null and b/experimental/examples/prometheus/images/prom-updowncounter.png differ diff --git a/experimental/examples/prometheus/index.js b/experimental/examples/prometheus/index.js new file mode 100644 index 0000000000..17da9c3b00 --- /dev/null +++ b/experimental/examples/prometheus/index.js @@ -0,0 +1,38 @@ +'use strict'; + +const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api'); +const { MeterProvider } = require('@opentelemetry/sdk-metrics-base'); +const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); + +// Optional and only needed to see the internal diagnostic logging (during development) +diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG); + +const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS; + +const exporter = new PrometheusExporter({}, () => { + console.log( + `prometheus scrape endpoint: http://localhost:${port}${endpoint}`, + ); +}); + +// Creates MeterProvider and installs the exporter as a MetricReader +const meterProvider = new MeterProvider(); +meterProvider.addMetricReader(exporter); +const meter = meterProvider.getMeter('example-prometheus'); + +// Creates metric instruments +const requestCounter = meter.createCounter('requests', { + description: 'Example of a Counter', +}); + +const upDownCounter = meter.createUpDownCounter('test_up_down_counter', { + description: 'Example of a UpDownCounter', +}); + +const attributes = { pid: process.pid, environment: 'staging' }; + +// Record metrics +setInterval(() => { + requestCounter.add(1, attributes); + upDownCounter.add(Math.random() > 0.5 ? 1 : -1, attributes); +}, 1000); diff --git a/examples/prometheus/package.json b/experimental/examples/prometheus/package.json similarity index 73% rename from examples/prometheus/package.json rename to experimental/examples/prometheus/package.json index d6b75714e1..a3c5dbca51 100644 --- a/examples/prometheus/package.json +++ b/experimental/examples/prometheus/package.json @@ -1,6 +1,6 @@ { "name": "prometheus-example", - "version": "0.25.0", + "version": "0.28.0", "description": "Example of using @opentelemetry/sdk-metrics-base and @opentelemetry/exporter-prometheus", "main": "index.js", "scripts": { @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@opentelemetry/api": "^1.0.2", - "@opentelemetry/exporter-prometheus": "0.25.0", - "@opentelemetry/sdk-metrics-base": "0.25.0" + "@opentelemetry/exporter-prometheus": "0.28.0", + "@opentelemetry/sdk-metrics-base": "0.28.0" } } diff --git a/examples/prometheus/prometheus.yml b/experimental/examples/prometheus/prometheus.yml similarity index 100% rename from examples/prometheus/prometheus.yml rename to experimental/examples/prometheus/prometheus.yml diff --git a/experimental/packages/exporter-trace-otlp-grpc/package.json b/experimental/packages/exporter-trace-otlp-grpc/package.json index 74ddcb2f5e..c63e084cff 100644 --- a/experimental/packages/exporter-trace-otlp-grpc/package.json +++ b/experimental/packages/exporter-trace-otlp-grpc/package.json @@ -60,7 +60,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts b/experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts index 7d44d4938e..fc4383f183 100644 --- a/experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts +++ b/experimental/packages/exporter-trace-otlp-grpc/test/OTLPTraceExporter.test.ts @@ -97,14 +97,14 @@ const testCollectorExporter = (params: TestParams) => ); const credentials = params.useTLS ? grpc.ServerCredentials.createSsl( - fs.readFileSync('./test/certs/ca.crt'), - [ - { - cert_chain: fs.readFileSync('./test/certs/server.crt'), - private_key: fs.readFileSync('./test/certs/server.key'), - }, - ] - ) + fs.readFileSync('./test/certs/ca.crt'), + [ + { + cert_chain: fs.readFileSync('./test/certs/server.crt'), + private_key: fs.readFileSync('./test/certs/server.key'), + }, + ] + ) : grpc.ServerCredentials.createInsecure(); server.bindAsync(address, credentials, () => { server.start(); @@ -120,10 +120,10 @@ const testCollectorExporter = (params: TestParams) => beforeEach(done => { const credentials = params.useTLS ? grpc.credentials.createSsl( - fs.readFileSync('./test/certs/ca.crt'), - fs.readFileSync('./test/certs/client.key'), - fs.readFileSync('./test/certs/client.crt') - ) + fs.readFileSync('./test/certs/ca.crt'), + fs.readFileSync('./test/certs/client.key'), + fs.readFileSync('./test/certs/client.crt') + ) : undefined; collectorExporter = new OTLPTraceExporter({ url: 'grpcs://' + address, @@ -203,12 +203,12 @@ const testCollectorExporter = (params: TestParams) => describe('export - with gzip compression', () => { beforeEach(() => { const credentials = params.useTLS - ? grpc.credentials.createSsl( + ? grpc.credentials.createSsl( fs.readFileSync('./test/certs/ca.crt'), fs.readFileSync('./test/certs/client.key'), fs.readFileSync('./test/certs/client.crt') ) - : undefined; + : undefined; collectorExporter = new OTLPTraceExporter({ url: 'grpcs://' + address, credentials, @@ -254,12 +254,12 @@ const testCollectorExporter = (params: TestParams) => const envSource = process.env; it('should return gzip compression algorithm on exporter', () => { const credentials = params.useTLS - ? grpc.credentials.createSsl( + ? grpc.credentials.createSsl( fs.readFileSync('./test/certs/ca.crt'), fs.readFileSync('./test/certs/client.key'), fs.readFileSync('./test/certs/client.crt') ) - : undefined; + : undefined; envSource.OTEL_EXPORTER_OTLP_COMPRESSION='gzip'; collectorExporter = new OTLPTraceExporter({ diff --git a/experimental/packages/exporter-trace-otlp-http/package.json b/experimental/packages/exporter-trace-otlp-http/package.json index c4e631b0b8..f7528a5349 100644 --- a/experimental/packages/exporter-trace-otlp-http/package.json +++ b/experimental/packages/exporter-trace-otlp-http/package.json @@ -84,7 +84,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts index 28411089f6..1f78f66ef6 100644 --- a/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-http/src/platform/browser/OTLPTraceExporter.ts @@ -52,9 +52,9 @@ export class OTLPTraceExporter return typeof config.url === 'string' ? config.url : getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0 - ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0 - ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH) - : DEFAULT_COLLECTOR_URL; + ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0 + ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH) + : DEFAULT_COLLECTOR_URL; } } diff --git a/experimental/packages/exporter-trace-otlp-proto/package.json b/experimental/packages/exporter-trace-otlp-proto/package.json index f1c7071e65..7367f0efd5 100644 --- a/experimental/packages/exporter-trace-otlp-proto/package.json +++ b/experimental/packages/exporter-trace-otlp-proto/package.json @@ -59,7 +59,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/exporter-trace-otlp-proto/src/OTLPTraceExporter.ts b/experimental/packages/exporter-trace-otlp-proto/src/OTLPTraceExporter.ts index bb26b949bc..e2e98de304 100644 --- a/experimental/packages/exporter-trace-otlp-proto/src/OTLPTraceExporter.ts +++ b/experimental/packages/exporter-trace-otlp-proto/src/OTLPTraceExporter.ts @@ -55,10 +55,10 @@ export class OTLPTraceExporter return typeof config.url === 'string' ? config.url : getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0 - ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT - : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0 - ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH) - : DEFAULT_COLLECTOR_URL; + ? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT + : getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0 + ? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH) + : DEFAULT_COLLECTOR_URL; } getServiceClientType() { diff --git a/experimental/packages/opentelemetry-api-metrics/package.json b/experimental/packages/opentelemetry-api-metrics/package.json index 036d5e7f9f..07e5dfa5d1 100644 --- a/experimental/packages/opentelemetry-api-metrics/package.json +++ b/experimental/packages/opentelemetry-api-metrics/package.json @@ -1,7 +1,6 @@ { "name": "@opentelemetry/api-metrics", "version": "0.28.0", - "private": true, "description": "Public metrics API for OpenTelemetry", "main": "build/src/index.js", "module": "build/esm/index.js", @@ -79,7 +78,7 @@ "mocha": "7.2.0", "nyc": "15.1.0", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0" } diff --git a/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts b/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts index 693547b7c2..1dece570f3 100644 --- a/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts +++ b/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts @@ -29,7 +29,7 @@ // eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef export const _globalThis: typeof globalThis = typeof globalThis === 'object' ? globalThis : - typeof self === 'object' ? self : - typeof window === 'object' ? window : - typeof global === 'object' ? global : + typeof self === 'object' ? self : + typeof window === 'object' ? window : + typeof global === 'object' ? global : {} as typeof globalThis; diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json index 7c21499b26..0d05d93ec0 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json @@ -60,7 +60,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json index f9a080ad0b..d896cc02ec 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json @@ -84,7 +84,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts index 7e99662ada..75a0617bec 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/src/OTLPMetricExporterBase.ts @@ -23,12 +23,12 @@ import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base'; export class OTLPMetricExporterBase> - implements PushMetricExporter { +implements PushMetricExporter { public _otlpExporter: T; protected _preferredAggregationTemporality: AggregationTemporality; constructor(exporter: T, - config: OTLPMetricExporterOptions = defaultOptions) { + config: OTLPMetricExporterOptions = defaultOptions) { this._otlpExporter = exporter; this._preferredAggregationTemporality = config.aggregationTemporality ?? AggregationTemporality.CUMULATIVE; } diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts index f5b401f304..6232752304 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/common/transformMetrics.test.ts @@ -50,114 +50,114 @@ describe('transformMetrics', () => { }); it('should convert counter', async () => { - const counter = mockCounter(); - counter.add(1); - const metrics = (await collect()); - - const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; - ensureCounterIsCorrect( - transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), - hrTimeToNanoseconds(metric.dataPoints[0].endTime), - hrTimeToNanoseconds(metric.dataPoints[0].startTime) - ); - } + const counter = mockCounter(); + counter.add(1); + const metrics = (await collect()); + + const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; + ensureCounterIsCorrect( + transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), + hrTimeToNanoseconds(metric.dataPoints[0].endTime), + hrTimeToNanoseconds(metric.dataPoints[0].startTime) + ); + } ); it('should convert double counter', async () => { - const doubleCounter = mockDoubleCounter(); - doubleCounter.add(8); - const metrics = (await collect()); - - const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; - ensureDoubleCounterIsCorrect( - transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), - hrTimeToNanoseconds(metric.dataPoints[0].endTime), - hrTimeToNanoseconds(metric.dataPoints[0].startTime), - ); - } + const doubleCounter = mockDoubleCounter(); + doubleCounter.add(8); + const metrics = (await collect()); + + const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; + ensureDoubleCounterIsCorrect( + transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), + hrTimeToNanoseconds(metric.dataPoints[0].endTime), + hrTimeToNanoseconds(metric.dataPoints[0].startTime), + ); + } ); it('should convert observable gauge', async () => { - let count = 0; - mockObservableGauge(observableResult => { - count++; - observableResult.observe(getValue(count), {}); - }); - - // collect three times. - await collect(); - await collect(); - const metrics = (await collect()); - - const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; - ensureObservableGaugeIsCorrect( - transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), - hrTimeToNanoseconds(metric.dataPoints[0].endTime), - hrTimeToNanoseconds(metric.dataPoints[0].startTime), - -1, - ); - } + let count = 0; + mockObservableGauge(observableResult => { + count++; + observableResult.observe(getValue(count), {}); + }); + + // collect three times. + await collect(); + await collect(); + const metrics = (await collect()); + + const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; + ensureObservableGaugeIsCorrect( + transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), + hrTimeToNanoseconds(metric.dataPoints[0].endTime), + hrTimeToNanoseconds(metric.dataPoints[0].startTime), + -1, + ); + } ); it('should convert observable counter', async () => { - mockObservableCounter(observableResult => { - observableResult.observe(1, {}); - }); - - // collect three times. - await collect(); - await collect(); - const metrics = (await collect()); - // TODO: Collect seems to not deliver the last observation -> why? - - const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; - ensureObservableCounterIsCorrect( - transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), - hrTimeToNanoseconds(metric.dataPoints[0].endTime), - hrTimeToNanoseconds(metric.dataPoints[0].startTime), - 2, - ); - } + mockObservableCounter(observableResult => { + observableResult.observe(1, {}); + }); + + // collect three times. + await collect(); + await collect(); + const metrics = (await collect()); + // TODO: Collect seems to not deliver the last observation -> why? + + const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; + ensureObservableCounterIsCorrect( + transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), + hrTimeToNanoseconds(metric.dataPoints[0].endTime), + hrTimeToNanoseconds(metric.dataPoints[0].startTime), + 2, + ); + } ); it('should convert observable up-down counter', async () => { - mockObservableUpDownCounter(observableResult => { - observableResult.observe(1, {}); - }); - - // collect three times. - await collect(); - await collect(); - const metrics = (await collect()); - // TODO: Collect seems to not deliver the last observation -> why? - - const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; - ensureObservableUpDownCounterIsCorrect( - transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), - hrTimeToNanoseconds(metric.dataPoints[0].endTime), - hrTimeToNanoseconds(metric.dataPoints[0].startTime), - 2, - ); - } + mockObservableUpDownCounter(observableResult => { + observableResult.observe(1, {}); + }); + + // collect three times. + await collect(); + await collect(); + const metrics = (await collect()); + // TODO: Collect seems to not deliver the last observation -> why? + + const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; + ensureObservableUpDownCounterIsCorrect( + transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), + hrTimeToNanoseconds(metric.dataPoints[0].endTime), + hrTimeToNanoseconds(metric.dataPoints[0].startTime), + 2, + ); + } ); it('should convert observable histogram', async () => { - const histogram = mockHistogram(); - histogram.record(7); - histogram.record(14); - - const metrics = (await collect()); - - const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; - ensureHistogramIsCorrect( - transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), - hrTimeToNanoseconds(metric.dataPoints[0].endTime), - hrTimeToNanoseconds(metric.dataPoints[0].startTime), - [0, 100], - [0, 2, 0] - ); - } + const histogram = mockHistogram(); + histogram.record(7); + histogram.record(14); + + const metrics = (await collect()); + + const metric = metrics.instrumentationLibraryMetrics[0].metrics[0]; + ensureHistogramIsCorrect( + transform.toCollectorMetric(metric, AggregationTemporality.CUMULATIVE), + hrTimeToNanoseconds(metric.dataPoints[0].endTime), + hrTimeToNanoseconds(metric.dataPoints[0].startTime), + [0, 100], + [0, 2, 0] + ); + } ); it('should convert metric attributes value to string', () => { diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/metricsHelper.ts b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/metricsHelper.ts index a2852771a4..a38db6ca83 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/metricsHelper.ts +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/test/metricsHelper.ts @@ -133,13 +133,13 @@ export function mockHistogram(): Histogram { const name = 'int-histogram'; meterProvider.addView({ - aggregation: new ExplicitBucketHistogramAggregation([0, 100]) - }, - { - instrument: { - name: name - } - }); + aggregation: new ExplicitBucketHistogramAggregation([0, 100]) + }, + { + instrument: { + name: name + } + }); return meter.createHistogram(name, { description: 'sample histogram description', diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json index 9f374d91a2..a69ed4d616 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json @@ -60,7 +60,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-exporter-prometheus/package.json b/experimental/packages/opentelemetry-exporter-prometheus/package.json index bb478bf88e..932bf72287 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/package.json +++ b/experimental/packages/opentelemetry-exporter-prometheus/package.json @@ -1,7 +1,6 @@ { "name": "@opentelemetry/exporter-prometheus", "version": "0.28.0", - "private": true, "description": "OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -53,7 +52,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "12.0.1", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts index 0f3d507de9..0a0747b1ef 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts @@ -209,8 +209,8 @@ describe('PrometheusExporter', () => { ); let resolve: () => void; const deferred = new Promise(res => { - resolve = res; -}); + resolve = res; + }); mockResponse.end.callsFake(() => resolve()); exporter.getMetricsRequestHandler( (mockRequest as unknown) as http.IncomingMessage, diff --git a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts index ec83b35e14..c71c01310a 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts +++ b/experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts @@ -37,8 +37,8 @@ const attributes = { class TestMetricReader extends MetricReader { constructor() { - super(AggregationTemporality.CUMULATIVE); -} + super(AggregationTemporality.CUMULATIVE); + } async onForceFlush() {} async onShutdown() {} } diff --git a/experimental/packages/opentelemetry-instrumentation-fetch/package.json b/experimental/packages/opentelemetry-instrumentation-fetch/package.json index b62a61c594..8739ed75c5 100644 --- a/experimental/packages/opentelemetry-instrumentation-fetch/package.json +++ b/experimental/packages/opentelemetry-instrumentation-fetch/package.json @@ -77,7 +77,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/package.json b/experimental/packages/opentelemetry-instrumentation-grpc/package.json index 6eb84d4ca7..1867d6fffe 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/package.json +++ b/experimental/packages/opentelemetry-instrumentation-grpc/package.json @@ -64,7 +64,7 @@ "rimraf": "3.0.2", "semver": "7.3.5", "sinon": "12.0.1", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/test/helper.ts b/experimental/packages/opentelemetry-instrumentation-grpc/test/helper.ts index 5620f233dc..5564c7c964 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/test/helper.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/test/helper.ts @@ -104,8 +104,8 @@ const checkEqual = (x: TestRequestResponse | TestRequestResponse[]) => ( x instanceof Array && y instanceof Array ? arrayIsEqual(requestEqual)(x as any)(y as any) : !(x instanceof Array) && !(y instanceof Array) - ? requestEqual(x)(y) - : false; + ? requestEqual(x)(y) + : false; export const runTests = ( plugin: GrpcInstrumentation, @@ -292,7 +292,7 @@ export const runTests = ( 'Unary Method Error', call.request.num ) as grpcJs.ServiceError - ) + ) : callback(null, { num: call.request.num }); }, @@ -304,7 +304,7 @@ export const runTests = ( 'Unary Method Error', call.request.num ) as grpcJs.ServiceError - ) + ) : callback(null, { num: call.request.num }); }, diff --git a/experimental/packages/opentelemetry-instrumentation-http/package.json b/experimental/packages/opentelemetry-instrumentation-http/package.json index e75414c193..3549375824 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/package.json +++ b/experimental/packages/opentelemetry-instrumentation-http/package.json @@ -67,7 +67,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "superagent": "6.1.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts index 07dc688fac..c0c01b762c 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts @@ -683,7 +683,7 @@ export class HttpInstrumentation extends InstrumentationBase { private _callStartSpanHook( request: http.IncomingMessage | http.RequestOptions, hookFunc: Function | undefined, - ) { + ) { if(typeof hookFunc === 'function'){ return safeExecuteInTheMiddle( () => hookFunc(request), diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/types.ts b/experimental/packages/opentelemetry-instrumentation-http/src/types.ts index 6741d0a042..c0f2adab34 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/types.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/types.ts @@ -16,7 +16,7 @@ import { Span, SpanAttributes, - } from '@opentelemetry/api'; +} from '@opentelemetry/api'; import type * as http from 'http'; import type * as https from 'https'; import { diff --git a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts index 3735e530f9..5f1c11d4a7 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts @@ -100,10 +100,10 @@ describe('Packages', () => { const urlparsed = url.parse( name === 'got' && process.versions.node.startsWith('12') ? // there is an issue with got 9.6 version and node 12 when redirecting so url above will not work - // https://github.com/nock/nock/pull/1551 - // https://github.com/sindresorhus/got/commit/bf1aa5492ae2bc78cbbec6b7d764906fb156e6c2#diff-707a4781d57c42085155dcb27edb9ccbR258 - // TODO: check if this is still the case when new version - 'https://www.google.com' + // https://github.com/nock/nock/pull/1551 + // https://github.com/sindresorhus/got/commit/bf1aa5492ae2bc78cbbec6b7d764906fb156e6c2#diff-707a4781d57c42085155dcb27edb9ccbR258 + // TODO: check if this is still the case when new version + 'https://www.google.com' : 'https://www.google.com/search?q=axios&oq=axios&aqs=chrome.0.69i59l2j0l3j69i60.811j0j7&sourceid=chrome&ie=UTF-8' ); const result = await httpPackage.get(urlparsed.href!); diff --git a/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json b/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json index 7b89a2073f..99e812244b 100644 --- a/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -77,7 +77,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/experimental/packages/opentelemetry-instrumentation/package.json b/experimental/packages/opentelemetry-instrumentation/package.json index 2f83e703fd..21e407bad9 100644 --- a/experimental/packages/opentelemetry-instrumentation/package.json +++ b/experimental/packages/opentelemetry-instrumentation/package.json @@ -100,7 +100,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts b/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts index 687b611501..fb9f53fc70 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts @@ -30,7 +30,7 @@ import * as types from './types'; * Base abstract internal class for instrumenting node and web plugins */ export abstract class InstrumentationAbstract - implements types.Instrumentation { +implements types.Instrumentation { protected _config: types.InstrumentationConfig; private _tracer: Tracer; diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index f67476930d..09d6a86b29 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -59,6 +59,21 @@ export abstract class InstrumentationBase } } + private _warnOnPreloadedModules(): void { + this._modules.forEach((module: InstrumentationModuleDefinition) => { + const { name } = module; + try { + const resolvedModule = require.resolve(name); + if (require.cache[resolvedModule]) { + // Module is already cached, which means the instrumentation hook might not work + this._diag.warn(`Module ${name} has been loaded before ${this.instrumentationName} so it might not work, please initialize it before requiring ${name}`); + } + } catch { + // Module isn't available, we can simply skip + } + }); + } + private _extractPackageVersion(baseDir: string): string | undefined { try { // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -134,6 +149,7 @@ export abstract class InstrumentationBase return; } + this._warnOnPreloadedModules(); for (const module of this._modules) { this._hooks.push( RequireInTheMiddle( diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts index 9014dcdeeb..8d4885c7b9 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleDefinition.ts @@ -20,7 +20,7 @@ import { } from './types'; export class InstrumentationNodeModuleDefinition - implements InstrumentationModuleDefinition { +implements InstrumentationModuleDefinition { files: InstrumentationModuleFile[]; constructor( public name: string, diff --git a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts index bf5a9a71c1..80b617c5d7 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentationNodeModuleFile.ts @@ -18,7 +18,7 @@ import { InstrumentationModuleFile } from './types'; import { normalize } from 'path'; export class InstrumentationNodeModuleFile - implements InstrumentationModuleFile { +implements InstrumentationModuleFile { public name: string; constructor( name: string, diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/.eslintrc.json b/experimental/packages/opentelemetry-sdk-metrics-base/examples/.eslintrc.json deleted file mode 100644 index 6000f93619..0000000000 --- a/experimental/packages/opentelemetry-sdk-metrics-base/examples/.eslintrc.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "env": { - "node": true - }, - "extends": "airbnb-base", - "parserOptions": { - "sourceType": "script" - }, - "rules": { - "strict": ["error", "global"], - "no-use-before-define": ["error", "nofunc"], - "no-console": "off", - "import/no-unresolved": "off", - "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }] - }, - "ignorePatterns": "**/*_pb.js" -} diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/README.md b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/README.md deleted file mode 100644 index 5578b239c3..0000000000 --- a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Overview - -OpenTelemetry metrics allow a user to collect data and export it to a metrics backend like Prometheus. - -This is a simple example that demonstrates basic metrics collection and exports those metrics to a Prometheus compatible endpoint. - -## Installation - -```sh -# from this directory -npm install -``` - -How to setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/) please check -[Setup Prometheus](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-exporter-prometheus) - -## Run the Application - -- Run the example - -### Observer - -```sh -npm run start:observer -``` - -### Prometheus - -1. In prometheus search for "cpu_core_usage", "cpu_temp_per_app", "cpu_usage_per_app" - -### Links - -1. Prometheus Scrape Endpoint -2. Prometheus graph - -### Example - -![Screenshot of the running example](metrics/observer.png) -![Screenshot of the running example](metrics/observer_batch.png) -![Screenshot of the running example](metrics/observer_batch2.png) - -## Useful links - -- For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry metrics, visit: - -## LICENSE - -Apache License 2.0 diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js deleted file mode 100644 index 87d0e3817c..0000000000 --- a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -const { MeterProvider } = require('@opentelemetry/sdk-metrics-base'); -const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api'); -const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); - -// Optional and only needed to see the internal diagnostic logging (during development) -diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG); - -const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS; - -const exporter = new PrometheusExporter({}, () => { - console.log( - `prometheus scrape endpoint: http://localhost:${port}${endpoint}`, - ); -}); - -const meter = new MeterProvider({ - exporter, - interval: 2000, -}).getMeter('example-meter'); - -// async callback - for operation that needs to wait for value -meter.createObservableGauge('cpu_core_usage', { - description: 'Example of an async observable gauge with callback', -}, async (observableResult) => { - const value = await getAsyncValue(); - observableResult.observe(value, { core: '1' }); - observableResult.observe(value, { core: '2' }); -}); - -function getAsyncValue() { - return new Promise((resolve) => { - setTimeout(() => { - resolve(Math.random()); - }, 100); - }); -} - -setInterval(function () { - console.log("simulating an app being kept open") -}, 5000); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.png b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.png deleted file mode 100644 index b8c3c48910..0000000000 Binary files a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer.png and /dev/null differ diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer_batch.png b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer_batch.png deleted file mode 100644 index 32b5f25fe2..0000000000 Binary files a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer_batch.png and /dev/null differ diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer_batch2.png b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer_batch2.png deleted file mode 100644 index a8792e913a..0000000000 Binary files a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/metrics/observer_batch2.png and /dev/null differ diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/package.json b/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/package.json deleted file mode 100644 index eb518107c5..0000000000 --- a/experimental/packages/opentelemetry-sdk-metrics-base/examples/metrics/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "example-metrics", - "private": true, - "version": "0.27.0", - "description": "Example of using @opentelemetry/sdk-metrics-base", - "main": "index.js", - "scripts": { - "start:observer": "node metrics/observer.js" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js.git" - }, - "keywords": [ - "opentelemetry", - "http", - "tracing", - "metrics" - ], - "engines": { - "node": ">=8" - }, - "author": "OpenTelemetry Authors", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/open-telemetry/opentelemetry-js/issues" - }, - "dependencies": { - "@opentelemetry/api": "^1.0.0", - "@opentelemetry/core": "^1.1.1", - "@opentelemetry/exporter-prometheus": "^0.27.0", - "@opentelemetry/sdk-metrics-base": "^0.27.0" - }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme" -} diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/package.json b/experimental/packages/opentelemetry-sdk-metrics-base/package.json index 1d73fd526d..09dbd8c8b2 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/package.json +++ b/experimental/packages/opentelemetry-sdk-metrics-base/package.json @@ -1,7 +1,6 @@ { "name": "@opentelemetry/sdk-metrics-base", "version": "0.28.0", - "private": true, "description": "Work in progress OpenTelemetry metrics SDK", "main": "build/src/index.js", "module": "build/esm/index.js", @@ -71,7 +70,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "11.1.2", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlwaysSampleExemplarFilter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlwaysSampleExemplarFilter.ts index 83859dd326..d2c52cdc0e 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlwaysSampleExemplarFilter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/AlwaysSampleExemplarFilter.ts @@ -27,6 +27,6 @@ export class AlwaysSampleExemplarFilter implements ExemplarFilter { _attributes: MetricAttributes, _ctx: Context ): boolean { - return true; + return true; } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/ExemplarReservoir.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/ExemplarReservoir.ts index 6d1245d33b..190976502e 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/ExemplarReservoir.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/ExemplarReservoir.ts @@ -67,7 +67,7 @@ class ExemplarBucket { collect(pointAttributes: MetricAttributes): Exemplar | null { if (!this._offered) return null; const currentAttributes = this.attributes; - // filter attributes + // filter attributes Object.keys(pointAttributes).forEach(key => { if (pointAttributes[key] === currentAttributes[key]) { delete currentAttributes[key]; diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/NeverSampleExemplarFilter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/NeverSampleExemplarFilter.ts index 1f40143f1f..374f35e52f 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/NeverSampleExemplarFilter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/exemplar/NeverSampleExemplarFilter.ts @@ -26,6 +26,6 @@ export class NeverSampleExemplarFilter implements ExemplarFilter { _attributes: MetricAttributes, _ctx: Context ): boolean { - return false; + return false; } } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricExporter.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricExporter.ts index 2d84d94eac..06375d4da5 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricExporter.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/export/MetricExporter.ts @@ -41,9 +41,9 @@ export class ConsoleMetricExporter implements PushMetricExporter { export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void) { return resultCallback({ - code: ExportResultCode.FAILED, - error: new Error('Method not implemented') - }); + code: ExportResultCode.FAILED, + error: new Error('Method not implemented') + }); } getPreferredAggregationTemporality() { diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/src/utils.ts b/experimental/packages/opentelemetry-sdk-metrics-base/src/utils.ts index 3b08c43b78..b1bdbf7bd7 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/src/utils.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/src/utils.ts @@ -83,11 +83,11 @@ export function callWithTimeout(promise: Promise, timeout: number): Promis }); return Promise.race([promise, timeoutPromise]).then(result => { - clearTimeout(timeoutHandle); - return result; - }, - reason => { - clearTimeout(timeoutHandle); - throw reason; - }); + clearTimeout(timeoutHandle); + return result; + }, + reason => { + clearTimeout(timeoutHandle); + throw reason; + }); } diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/MeterProvider.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/MeterProvider.test.ts index 814044891a..eff5223e29 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/MeterProvider.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/MeterProvider.test.ts @@ -116,13 +116,13 @@ describe('MeterProvider', () => { // Throws with wildcard character only. assert.throws(() => meterProvider.addView({ - name: 'renamed-instrument' - }, - { - instrument: { - name: '*' - } - })); + name: 'renamed-instrument' + }, + { + instrument: { + name: '*' + } + })); // Throws with wildcard character in instrument name. assert.throws(() => meterProvider.addView({ @@ -138,13 +138,13 @@ describe('MeterProvider', () => { const meterProvider = new MeterProvider({ resource: defaultResource }); assert.throws(() => meterProvider.addView({ - name: 'renamed-instrument' - }, - { - instrument: { - type: InstrumentType.COUNTER - } - })); + name: 'renamed-instrument' + }, + { + instrument: { + type: InstrumentType.COUNTER + } + })); }); it('with named view and no instrument selector should throw', () => { @@ -155,9 +155,9 @@ describe('MeterProvider', () => { })); assert.throws(() => meterProvider.addView({ - name: 'renamed-instrument' - }, - {})); + name: 'renamed-instrument' + }, + {})); }); it('with no view parameters should throw', () => { @@ -174,14 +174,14 @@ describe('MeterProvider', () => { // Add view to rename 'non-renamed-instrument' to 'renamed-instrument' meterProvider.addView({ - name: 'renamed-instrument', - description: 'my renamed instrument' + name: 'renamed-instrument', + description: 'my renamed instrument' + }, + { + instrument: { + name: 'non-renamed-instrument', }, - { - instrument: { - name: 'non-renamed-instrument', - }, - }); + }); // Create meter and instrument. const myMeter = meterProvider.getMeter('meter1', 'v1.0.0'); @@ -233,13 +233,13 @@ describe('MeterProvider', () => { // Add view to drop all attributes except 'attrib1' meterProvider.addView({ - attributeKeys: ['attrib1'] - }, - { - instrument: { - name: 'non-renamed-instrument', - } - }); + attributeKeys: ['attrib1'] + }, + { + instrument: { + name: 'non-renamed-instrument', + } + }); // Create meter and instrument. const myMeter = meterProvider.getMeter('meter1', 'v1.0.0'); @@ -289,13 +289,13 @@ describe('MeterProvider', () => { // Add view that renames 'test-counter' to 'renamed-instrument' meterProvider.addView({ - name: 'renamed-instrument' - }, - { - instrument: { - name: 'test-counter' - } - }); + name: 'renamed-instrument' + }, + { + instrument: { + name: 'test-counter' + } + }); // Create two meters. const meter1 = meterProvider.getMeter('meter1', 'v1.0.0'); @@ -354,16 +354,16 @@ describe('MeterProvider', () => { // Add view that renames 'test-counter' to 'renamed-instrument' on 'meter1' meterProvider.addView({ - name: 'renamed-instrument' + name: 'renamed-instrument' + }, + { + instrument: { + name: 'test-counter' }, - { - instrument: { - name: 'test-counter' - }, - meter: { - name: 'meter1' - } - }); + meter: { + name: 'meter1' + } + }); // Create two meters. const meter1 = meterProvider.getMeter('meter1', 'v1.0.0'); @@ -421,28 +421,28 @@ describe('MeterProvider', () => { // Add Views to rename both instruments (of different types) to the same name. meterProvider.addView({ - name: 'renamed-instrument' + name: 'renamed-instrument' + }, + { + instrument: { + name: 'test-counter' }, - { - instrument: { - name: 'test-counter' - }, - meter: { - name: 'meter1' - } - }); + meter: { + name: 'meter1' + } + }); meterProvider.addView({ - name: 'renamed-instrument' + name: 'renamed-instrument' + }, + { + instrument: { + name: 'test-histogram' }, - { - instrument: { - name: 'test-histogram' - }, - meter: { - name: 'meter1' - } - }); + meter: { + name: 'meter1' + } + }); // Create meter and instruments. const meter = meterProvider.getMeter('meter1', 'v1.0.0'); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/export/PeriodicExportingMetricReader.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/export/PeriodicExportingMetricReader.test.ts index 1cde6184c2..f5f30e03ab 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/export/PeriodicExportingMetricReader.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/export/PeriodicExportingMetricReader.test.ts @@ -108,10 +108,10 @@ describe('PeriodicExportingMetricReader', () => { it('should construct PeriodicExportingMetricReader without exceptions', () => { const exporter = new TestDeltaMetricExporter(); const reader = new PeriodicExportingMetricReader({ - exporter: exporter, - exportIntervalMillis: 4000, - exportTimeoutMillis: 3000 - } + exporter: exporter, + exportIntervalMillis: 4000, + exportTimeoutMillis: 3000 + } ); assert.strictEqual(reader.getPreferredAggregationTemporality(), exporter.getPreferredAggregationTemporality()); }); diff --git a/experimental/packages/opentelemetry-sdk-metrics-base/test/state/MetricStorageRegistry.test.ts b/experimental/packages/opentelemetry-sdk-metrics-base/test/state/MetricStorageRegistry.test.ts index cd355a6d54..163cd762ff 100644 --- a/experimental/packages/opentelemetry-sdk-metrics-base/test/state/MetricStorageRegistry.test.ts +++ b/experimental/packages/opentelemetry-sdk-metrics-base/test/state/MetricStorageRegistry.test.ts @@ -32,9 +32,9 @@ import { class TestMetricStorage extends MetricStorage { collect(collector: MetricCollectorHandle, - collectors: MetricCollectorHandle[], - sdkStartTime: HrTime, - collectionTime: HrTime, + collectors: MetricCollectorHandle[], + sdkStartTime: HrTime, + collectionTime: HrTime, ): Promise> { return Promise.resolve(undefined); } @@ -74,8 +74,8 @@ describe('MetricStorageRegistry', () => { }); function testConflictingRegistration(existingDescriptor: InstrumentDescriptor, - otherDescriptor: InstrumentDescriptor, - expectedLog: string) { + otherDescriptor: InstrumentDescriptor, + expectedLog: string) { const registry = new MetricStorageRegistry(); const storage = new TestMetricStorage(existingDescriptor); diff --git a/experimental/packages/opentelemetry-sdk-node/package.json b/experimental/packages/opentelemetry-sdk-node/package.json index 84ff5b699a..ce20bb42d9 100644 --- a/experimental/packages/opentelemetry-sdk-node/package.json +++ b/experimental/packages/opentelemetry-sdk-node/package.json @@ -73,7 +73,7 @@ "semver": "7.3.5", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" } } diff --git a/experimental/packages/otlp-exporter-base/package.json b/experimental/packages/otlp-exporter-base/package.json index d82df98eaf..4368373947 100644 --- a/experimental/packages/otlp-exporter-base/package.json +++ b/experimental/packages/otlp-exporter-base/package.json @@ -69,7 +69,7 @@ "nyc": "15.1.0", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/otlp-grpc-exporter-base/package.json b/experimental/packages/otlp-grpc-exporter-base/package.json index d8066b89b7..e3c34d8c02 100644 --- a/experimental/packages/otlp-grpc-exporter-base/package.json +++ b/experimental/packages/otlp-grpc-exporter-base/package.json @@ -61,7 +61,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "@opentelemetry/sdk-trace-base": "1.2.0", "@opentelemetry/resources": "1.2.0", diff --git a/experimental/packages/otlp-proto-exporter-base/package.json b/experimental/packages/otlp-proto-exporter-base/package.json index bf95c9936c..98e0e27c40 100644 --- a/experimental/packages/otlp-proto-exporter-base/package.json +++ b/experimental/packages/otlp-proto-exporter-base/package.json @@ -7,7 +7,6 @@ "repository": "open-telemetry/opentelemetry-js", "scripts": { "prepublishOnly": "npm run compile", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", "compile": "tsc --build", "clean": "tsc --build --clean", "lint": "eslint . --ext .ts", @@ -15,8 +14,6 @@ "postcompile": "npm run submodule && npm run protos:copy", "protos:copy": "cpx protos/opentelemetry/**/*.* build/protos/opentelemetry", "submodule": "git submodule sync --recursive && git submodule update --init --recursive", - "tdd": "npm run test -- --watch-extensions ts --watch", - "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", "version": "node ../../../scripts/version-update.js", "watch": "npm run protos:copy && tsc -w", "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies", @@ -61,7 +58,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/experimental/packages/otlp-transformer/package.json b/experimental/packages/otlp-transformer/package.json index 15de49efef..9ec6ec2d84 100644 --- a/experimental/packages/otlp-transformer/package.json +++ b/experimental/packages/otlp-transformer/package.json @@ -64,7 +64,7 @@ "protobufjs": "6.11.2", "rimraf": "3.0.2", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0" }, diff --git a/experimental/packages/otlp-transformer/src/metrics/index.ts b/experimental/packages/otlp-transformer/src/metrics/index.ts index e5a8560ded..9022048c29 100644 --- a/experimental/packages/otlp-transformer/src/metrics/index.ts +++ b/experimental/packages/otlp-transformer/src/metrics/index.ts @@ -20,7 +20,7 @@ import type { IExportMetricsServiceRequest } from './types'; import { AggregationTemporality } from '@opentelemetry/sdk-metrics-base'; export function createExportMetricsServiceRequest(resourceMetrics: ResourceMetrics, - aggregationTemporality: AggregationTemporality): IExportMetricsServiceRequest | null { + aggregationTemporality: AggregationTemporality): IExportMetricsServiceRequest | null { return { resourceMetrics: [{ resource: { diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 436ebeb04b..288e278499 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -51,7 +51,7 @@ "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts index 4eb200c0aa..7c8748f258 100644 --- a/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts +++ b/packages/opentelemetry-context-async-hooks/src/AbstractAsyncHooksContextManager.ts @@ -37,7 +37,7 @@ const ADD_LISTENER_METHODS = [ ]; export abstract class AbstractAsyncHooksContextManager - implements ContextManager { +implements ContextManager { abstract active(): Context; abstract with ReturnType>( diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index 0c95368433..382226ecc4 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -74,7 +74,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts b/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts index d612d4ca6b..542221be59 100644 --- a/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts +++ b/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts @@ -272,13 +272,13 @@ describe('ZoneContextManager', () => { const fn: any = contextManager.bind( context, () => { - assert.strictEqual( - contextManager.active(), - context, - 'should have context' - ); - return done(); - }); + assert.strictEqual( + contextManager.active(), + context, + 'should have context' + ); + return done(); + }); fn(); }); diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index 30a1e944b3..38e377a1f4 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -67,7 +67,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 9a801c8b74..40ce2d42de 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -83,7 +83,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0" }, diff --git a/packages/opentelemetry-core/src/baggage/utils.ts b/packages/opentelemetry-core/src/baggage/utils.ts index f75fe0cfc9..390b143ca7 100644 --- a/packages/opentelemetry-core/src/baggage/utils.ts +++ b/packages/opentelemetry-core/src/baggage/utils.ts @@ -26,7 +26,7 @@ type ParsedBaggageKeyValue = { key: string, value: string, metadata: BaggageEntr export function serializeKeyPairs(keyPairs: string[]): string { return keyPairs.reduce((hValue: string, current: string) => { const value = `${hValue}${hValue !== '' ? BAGGAGE_ITEMS_SEPARATOR : '' - }${current}`; + }${current}`; return value.length > BAGGAGE_MAX_TOTAL_LENGTH ? hValue : value; }, ''); } diff --git a/packages/opentelemetry-core/src/platform/browser/globalThis.ts b/packages/opentelemetry-core/src/platform/browser/globalThis.ts index 53dd1c3d02..aa3c2fec6e 100644 --- a/packages/opentelemetry-core/src/platform/browser/globalThis.ts +++ b/packages/opentelemetry-core/src/platform/browser/globalThis.ts @@ -29,7 +29,7 @@ // eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef export const _globalThis: typeof globalThis = typeof globalThis === 'object' ? globalThis : - typeof self === 'object' ? self : - typeof window === 'object' ? window : - typeof global === 'object' ? global : + typeof self === 'object' ? self : + typeof window === 'object' ? window : + typeof global === 'object' ? global : {} as typeof globalThis; diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 35338937d3..89996f6ee7 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -55,7 +55,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "12.0.1", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index a0c5da8880..3823760b53 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -81,7 +81,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index e65cecd0f7..4378881407 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -66,7 +66,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" } } diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index 73b2fe84c5..d999c984d9 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -72,7 +72,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0" }, diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 7528fa097f..f728e93efc 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -77,7 +77,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "12.0.1", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/packages/opentelemetry-resources/src/platform/browser/default-service-name.ts b/packages/opentelemetry-resources/src/platform/browser/default-service-name.ts index eebfb121e7..0811da9cf6 100644 --- a/packages/opentelemetry-resources/src/platform/browser/default-service-name.ts +++ b/packages/opentelemetry-resources/src/platform/browser/default-service-name.ts @@ -15,5 +15,5 @@ */ export function defaultServiceName(): string { - return 'unknown_service'; + return 'unknown_service'; } diff --git a/packages/opentelemetry-resources/src/platform/node/default-service-name.ts b/packages/opentelemetry-resources/src/platform/node/default-service-name.ts index c1df6d22fb..8b3b1a3b54 100644 --- a/packages/opentelemetry-resources/src/platform/node/default-service-name.ts +++ b/packages/opentelemetry-resources/src/platform/node/default-service-name.ts @@ -15,5 +15,5 @@ */ export function defaultServiceName(): string { - return `unknown_service:${process.argv0}`; + return `unknown_service:${process.argv0}`; } diff --git a/packages/opentelemetry-sdk-trace-base/package.json b/packages/opentelemetry-sdk-trace-base/package.json index d7c760e83e..57486815d6 100644 --- a/packages/opentelemetry-sdk-trace-base/package.json +++ b/packages/opentelemetry-sdk-trace-base/package.json @@ -80,7 +80,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0" }, diff --git a/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts b/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts index 60f803c5d0..57baa62d3a 100644 --- a/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts +++ b/packages/opentelemetry-sdk-trace-base/src/export/ConsoleSpanExporter.ts @@ -65,6 +65,7 @@ export class ConsoleSpanExporter implements SpanExporter { attributes: span.attributes, status: span.status, events: span.events, + links: span.links }; } @@ -78,7 +79,7 @@ export class ConsoleSpanExporter implements SpanExporter { done?: (result: ExportResult) => void ): void { for (const span of spans) { - console.log(this._exportInfo(span)); + console.dir(this._exportInfo(span), { depth: 3 }); } if (done) { return done({ code: ExportResultCode.SUCCESS }); diff --git a/packages/opentelemetry-sdk-trace-base/test/common/Tracer.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/Tracer.test.ts index 7918bbc951..71453bb260 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/Tracer.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/Tracer.test.ts @@ -67,14 +67,14 @@ describe('Tracer', () => { } class DummySpanProcessor implements SpanProcessor { - forceFlush () { - return Promise.resolve(); - } - onStart() {} - onEnd() {} - shutdown() { - return Promise.resolve(); - } + forceFlush () { + return Promise.resolve(); + } + onStart() {} + onEnd() {} + shutdown() { + return Promise.resolve(); + } } beforeEach(() => { diff --git a/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts b/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts index 8e5e40adfb..0a66b13fc2 100644 --- a/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts +++ b/packages/opentelemetry-sdk-trace-base/test/common/export/ConsoleSpanExporter.test.ts @@ -14,6 +14,10 @@ * limitations under the License. */ +import { + SpanContext, + TraceFlags, +} from '@opentelemetry/api'; import { AlwaysOnSampler } from '@opentelemetry/core'; import * as assert from 'assert'; import * as sinon from 'sinon'; @@ -26,16 +30,16 @@ import { /* eslint-disable no-console */ describe('ConsoleSpanExporter', () => { let consoleExporter: ConsoleSpanExporter; - let previousConsoleLog: any; + let previousConsoleDir: any; beforeEach(() => { - previousConsoleLog = console.log; - console.log = () => {}; + previousConsoleDir = console.dir; + console.dir = () => {}; consoleExporter = new ConsoleSpanExporter(); }); afterEach(() => { - console.log = previousConsoleLog; + console.dir = previousConsoleDir; }); describe('.export()', () => { @@ -46,14 +50,22 @@ describe('ConsoleSpanExporter', () => { }); consoleExporter = new ConsoleSpanExporter(); - const spyConsole = sinon.spy(console, 'log'); + const spyConsole = sinon.spy(console, 'dir'); const spyExport = sinon.spy(consoleExporter, 'export'); basicTracerProvider.addSpanProcessor( new SimpleSpanProcessor(consoleExporter) ); - const span = basicTracerProvider.getTracer('default').startSpan('foo'); + const tracer = basicTracerProvider.getTracer('default'); + const context: SpanContext = { + traceId: 'a3cda95b652f4a1592b449d5929fda1b', + spanId: '5e0c63257de34c92', + traceFlags: TraceFlags.SAMPLED, + }; + const span = tracer.startSpan('foo', { + links: [ { context, attributes: { anAttr: 'aValue' } } ] + }); span.addEvent('foobar'); span.end(); @@ -70,6 +82,7 @@ describe('ConsoleSpanExporter', () => { 'events', 'id', 'kind', + 'links', 'name', 'parentId', 'status', @@ -80,7 +93,7 @@ describe('ConsoleSpanExporter', () => { assert.ok(firstSpan.name === 'foo'); assert.ok(firstEvent.name === 'foobar'); assert.ok(consoleSpan.id === firstSpan.spanContext().spanId); - assert.ok(keys === expectedKeys); + assert.ok(keys === expectedKeys, 'expectedKeys'); assert.ok(spyExport.calledOnce); }); diff --git a/packages/opentelemetry-sdk-trace-node/package.json b/packages/opentelemetry-sdk-trace-node/package.json index c6a053d7f9..cb06312053 100644 --- a/packages/opentelemetry-sdk-trace-node/package.json +++ b/packages/opentelemetry-sdk-trace-node/package.json @@ -57,7 +57,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "12.0.1", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": { diff --git a/packages/opentelemetry-sdk-trace-web/package.json b/packages/opentelemetry-sdk-trace-web/package.json index 467c0f7ccd..00e3cee96f 100644 --- a/packages/opentelemetry-sdk-trace-web/package.json +++ b/packages/opentelemetry-sdk-trace-web/package.json @@ -81,7 +81,7 @@ "rimraf": "3.0.2", "sinon": "12.0.1", "ts-loader": "8.3.0", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4", "webpack": "4.46.0", "webpack-cli": "4.9.1", diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index 315c67d343..df190a8b7d 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -13,8 +13,6 @@ "clean": "tsc --build --clean tsconfig.all.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", - "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", - "tdd": "npm run test -- --watch-extensions ts --watch", "version": "node ../../scripts/version-update.js", "watch": "tsc --build --watch tsconfig.all.json", "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies", @@ -60,7 +58,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "12.0.1", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" } } diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 91964a4eda..0e80137985 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -52,7 +52,7 @@ "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", - "ts-mocha": "8.0.0", + "ts-mocha": "9.0.2", "typescript": "4.4.4" }, "peerDependencies": {