diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15f0c22583..11e38bf053 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -163,9 +163,9 @@ npm run lint:fix ### Adding a package -To add a new package, copy `packages/template` to your new package directory and modify the `package.json` file to reflect your desired package settings. If the package will not support browser, the `karma.conf` file may be deleted. If the package will support es5 targets, the reference to `tsconfig.base.json` in `tsconfig.json` should be changed to `tsconfig.es5.json`. +To add a new package, copy `packages/template` to your new package directory and modify the `package.json` file to reflect your desired package settings. If the package will not support browser, the `karma.conf` and `tsconifg.esm.json` files may be deleted. If the package will support es5 targets, the reference to `tsconfig.base.json` in `tsconfig.json` should be changed to `tsconfig.es5.json`. -After adding the package, run `npm install` from the root of the project. This will update the `tsconfig.json` project references automatically and install all dependencies in your new package. +After adding the package, run `npm install` from the root of the project. This will update the `tsconfig.json` project references automatically and install all dependencies in your new package. For packages supporting browser, file `tsconfig.esm.json` needs to be manually updated to include reference to ES modules build. ### Guidelines for Pull Requests diff --git a/backwards-compatability/node10/package.json b/backwards-compatability/node10/package.json index 1d2cafc2fd..d0c34bdcd2 100644 --- a/backwards-compatability/node10/package.json +++ b/backwards-compatability/node10/package.json @@ -12,7 +12,7 @@ "@opentelemetry/tracing": "0.19.0" }, "devDependencies": { - "@types/node": "10.17.56", + "@types/node": "10.17.58", "typescript": "4.2.4" }, "author": "OpenTelemetry Authors", diff --git a/backwards-compatability/node12/package.json b/backwards-compatability/node12/package.json index c16a05f37b..deaf88309f 100644 --- a/backwards-compatability/node12/package.json +++ b/backwards-compatability/node12/package.json @@ -12,7 +12,7 @@ "@opentelemetry/tracing": "0.19.0" }, "devDependencies": { - "@types/node": "12.20.7", + "@types/node": "12.20.10", "typescript": "4.2.4" }, "author": "OpenTelemetry Authors", diff --git a/getting-started/ts-example/example/package.json b/getting-started/ts-example/example/package.json index 5d24e4081a..f29e8d0ef2 100644 --- a/getting-started/ts-example/example/package.json +++ b/getting-started/ts-example/example/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@types/express": "4.17.11", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "ts-node": "8.10.2" }, "dependencies": { diff --git a/getting-started/ts-example/monitored-example/package.json b/getting-started/ts-example/monitored-example/package.json index 9b1fe3eea9..bd04240892 100644 --- a/getting-started/ts-example/monitored-example/package.json +++ b/getting-started/ts-example/monitored-example/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@types/express": "4.17.11", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "ts-node": "8.10.2" }, "dependencies": { diff --git a/getting-started/ts-example/traced-example/package.json b/getting-started/ts-example/traced-example/package.json index 0074941e2a..177c605593 100644 --- a/getting-started/ts-example/traced-example/package.json +++ b/getting-started/ts-example/traced-example/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@types/express": "4.17.11", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "ts-node": "9.1.1" }, "dependencies": { diff --git a/package.json b/package.json index 996a0acaf6..3b6211ae12 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ "main": "build/src/index.js", "types": "build/src/index.d.ts", "scripts": { - "compile": "tsc --build", - "watch": "tsc --build --watch", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "bench": "node benchmark", "postinstall": "update-ts-references && npm run bootstrap", "postcompile": "npm run submodule && npm run protos:copy", diff --git a/packages/opentelemetry-api-metrics/package.json b/packages/opentelemetry-api-metrics/package.json index 779fa4a602..47e04d8eb0 100644 --- a/packages/opentelemetry-api-metrics/package.json +++ b/packages/opentelemetry-api-metrics/package.json @@ -3,15 +3,17 @@ "version": "0.19.0", "description": "Public metrics API for OpenTelemetry", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", "test:browser": "nyc karma start --single-run", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", @@ -20,7 +22,7 @@ "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -37,6 +39,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -53,7 +58,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-api-metrics/tsconfig.esm.json b/packages/opentelemetry-api-metrics/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-api-metrics/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 627a3eb3f8..356dc140c5 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -42,7 +42,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/shimmer": "1.0.1", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index cd2ada189b..d43cb8984f 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -3,18 +3,19 @@ "version": "0.19.0", "description": "OpenTelemetry Context Zone with peer dependency for zone.js", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "version": "node ../../scripts/version-update.js", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -30,6 +31,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -41,10 +45,10 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "@types/zone.js": "0.5.12", diff --git a/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json b/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json new file mode 100644 index 0000000000..b3530914ff --- /dev/null +++ b/packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "files": [ + "node_modules/zone.js/dist/zone.js.d.ts" + ], + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index d5393fd806..c3d8030fa4 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -3,15 +3,16 @@ "version": "0.19.0", "description": "OpenTelemetry Context Zone", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -27,6 +28,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -38,9 +42,9 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", diff --git a/packages/opentelemetry-context-zone/tsconfig.esm.json b/packages/opentelemetry-context-zone/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-context-zone/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 0203f689d1..b253aed77d 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -3,15 +3,17 @@ "version": "0.19.0", "description": "OpenTelemetry Core provides default and no-op implementations of the OpenTelemetry types for trace and metrics", "main": "build/src/index.js", + "module": "build/esm/index.js", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts --exclude 'test/platform/browser/**/*.ts'", "test:browser": "nyc karma start --single-run", "tdd": "npm run tdd:node", @@ -22,7 +24,7 @@ "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -39,6 +41,9 @@ "node": ">=8.5.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -53,7 +58,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/propagator-b3": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/semver": "7.3.4", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", diff --git a/packages/opentelemetry-core/tsconfig.esm.json b/packages/opentelemetry-core/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-core/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-exporter-collector-grpc/package.json b/packages/opentelemetry-exporter-collector-grpc/package.json index 29249d6de9..4b55111682 100644 --- a/packages/opentelemetry-exporter-collector-grpc/package.json +++ b/packages/opentelemetry-exporter-collector-grpc/package.json @@ -45,11 +45,11 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/api-metrics": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "cpx": "1.5.0", diff --git a/packages/opentelemetry-exporter-collector-proto/package.json b/packages/opentelemetry-exporter-collector-proto/package.json index 7e9f4828f8..92e90eb64c 100644 --- a/packages/opentelemetry-exporter-collector-proto/package.json +++ b/packages/opentelemetry-exporter-collector-proto/package.json @@ -45,11 +45,11 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/api-metrics": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "cpx": "1.5.0", diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index 4f09e89971..feff7bbf38 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -3,15 +3,17 @@ "version": "0.19.0", "description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", @@ -20,7 +22,7 @@ "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'", "test:browser": "nyc karma start --single-run", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -37,6 +39,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -48,10 +53,10 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", diff --git a/packages/opentelemetry-exporter-collector/tsconfig.esm.json b/packages/opentelemetry-exporter-collector/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-exporter-collector/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index d0e2a56ae4..7fb9e3fb7e 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -43,7 +43,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/resources": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index 571273c87e..ce6e9b7c0a 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -41,7 +41,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts b/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts index d9b4b0f05c..a05e25abe5 100644 --- a/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts +++ b/packages/opentelemetry-exporter-prometheus/src/PrometheusSerializer.ts @@ -63,6 +63,27 @@ function sanitizePrometheusMetricName(name: string): string { return name.replace(invalidCharacterRegex, '_'); // replace all invalid characters with '_' } +/** + * @private + * + * Helper method which assists in enforcing the naming conventions for metric + * names in Prometheus + * @param name the name of the metric + * @param kind the kind of metric + * @returns string + */ +function enforcePrometheusNamingConvention( + name: string, + kind: MetricKind +): string { + // Prometheus requires that metrics of the Counter kind have "_total" suffix + if (!name.endsWith('_total') && kind === MetricKind.COUNTER) { + name = name + '_total'; + } + + return name; +} + function valueString(value: number) { if (Number.isNaN(value)) { return 'Nan'; @@ -162,6 +183,12 @@ export class PrometheusSerializer { if (this._prefix) { name = `${this._prefix}${name}`; } + + name = enforcePrometheusNamingConvention( + name, + checkpoint.descriptor.metricKind + ); + const help = `# HELP ${name} ${escapeString( checkpoint.descriptor.description || 'description missing' )}`; @@ -179,6 +206,12 @@ export class PrometheusSerializer { serializeRecord(name: string, record: MetricRecord): string { let results = ''; + + name = enforcePrometheusNamingConvention( + name, + record.descriptor.metricKind + ); + switch (record.aggregator.kind) { case AggregatorKind.SUM: case AggregatorKind.LAST_VALUE: { diff --git a/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts b/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts index 6954fd2954..29527736f1 100644 --- a/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/PrometheusExporter.test.ts @@ -229,7 +229,7 @@ describe('PrometheusExporter', () => { }); it('should export a count aggregation', done => { - const counter = meter.createCounter('counter', { + const counter = meter.createCounter('counter_total', { description: 'a test description', }); @@ -251,13 +251,13 @@ describe('PrometheusExporter', () => { assert.strictEqual( lines[0], - '# HELP counter a test description' + '# HELP counter_total a test description' ); assert.deepStrictEqual(lines, [ - '# HELP counter a test description', - '# TYPE counter counter', - `counter{key1="labelValue1"} 20 ${mockedHrTimeMs}`, + '# HELP counter_total a test description', + '# TYPE counter_total counter', + `counter_total{key1="labelValue1"} 20 ${mockedHrTimeMs}`, '', ]); @@ -313,7 +313,7 @@ describe('PrometheusExporter', () => { }); it('should export multiple labels', done => { - const counter = meter.createCounter('counter', { + const counter = meter.createCounter('counter_total', { description: 'a test description', }) as CounterMetric; @@ -328,10 +328,10 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter a test description', - '# TYPE counter counter', - `counter{counterKey1="labelValue1"} 10 ${mockedHrTimeMs}`, - `counter{counterKey1="labelValue2"} 20 ${mockedHrTimeMs}`, + '# HELP counter_total a test description', + '# TYPE counter_total counter', + `counter_total{counterKey1="labelValue1"} 10 ${mockedHrTimeMs}`, + `counter_total{counterKey1="labelValue2"} 20 ${mockedHrTimeMs}`, '', ]); @@ -344,7 +344,7 @@ describe('PrometheusExporter', () => { }); it('should export multiple labels on manual shutdown', done => { - const counter = meter.createCounter('counter', { + const counter = meter.createCounter('counter_total', { description: 'a test description', }) as CounterMetric; @@ -359,11 +359,11 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter a test description', - '# TYPE counter counter', - `counter{counterKey1="labelValue1"} 10 ${mockedHrTimeMs}`, - `counter{counterKey1="labelValue2"} 20 ${mockedHrTimeMs}`, - `counter{counterKey1="labelValue3"} 30 ${mockedHrTimeMs}`, + '# HELP counter_total a test description', + '# TYPE counter_total counter', + `counter_total{counterKey1="labelValue1"} 10 ${mockedHrTimeMs}`, + `counter_total{counterKey1="labelValue2"} 20 ${mockedHrTimeMs}`, + `counter_total{counterKey1="labelValue3"} 30 ${mockedHrTimeMs}`, '', ]); @@ -392,7 +392,7 @@ describe('PrometheusExporter', () => { }); it('should add a description if missing', done => { - const counter = meter.createCounter('counter'); + const counter = meter.createCounter('counter_total'); const boundCounter = counter.bind({ key1: 'labelValue1' }); boundCounter.add(10); @@ -405,9 +405,9 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter description missing', - '# TYPE counter counter', - `counter{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + '# HELP counter_total description missing', + '# TYPE counter_total counter', + `counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -432,9 +432,9 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter_bad_name description missing', - '# TYPE counter_bad_name counter', - `counter_bad_name{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + '# HELP counter_bad_name_total description missing', + '# TYPE counter_bad_name_total counter', + `counter_bad_name_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -620,9 +620,9 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP test_prefix_counter description missing', - '# TYPE test_prefix_counter counter', - `test_prefix_counter{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + '# HELP test_prefix_counter_total description missing', + '# TYPE test_prefix_counter_total counter', + `test_prefix_counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -650,9 +650,9 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter description missing', - '# TYPE counter counter', - `counter{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + '# HELP counter_total description missing', + '# TYPE counter_total counter', + `counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -680,9 +680,9 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter description missing', - '# TYPE counter counter', - `counter{key1="labelValue1"} 10 ${mockedHrTimeMs}`, + '# HELP counter_total description missing', + '# TYPE counter_total counter', + `counter_total{key1="labelValue1"} 10 ${mockedHrTimeMs}`, '', ]); @@ -710,9 +710,9 @@ describe('PrometheusExporter', () => { const lines = body.split('\n'); assert.deepStrictEqual(lines, [ - '# HELP counter description missing', - '# TYPE counter counter', - 'counter{key1="labelValue1"} 10', + '# HELP counter_total description missing', + '# TYPE counter_total counter', + 'counter_total{key1="labelValue1"} 10', '', ]); diff --git a/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts b/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts index 7a05e52334..07d240ff42 100644 --- a/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts @@ -23,6 +23,7 @@ import { UpDownCounterMetric, ValueObserverMetric, } from '@opentelemetry/metrics'; +import { diag, DiagLogLevel } from '@opentelemetry/api'; import * as assert from 'assert'; import { Labels } from '@opentelemetry/api-metrics'; import { PrometheusSerializer } from '../src/PrometheusSerializer'; @@ -53,7 +54,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const counter = meter.createCounter('test') as CounterMetric; + const counter = meter.createCounter('test_total') as CounterMetric; counter.bind(labels).add(1); const records = await counter.getMetricRecord(); @@ -65,7 +66,7 @@ describe('PrometheusSerializer', () => { ); assert.strictEqual( result, - `test{foo1="bar1",foo2="bar2"} 1 ${mockedHrTimeMs}\n` + `test_total{foo1="bar1",foo2="bar2"} 1 ${mockedHrTimeMs}\n` ); }); @@ -75,7 +76,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const counter = meter.createCounter('test') as CounterMetric; + const counter = meter.createCounter('test_total') as CounterMetric; counter.bind(labels).add(1); const records = await counter.getMetricRecord(); @@ -85,7 +86,7 @@ describe('PrometheusSerializer', () => { record.descriptor.name, record ); - assert.strictEqual(result, 'test{foo1="bar1",foo2="bar2"} 1\n'); + assert.strictEqual(result, 'test_total{foo1="bar1",foo2="bar2"} 1\n'); }); }); @@ -155,6 +156,7 @@ describe('PrometheusSerializer', () => { const recorder = meter.createValueRecorder('test', { description: 'foobar', }) as ValueRecorderMetric; + recorder.bind(labels).record(5); const records = await recorder.getMetricRecord(); @@ -244,7 +246,7 @@ describe('PrometheusSerializer', () => { processor: new ExactProcessor(SumAggregator), }).getMeter('test'); const processor = new PrometheusLabelsBatcher(); - const counter = meter.createCounter('test', { + const counter = meter.createCounter('test_total', { description: 'foobar', }) as CounterMetric; counter.bind({ val: '1' }).add(1); @@ -257,10 +259,10 @@ describe('PrometheusSerializer', () => { const result = serializer.serialize(checkPointSet); assert.strictEqual( result, - '# HELP test foobar\n' + - '# TYPE test counter\n' + - `test{val="1"} 1 ${mockedHrTimeMs}\n` + - `test{val="2"} 1 ${mockedHrTimeMs}\n` + '# HELP test_total foobar\n' + + '# TYPE test_total counter\n' + + `test_total{val="1"} 1 ${mockedHrTimeMs}\n` + + `test_total{val="2"} 1 ${mockedHrTimeMs}\n` ); }); @@ -271,7 +273,7 @@ describe('PrometheusSerializer', () => { processor: new ExactProcessor(SumAggregator), }).getMeter('test'); const processor = new PrometheusLabelsBatcher(); - const counter = meter.createCounter('test', { + const counter = meter.createCounter('test_total', { description: 'foobar', }) as CounterMetric; counter.bind({ val: '1' }).add(1); @@ -284,10 +286,10 @@ describe('PrometheusSerializer', () => { const result = serializer.serialize(checkPointSet); assert.strictEqual( result, - '# HELP test foobar\n' + - '# TYPE test counter\n' + - 'test{val="1"} 1\n' + - 'test{val="2"} 1\n' + '# HELP test_total foobar\n' + + '# TYPE test_total counter\n' + + 'test_total{val="1"} 1\n' + + 'test_total{val="2"} 1\n' ); }); }); @@ -370,6 +372,54 @@ describe('PrometheusSerializer', () => { }); }); + describe('validate against metric conventions', () => { + mockAggregator(SumAggregator); + + it('should rename metric of type counter when name misses _total suffix', async () => { + const serializer = new PrometheusSerializer(); + + const meter = new MeterProvider({ + processor: new ExactProcessor(SumAggregator), + }).getMeter('test'); + const counter = meter.createCounter('test') as CounterMetric; + counter.bind({}).add(1); + + const records = await counter.getMetricRecord(); + const record = records[0]; + + const result = serializer.serializeRecord(record.descriptor.name, record); + assert.strictEqual(result, `test_total 1 ${mockedHrTimeMs}\n`); + }); + + it('should not warn for counter metrics with correct name', async () => { + let calledArgs: any[] = []; + const dummyLogger = { + verbose: () => {}, + debug: (...args: any[]) => { + calledArgs = args; + }, + info: () => {}, + warn: () => {}, + error: () => {}, + }; + diag.setLogger(dummyLogger, DiagLogLevel.ALL); + const serializer = new PrometheusSerializer(); + + const meter = new MeterProvider({ + processor: new ExactProcessor(SumAggregator), + }).getMeter('test'); + const counter = meter.createCounter('test_total') as CounterMetric; + counter.bind({}).add(1); + + const records = await counter.getMetricRecord(); + const record = records[0]; + + const result = serializer.serializeRecord(record.descriptor.name, record); + assert.strictEqual(result, `test_total 1 ${mockedHrTimeMs}\n`); + assert.ok(calledArgs.length === 0); + }); + }); + describe('serialize non-normalized values', () => { describe('with SumAggregator', () => { mockAggregator(SumAggregator); @@ -380,7 +430,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const counter = meter.createCounter('test') as CounterMetric; + const counter = meter.createCounter('test_total') as CounterMetric; counter.bind({}).add(1); const records = await counter.getMetricRecord(); @@ -390,7 +440,7 @@ describe('PrometheusSerializer', () => { record.descriptor.name, record ); - assert.strictEqual(result, `test 1 ${mockedHrTimeMs}\n`); + assert.strictEqual(result, `test_total 1 ${mockedHrTimeMs}\n`); }); it('should serialize non-string label values', async () => { @@ -399,7 +449,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const counter = meter.createCounter('test') as CounterMetric; + const counter = meter.createCounter('test_total') as CounterMetric; counter .bind(({ object: {}, @@ -417,7 +467,7 @@ describe('PrometheusSerializer', () => { ); assert.strictEqual( result, - `test{object="[object Object]",NaN="NaN",null="null",undefined="undefined"} 1 ${mockedHrTimeMs}\n` + `test_total{object="[object Object]",NaN="NaN",null="null",undefined="undefined"} 1 ${mockedHrTimeMs}\n` ); }); @@ -457,7 +507,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), }).getMeter('test'); - const counter = meter.createCounter('test') as CounterMetric; + const counter = meter.createCounter('test_total') as CounterMetric; counter .bind(({ backslash: '\u005c', // \ => \\ (\u005c\u005c) @@ -477,7 +527,7 @@ describe('PrometheusSerializer', () => { ); assert.strictEqual( result, - 'test{' + + 'test_total{' + 'backslash="\u005c\u005c",' + 'doubleQuote="\u005c\u0022",' + 'lineFeed="\u005c\u006e",' + @@ -493,7 +543,7 @@ describe('PrometheusSerializer', () => { const meter = new MeterProvider({ processor: new ExactProcessor(SumAggregator), - }).getMeter('test'); + }).getMeter('test_total'); const counter = meter.createCounter('test') as CounterMetric; // if you try to use a label name like account-id prometheus will complain // with an error like: @@ -512,7 +562,7 @@ describe('PrometheusSerializer', () => { ); assert.strictEqual( result, - `test{account_id="123456"} 1 ${mockedHrTimeMs}\n` + `test_total{account_id="123456"} 1 ${mockedHrTimeMs}\n` ); }); }); diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index 29b5853875..59e7e60ea1 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -3,15 +3,17 @@ "version": "0.19.0", "description": "OpenTelemetry Zipkin Exporter allows the user to send collected traces to Zipkin.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", @@ -20,7 +22,7 @@ "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'", "test:browser": "nyc karma start --single-run", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -35,6 +37,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -46,10 +51,10 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", diff --git a/packages/opentelemetry-exporter-zipkin/tsconfig.esm.json b/packages/opentelemetry-exporter-zipkin/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-exporter-zipkin/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-instrumentation-fetch/package.json b/packages/opentelemetry-instrumentation-fetch/package.json index 5d9a281d4e..c586b3b1b9 100644 --- a/packages/opentelemetry-instrumentation-fetch/package.json +++ b/packages/opentelemetry-instrumentation-fetch/package.json @@ -3,18 +3,19 @@ "version": "0.19.0", "description": "OpenTelemetry fetch automatic instrumentation package.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "version": "node ../../scripts/version-update.js", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "fetch", @@ -31,6 +32,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -42,13 +46,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-zone": "0.19.0", "@opentelemetry/propagator-b3": "0.19.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", diff --git a/packages/opentelemetry-instrumentation-fetch/tsconfig.esm.json b/packages/opentelemetry-instrumentation-fetch/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-instrumentation-fetch/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-instrumentation-grpc/package.json b/packages/opentelemetry-instrumentation-grpc/package.json index b0b25593fb..81e3929a6c 100644 --- a/packages/opentelemetry-instrumentation-grpc/package.json +++ b/packages/opentelemetry-instrumentation-grpc/package.json @@ -42,14 +42,14 @@ }, "devDependencies": { "@grpc/grpc-js": "1.2.12", - "@grpc/proto-loader": "0.6.0", + "@grpc/proto-loader": "0.6.1", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-async-hooks": "0.19.0", "@opentelemetry/core": "0.19.0", "@opentelemetry/node": "0.19.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/semver": "7.3.4", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", diff --git a/packages/opentelemetry-instrumentation-http/package.json b/packages/opentelemetry-instrumentation-http/package.json index 0d3e076986..fc7f8ed862 100644 --- a/packages/opentelemetry-instrumentation-http/package.json +++ b/packages/opentelemetry-instrumentation-http/package.json @@ -48,7 +48,7 @@ "@opentelemetry/tracing": "0.19.0", "@types/got": "9.6.11", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/request-promise-native": "1.0.17", "@types/semver": "7.3.4", "@types/sinon": "9.0.11", diff --git a/packages/opentelemetry-instrumentation-xml-http-request/package.json b/packages/opentelemetry-instrumentation-xml-http-request/package.json index 4d3c55baad..a4392d6128 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -3,18 +3,19 @@ "version": "0.19.0", "description": "OpenTelemetry XMLHttpRequest automatic instrumentation package.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "version": "node ../../scripts/version-update.js", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -31,6 +32,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -42,13 +46,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-zone": "0.19.0", "@opentelemetry/propagator-b3": "0.19.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", diff --git a/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.esm.json b/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-instrumentation-xml-http-request/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-instrumentation/package.json b/packages/opentelemetry-instrumentation/package.json index af4d37ffd0..78de724d28 100644 --- a/packages/opentelemetry-instrumentation/package.json +++ b/packages/opentelemetry-instrumentation/package.json @@ -6,6 +6,7 @@ "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", "license": "Apache-2.0", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "publishConfig": { "access": "public" @@ -16,9 +17,13 @@ }, "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -27,8 +32,8 @@ "README.md" ], "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", @@ -39,7 +44,7 @@ "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/browser/**/*.ts'", "test:browser": "nyc karma start --single-run", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -63,10 +68,10 @@ "@opentelemetry/api": "^1.0.0-rc.0" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/semver": "7.3.4", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", diff --git a/packages/opentelemetry-instrumentation/tsconfig.esm.json b/packages/opentelemetry-instrumentation/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-instrumentation/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index eee09b06b1..8da6d03371 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -3,18 +3,19 @@ "version": "0.19.0", "description": "OpenTelemetry metrics SDK", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", "tdd": "npm run test -- --watch-extensions ts --watch", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -29,6 +30,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -43,7 +47,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@types/lodash.merge": "4.6.6", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-metrics/src/Meter.ts b/packages/opentelemetry-metrics/src/Meter.ts index ab2ce90def..d42c9f15c6 100644 --- a/packages/opentelemetry-metrics/src/Meter.ts +++ b/packages/opentelemetry-metrics/src/Meter.ts @@ -31,7 +31,7 @@ import { UpDownCounterMetric } from './UpDownCounterMetric'; import { UpDownSumObserverMetric } from './UpDownSumObserverMetric'; import { ValueObserverMetric } from './ValueObserverMetric'; import { ValueRecorderMetric } from './ValueRecorderMetric'; -import merge = require('lodash.merge'); +const merge = require('lodash.merge'); /** * Meter is an implementation of the {@link Meter} interface. diff --git a/packages/opentelemetry-metrics/src/MeterProvider.ts b/packages/opentelemetry-metrics/src/MeterProvider.ts index 3b645b8a91..b305456a9e 100644 --- a/packages/opentelemetry-metrics/src/MeterProvider.ts +++ b/packages/opentelemetry-metrics/src/MeterProvider.ts @@ -18,7 +18,7 @@ import * as api from '@opentelemetry/api-metrics'; import { Resource } from '@opentelemetry/resources'; import { Meter } from '.'; import { DEFAULT_CONFIG, MeterConfig } from './types'; -import merge = require('lodash.merge'); +const merge = require('lodash.merge'); /** * This class represents a meter provider which platform libraries can extend diff --git a/packages/opentelemetry-metrics/tsconfig.esm.json b/packages/opentelemetry-metrics/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-metrics/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index 8b9ef8d66f..b92bb88d3d 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -44,7 +44,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/resources": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/semver": "7.3.4", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index b1392604da..336ca825d4 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -3,17 +3,18 @@ "version": "0.19.0", "description": "OpenTelemetry B3 propagator provides context propagation for systems that are using the B3 header format", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -29,6 +30,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -44,7 +48,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "codecov": "3.8.1", "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", diff --git a/packages/opentelemetry-propagator-b3/tsconfig.esm.json b/packages/opentelemetry-propagator-b3/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-propagator-b3/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index b6bfef8b4f..e8bcb7bc0e 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -3,21 +3,22 @@ "version": "0.19.0", "description": "OpenTelemetry Jaeger propagator provides HTTP header propagation for systems that are using Jaeger HTTP header format.", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/index-webpack.ts'", "test:browser": "nyc karma start --single-run", "tdd": "npm run tdd:node", "tdd:node": "npm run test -- --watch-extensions ts --watch", "tdd:browser": "karma start", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", - "clean": "tsc --build --clean", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -32,6 +33,9 @@ "node": ">=8.5.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -45,7 +49,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", diff --git a/packages/opentelemetry-propagator-jaeger/tsconfig.esm.json b/packages/opentelemetry-propagator-jaeger/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-propagator-jaeger/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-resource-detector-aws/package.json b/packages/opentelemetry-resource-detector-aws/package.json index e813c59d34..4d8da68cd6 100644 --- a/packages/opentelemetry-resource-detector-aws/package.json +++ b/packages/opentelemetry-resource-detector-aws/package.json @@ -41,7 +41,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-resource-detector-gcp/package.json b/packages/opentelemetry-resource-detector-gcp/package.json index 761910b411..d29fbc957d 100644 --- a/packages/opentelemetry-resource-detector-gcp/package.json +++ b/packages/opentelemetry-resource-detector-gcp/package.json @@ -42,7 +42,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/core": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/semver": "7.3.4", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 8ba4f6ac7b..903a378b18 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -3,15 +3,17 @@ "version": "0.19.0", "description": "OpenTelemetry SDK resources", "main": "build/src/index.js", + "module": "build/esm/index.js", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", @@ -32,6 +34,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -45,7 +50,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-resources/tsconfig.esm.json b/packages/opentelemetry-resources/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-resources/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json index 8c79da1293..bd209ed45c 100644 --- a/packages/opentelemetry-sdk-node/package.json +++ b/packages/opentelemetry-sdk-node/package.json @@ -58,7 +58,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-async-hooks": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/semver": "7.3.4", "@types/sinon": "9.0.11", "codecov": "3.8.1", diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index 96f731f404..f1165770a2 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -3,17 +3,18 @@ "version": "0.19.0", "description": "OpenTelemetry semantic conventions", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.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" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -40,7 +41,7 @@ }, "devDependencies": { "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-semantic-conventions/tsconfig.esm.json b/packages/opentelemetry-semantic-conventions/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-semantic-conventions/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 4b2b6515ea..c0be2b54d1 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -41,7 +41,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "codecov": "3.8.1", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index d88330f739..08a856c02f 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -3,15 +3,17 @@ "version": "0.19.0", "description": "OpenTelemetry Tracing", "main": "build/src/index.js", + "module": "build/esm/index.js", "browser": { "./src/platform/index.ts": "./src/platform/browser/index.ts", + "./build/esm/platform/index.js": "./build/esm/platform/browser/index.js", "./build/src/platform/index.js": "./build/src/platform/browser/index.js" }, "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts' --exclude 'test/index-webpack.ts'", "test:browser": "nyc karma start --single-run", "tdd": "npm run tdd:node", @@ -21,7 +23,7 @@ "lint:fix": "eslint . --ext .ts --fix", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "version": "node ../../scripts/version-update.js", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -37,6 +39,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -51,7 +56,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@types/lodash.merge": "4.6.6", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", diff --git a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts index b5db060271..86d5f4d077 100644 --- a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts @@ -34,7 +34,7 @@ import { DEFAULT_CONFIG } from './config'; import { MultiSpanProcessor } from './MultiSpanProcessor'; import { NoopSpanProcessor } from './NoopSpanProcessor'; import { SDKRegistrationConfig, TracerConfig } from './types'; -import merge = require('lodash.merge'); +const merge = require('lodash.merge'); export type PROPAGATOR_FACTORY = () => TextMapPropagator; @@ -122,7 +122,9 @@ export class BasicTracerProvider implements TracerProvider { protected _buildPropagatorFromEnv(): TextMapPropagator | undefined { // per spec, propagators from env must be deduplicated - const uniquePropagatorNames = [...new Set(getEnv().OTEL_PROPAGATORS)]; + const uniquePropagatorNames = Array.from( + new Set(getEnv().OTEL_PROPAGATORS) + ); const propagators = uniquePropagatorNames.map(name => { const propagator = this._getPropagator(name); diff --git a/packages/opentelemetry-tracing/tsconfig.esm.json b/packages/opentelemetry-tracing/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-tracing/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index 1b02e585a9..71af31964f 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -3,18 +3,19 @@ "version": "0.19.0", "description": "OpenTelemetry Web Tracer", "main": "build/src/index.js", + "module": "build/esm/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { - "compile": "tsc --build", - "clean": "tsc --build --clean", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "version": "node ../../scripts/version-update.js", "tdd": "karma start", "test:browser": "nyc karma start --single-run", - "watch": "tsc --build --watch" + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -30,6 +31,9 @@ "node": ">=8.0.0" }, "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", "build/src/**/*.js", "build/src/**/*.js.map", "build/src/**/*.d.ts", @@ -41,14 +45,14 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.15", + "@babel/core": "7.13.16", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-zone": "0.19.0", "@opentelemetry/propagator-b3": "0.19.0", "@opentelemetry/resources": "0.19.0", "@types/jquery": "3.5.5", "@types/mocha": "8.2.2", - "@types/node": "14.14.37", + "@types/node": "14.14.41", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", diff --git a/packages/opentelemetry-web/tsconfig.esm.json b/packages/opentelemetry-web/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/opentelemetry-web/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/packages/template/package.json b/packages/template/package.json index 4b000e98ee..83ea22f40f 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -35,9 +35,12 @@ "version": "node ../../scripts/version-update.js", "watch": "tsc --build --watch" }, - "Add these to scripts if browser is supported": { + "Add/change these to scripts if browser is supported": { + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", "test:browser": "nyc karma start --single-run", - "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../" + "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json" }, "keywords": [ "opentelemetry", @@ -56,8 +59,13 @@ "LICENSE", "README.md" ], + "Add these to files if browser is supported": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts" + ], "devDependencies": { - "@types/node": "14.14.37", + "@types/node": "14.14.41", "typescript": "4.2.4" }, "Add these to devDependencies for testing": { diff --git a/packages/template/tsconfig.esm.json b/packages/template/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/packages/template/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/tsconfig.base.esm.json b/tsconfig.base.esm.json new file mode 100644 index 0000000000..e65651a426 --- /dev/null +++ b/tsconfig.base.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.es5.json", + "compilerOptions": { + "module": "ES6", + "moduleResolution": "node" + } +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000000..6b6b6fe8be --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,54 @@ +{ + "extends": "./tsconfig.base.esm.json", + "files": [], + "references": [ + { + "path": "packages/opentelemetry-api-metrics/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-context-zone-peer-dep/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-context-zone/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-core/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-exporter-collector/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-exporter-zipkin/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-instrumentation-fetch/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-instrumentation-xml-http-request/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-instrumentation/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-metrics/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-propagator-b3/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-propagator-jaeger/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-resources/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-semantic-conventions/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-tracing/tsconfig.esm.json" + }, + { + "path": "packages/opentelemetry-web/tsconfig.esm.json" + } + ] +}