diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json
index 948abef3ceb..b3ff4e84578 100644
--- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json
+++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/tsconfig.json
@@ -11,6 +11,18 @@
"references": [
{
"path": "../opentelemetry-api-metrics"
+ },
+ {
+ "path": "../opentelemetry-exporter-metrics-otlp-http"
+ },
+ {
+ "path": "../opentelemetry-exporter-trace-otlp-grpc"
+ },
+ {
+ "path": "../opentelemetry-exporter-trace-otlp-http"
+ },
+ {
+ "path": "../opentelemetry-sdk-metrics-base"
}
]
}
diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.esm.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.esm.json
index 379f547a469..484461f470a 100644
--- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.esm.json
+++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.esm.json
@@ -7,5 +7,16 @@
},
"include": [
"src/**/*.ts"
+ ],
+ "references": [
+ {
+ "path": "../opentelemetry-api-metrics/tsconfig.esm.json"
+ },
+ {
+ "path": "../opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json"
+ },
+ {
+ "path": "../opentelemetry-sdk-metrics-base/tsconfig.esm.json"
+ }
]
}
diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json
index ed9d0830bdd..13dc2e7744d 100644
--- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json
+++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.json
@@ -7,5 +7,16 @@
"include": [
"src/**/*.ts",
"test/**/*.ts"
+ ],
+ "references": [
+ {
+ "path": "../opentelemetry-api-metrics"
+ },
+ {
+ "path": "../opentelemetry-exporter-trace-otlp-http"
+ },
+ {
+ "path": "../opentelemetry-sdk-metrics-base"
+ }
]
}
diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json
index 03a463d6378..35c3f6d9c73 100644
--- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json
+++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/tsconfig.json
@@ -10,10 +10,19 @@
],
"references": [
{
- "path": "../opentelemetry-sdk-metrics-base"
+ "path": "../opentelemetry-api-metrics"
},
{
"path": "../opentelemetry-exporter-metrics-otlp-http"
+ },
+ {
+ "path": "../opentelemetry-exporter-trace-otlp-http"
+ },
+ {
+ "path": "../opentelemetry-exporter-trace-otlp-proto"
+ },
+ {
+ "path": "../opentelemetry-sdk-metrics-base"
}
]
}
diff --git a/experimental/packages/opentelemetry-exporter-trace-otlp-grpc/tsconfig.json b/experimental/packages/opentelemetry-exporter-trace-otlp-grpc/tsconfig.json
index 13dc2e7744d..075a501621d 100644
--- a/experimental/packages/opentelemetry-exporter-trace-otlp-grpc/tsconfig.json
+++ b/experimental/packages/opentelemetry-exporter-trace-otlp-grpc/tsconfig.json
@@ -9,14 +9,8 @@
"test/**/*.ts"
],
"references": [
- {
- "path": "../opentelemetry-api-metrics"
- },
{
"path": "../opentelemetry-exporter-trace-otlp-http"
- },
- {
- "path": "../opentelemetry-sdk-metrics-base"
}
]
}
diff --git a/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json b/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json
index 7b09613481b..379f547a469 100644
--- a/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json
+++ b/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json
@@ -7,13 +7,5 @@
},
"include": [
"src/**/*.ts"
- ],
- "references": [
- {
- "path": "../opentelemetry-api-metrics/tsconfig.esm.json"
- },
- {
- "path": "../opentelemetry-sdk-metrics-base/tsconfig.esm.json"
- }
]
}
diff --git a/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.json b/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.json
index 3c062d3feb2..ed9d0830bdd 100644
--- a/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.json
+++ b/experimental/packages/opentelemetry-exporter-trace-otlp-http/tsconfig.json
@@ -7,13 +7,5 @@
"include": [
"src/**/*.ts",
"test/**/*.ts"
- ],
- "references": [
- {
- "path": "../opentelemetry-api-metrics"
- },
- {
- "path": "../opentelemetry-sdk-metrics-base"
- }
]
}
diff --git a/experimental/packages/opentelemetry-exporter-trace-otlp-proto/tsconfig.json b/experimental/packages/opentelemetry-exporter-trace-otlp-proto/tsconfig.json
index 13dc2e7744d..075a501621d 100644
--- a/experimental/packages/opentelemetry-exporter-trace-otlp-proto/tsconfig.json
+++ b/experimental/packages/opentelemetry-exporter-trace-otlp-proto/tsconfig.json
@@ -9,14 +9,8 @@
"test/**/*.ts"
],
"references": [
- {
- "path": "../opentelemetry-api-metrics"
- },
{
"path": "../opentelemetry-exporter-trace-otlp-http"
- },
- {
- "path": "../opentelemetry-sdk-metrics-base"
}
]
}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/.eslintignore b/experimental/packages/opentelemetry-sdk-metrics-base-wip/.eslintignore
new file mode 100644
index 00000000000..378eac25d31
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/.eslintignore
@@ -0,0 +1 @@
+build
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/.eslintrc.js b/experimental/packages/opentelemetry-sdk-metrics-base-wip/.eslintrc.js
new file mode 100644
index 00000000000..f756f4488b2
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/.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-wip/.npmignore b/experimental/packages/opentelemetry-sdk-metrics-base-wip/.npmignore
new file mode 100644
index 00000000000..9505ba9450f
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/.npmignore
@@ -0,0 +1,4 @@
+/bin
+/coverage
+/doc
+/test
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/LICENSE b/experimental/packages/opentelemetry-sdk-metrics-base-wip/LICENSE
new file mode 100644
index 00000000000..261eeb9e9f8
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/README.md b/experimental/packages/opentelemetry-sdk-metrics-base-wip/README.md
new file mode 100644
index 00000000000..b89b7658e80
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/README.md
@@ -0,0 +1,210 @@
+# OpenTelemetry Metrics SDK
+
+[![NPM Published Version][npm-img]][npm-url]
+[![dependencies][dependencies-image]][dependencies-url]
+[![devDependencies][devDependencies-image]][devDependencies-url]
+[![Apache License][license-image]][license-image]
+
+OpenTelemetry metrics allow a user to collect data and export it to a metrics backend like [Prometheus](https://prometheus.io/).
+
+## Installation
+
+```bash
+npm install --save @opentelemetry/sdk-metrics-base
+```
+
+## Usage
+
+### Counter
+
+Choose this kind of metric when the value is a quantity, the sum is of primary interest, and the event count and value distribution are not of primary interest. It is restricted to non-negative increments.
+Example uses for Counter:
+
+- count the number of bytes received
+- count the number of requests completed
+- count the number of accounts created
+- count the number of checkpoints run
+- count the number of 5xx errors.
+
+```js
+const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
+
+// Initialize the Meter to capture measurements in various ways.
+const meter = new MeterProvider().getMeter('your-meter-name');
+
+const counter = meter.createCounter('metric_name', {
+ description: 'Example of a counter'
+});
+
+const labels = { pid: process.pid };
+counter.add(10, labels);
+```
+
+### UpDownCounter
+
+`UpDownCounter` is similar to `Counter` except that it supports negative increments. It is generally useful for capturing changes in an amount of resources used, or any quantity that rises and falls during a request.
+
+Example uses for UpDownCounter:
+
+- count the number of active requests
+- count memory in use by instrumenting new and delete
+- count queue size by instrumenting enqueue and dequeue
+- count semaphore up and down operations
+
+```js
+const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
+
+// Initialize the Meter to capture measurements in various ways.
+const meter = new MeterProvider().getMeter('your-meter-name');
+
+const counter = meter.createUpDownCounter('metric_name', {
+ description: 'Example of a UpDownCounter'
+});
+
+const labels = { pid: process.pid };
+counter.add(Math.random() > 0.5 ? 1 : -1, labels);
+```
+
+### Observable Gauge
+
+Choose this kind of metric when only last value is important without worry about aggregation.
+The callback can be sync or async.
+
+```js
+const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
+
+const meter = new MeterProvider().getMeter('your-meter-name');
+
+
+// async callback - for operation that needs to wait for value
+meter.createObservableGauge('your_metric_name', {
+ description: 'Example of an async observable gauge with callback',
+}, async (observableResult) => {
+ const value = await getAsyncValue();
+ observableResult.observe(value, { label: '1' });
+});
+
+function getAsyncValue() {
+ return new Promise((resolve) => {
+ setTimeout(()=> {
+ resolve(Math.random());
+ }, 100);
+ });
+}
+
+// sync callback in case you don't need to wait for value
+meter.createObservableGauge('your_metric_name', {
+ description: 'Example of a sync observable gauge with callback',
+}, (observableResult) => {
+ observableResult.observe(getRandomValue(), { label: '1' });
+ observableResult.observe(getRandomValue(), { label: '2' });
+});
+
+function getRandomValue() {
+ return Math.random();
+}
+```
+
+### ObservableUpDownCounter
+
+Choose this kind of metric when sum is important and you want to capture any value that starts at zero and rises or falls throughout the process lifetime.
+The callback can be sync or async.
+
+```js
+const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
+
+const meter = new MeterProvider().getMeter('your-meter-name');
+
+// async callback - for operation that needs to wait for value
+meter.createObservableUpDownCounter('your_metric_name', {
+ description: 'Example of an async observable up down counter with callback',
+}, async (observableResult) => {
+ const value = await getAsyncValue();
+ observableResult.observe(value, { label: '1' });
+});
+
+function getAsyncValue() {
+ return new Promise((resolve) => {
+ setTimeout(()=> {
+ resolve(Math.random());
+ }, 100);
+ });
+}
+
+// sync callback in case you don't need to wait for value
+meter.createObservableUpDownCounter('your_metric_name', {
+ description: 'Example of a sync observable up down counter with callback',
+}, (observableResult) => {
+ observableResult.observe(getRandomValue(), { label: '1' });
+});
+
+function getRandomValue() {
+ return Math.random();
+}
+
+```
+
+### Observable Counter
+
+Choose this kind of metric when collecting a sum that never decreases.
+The callback can be sync or async.
+
+```js
+const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
+
+const meter = new MeterProvider().getMeter('your-meter-name');
+
+// async callback in case you need to wait for values
+meter.createObservableCounter('example_metric', {
+ description: 'Example of an async observable counter with callback',
+}, async (observableResult) => {
+ const value = await getAsyncValue();
+ observableResult.observe(value, { label: '1' });
+});
+
+function getAsyncValue() {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(Math.random());
+ }, 100)
+ });
+}
+
+// sync callback in case you don't need to wait for values
+meter.createObservableCounter('example_metric', {
+ description: 'Example of a sync observable counter with callback',
+}, (observableResult) => {
+ const value = getRandomValue();
+ observableResult.observe(value, { label: '1' });
+});
+
+function getRandomValue() {
+ return Math.random();
+}
+```
+
+### Histogram
+
+`Histogram` is a non-additive synchronous instrument useful for recording any non-additive number, positive or negative.
+Values captured by `Histogram.record(value)` are treated as individual events belonging to a distribution that is being summarized.
+`Histogram` should be chosen either when capturing measurements that do not contribute meaningfully to a sum, or when capturing numbers that are additive in nature, but where the distribution of individual increments is considered interesting.
+
+## Useful links
+
+- For more information on OpenTelemetry, visit:
+- For more about OpenTelemetry JavaScript:
+- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
+
+## License
+
+Apache 2.0 - See [LICENSE][license-url] for more information.
+
+[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
+[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
+[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
+[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-sdk-metrics-base
+[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-metrsics
+[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-sdk-metrics-base&type=dev
+[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-sdk-metrics-base&type=dev
+[npm-url]: https://www.npmjs.com/package/@opentelemetry/sdk-metrics-base
+[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fmetrics.svg
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/package.json b/experimental/packages/opentelemetry-sdk-metrics-base-wip/package.json
new file mode 100644
index 00000000000..36c4ab04df5
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/package.json
@@ -0,0 +1,69 @@
+{
+ "name": "@opentelemetry/sdk-metrics-base-wip",
+ "version": "0.26.0",
+ "private": true,
+ "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 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 tsconfig.json tsconfig.esm.json",
+ "precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies",
+ "prewatch": "node ../../../scripts/version-update.js"
+ },
+ "keywords": [
+ "opentelemetry",
+ "nodejs",
+ "metrics",
+ "stats",
+ "profiling"
+ ],
+ "author": "OpenTelemetry Authors",
+ "license": "Apache-2.0",
+ "engines": {
+ "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",
+ "doc",
+ "LICENSE",
+ "README.md"
+ ],
+ "devDependencies": {
+ "@opentelemetry/api": "^1.0.3",
+ "@types/lodash.merge": "4.6.6",
+ "@types/mocha": "8.2.3",
+ "@types/node": "14.17.11",
+ "@types/sinon": "10.0.2",
+ "codecov": "3.8.3",
+ "mocha": "7.2.0",
+ "nyc": "15.1.0",
+ "rimraf": "3.0.2",
+ "sinon": "11.1.2",
+ "ts-mocha": "8.0.0",
+ "typescript": "4.3.5"
+ },
+ "peerDependencies": {
+ "@opentelemetry/api": "^1.0.0"
+ },
+ "dependencies": {
+ "@opentelemetry/api-metrics": "0.26.0",
+ "@opentelemetry/core": "1.0.0",
+ "@opentelemetry/resources": "1.0.0",
+ "lodash.merge": "^4.6.2"
+ }
+}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Aggregation.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Aggregation.ts
new file mode 100644
index 00000000000..8057e064b49
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Aggregation.ts
@@ -0,0 +1,24 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { Measurement } from './Measurement';
+
+// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#aggregation
+
+export interface Aggregator {
+ aggregate(measurement: Measurement): void;
+}
+
+// TODO define actual aggregator classes
\ No newline at end of file
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Instruments.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Instruments.ts
new file mode 100644
index 00000000000..a06ff423bf8
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Instruments.ts
@@ -0,0 +1,24 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export enum InstrumentType {
+ COUNTER = 'COUNTER',
+ HISTOGRAM = 'HISTOGRAM',
+ UP_DOWN_COUNTER = 'UP_DOWN_COUNTER',
+ OBSERVABLE_COUNTER = 'OBSERVABLE_COUNTER',
+ OBSERVABLE_GAUGE = 'OBSERVABLE_GAUGE',
+ OBSERVABLE_UP_DOWN_COUNTER = 'OBSERVABLE_UP_DOWN_COUNTER',
+}
+
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Measurement.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Measurement.ts
new file mode 100644
index 00000000000..d8f3c94800f
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Measurement.ts
@@ -0,0 +1,23 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as api from '@opentelemetry/api'
+
+export type Measurement = {
+ value: number;
+ // TODO use common attributes
+ attributes: api.SpanAttributes;
+ context?: api.Context;
+}
\ No newline at end of file
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Meter.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Meter.ts
new file mode 100644
index 00000000000..1077e10cca9
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Meter.ts
@@ -0,0 +1,59 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as metrics from '@opentelemetry/api-metrics';
+import { InstrumentationLibrary } from '@opentelemetry/core';
+import { Measurement } from './Measurement';
+import { MeterProvider } from './MeterProvider';
+import { Histogram, Metric } from './Metric';
+
+export class Meter implements metrics.Meter {
+ // instrumentation library required by spec to be on meter
+ // spec requires provider config changes to apply to previously created meters, achieved by holding a reference to the provider
+ constructor(private _provider: MeterProvider, private _instrumentationLibrary: InstrumentationLibrary, private _schemaUrl?: string) { }
+
+ /** this exists just to prevent ts errors from unused variables and may be removed */
+ getSchemaUrl(): string | undefined {
+ return this._schemaUrl;
+ }
+
+ /** this exists just to prevent ts errors from unused variables and may be removed */
+ getInstrumentationLibrary(): InstrumentationLibrary {
+ return this._instrumentationLibrary;
+ }
+
+ createHistogram(_name: string, _options?: metrics.MetricOptions): Histogram {
+ throw new Error('Method not implemented.');
+ }
+ createCounter(_name: string, _options?: metrics.MetricOptions): metrics.Counter {
+ throw new Error('Method not implemented.');
+ }
+ createUpDownCounter(_name: string, _options?: metrics.MetricOptions): metrics.UpDownCounter {
+ throw new Error('Method not implemented.');
+ }
+ createObservableGauge(_name: string, _options?: metrics.MetricOptions, _callback?: (observableResult: metrics.ObservableResult) => void): metrics.ObservableBase {
+ throw new Error('Method not implemented.');
+ }
+ createObservableCounter(_name: string, _options?: metrics.MetricOptions, _callback?: (observableResult: metrics.ObservableResult) => void): metrics.ObservableBase {
+ throw new Error('Method not implemented.');
+ }
+ createObservableUpDownCounter(_name: string, _options?: metrics.MetricOptions, _callback?: (observableResult: metrics.ObservableResult) => void): metrics.ObservableBase {
+ throw new Error('Method not implemented.');
+ }
+
+ public aggregate(metric: Metric, measurement: Measurement) {
+ this._provider.aggregate(this, metric, measurement);
+ }
+}
\ No newline at end of file
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MeterProvider.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MeterProvider.ts
new file mode 100644
index 00000000000..2bbd720cb68
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MeterProvider.ts
@@ -0,0 +1,165 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as api from '@opentelemetry/api';
+import * as metrics from '@opentelemetry/api-metrics';
+import { Resource } from '@opentelemetry/resources';
+import { Measurement } from './Measurement';
+import { Meter } from './Meter';
+import { Metric } from './Metric';
+import { MetricExporter } from './MetricExporter';
+import { MetricReader } from './MetricReader';
+import { View } from './View';
+
+// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meterprovider
+
+export type MeterProviderOptions = {
+ resource?: Resource;
+}
+
+export class MeterProvider {
+ private _resource: Resource;
+ private _shutdown = false;
+ private _metricReaders: MetricReader[] = [];
+ private _metricExporters: MetricExporter[] = [];
+ private _views: View[] = [];
+
+ constructor(options: MeterProviderOptions) {
+ this._resource = options.resource ?? Resource.empty();
+ }
+
+ /**
+ * **Unstable**
+ *
+ * This method is only here to prevent typescript from complaining and may be removed.
+ */
+ getResource() {
+ return this._resource;
+ }
+
+ getMeter(name: string, version = '', options: metrics.MeterOptions = {}): metrics.Meter {
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meter-creation
+ if (this._shutdown) {
+ api.diag.warn('A shutdown MeterProvider cannot provide a Meter')
+ return metrics.NOOP_METER;
+ }
+
+ // Spec leaves it unspecified if creating a meter with duplicate
+ // name/version returns the same meter. We create a new one here
+ // for simplicity. This may change in the future.
+ return new Meter(this, { name, version }, options.schemaUrl);
+ }
+
+ addMetricReader(metricReader: MetricReader) {
+ this._metricReaders.push(metricReader);
+ }
+
+ addView(view: View) {
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#view
+ this._views.push(view);
+ }
+
+ async shutdown(): Promise {
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#shutdown
+
+ // TODO add a timeout - spec leaves it up the the SDK if this is configurable
+ this._shutdown = true;
+
+ // Shut down all exporters and readers.
+ // Throw the first error and log all others.
+ let err: unknown;
+ for (const exporter of this._metricExporters) {
+ try {
+ await exporter.shutdown();
+ } catch (e) {
+ if (e instanceof Error) {
+ api.diag.error(`Error shutting down: ${e.message}`)
+ }
+ err = err || e;
+ }
+ }
+
+ for (const reader of this._metricReaders) {
+ try {
+ await reader.shutdown();
+ } catch (e) {
+ if (e instanceof Error) {
+ api.diag.error(`Error shutting down: ${e.message}`)
+ }
+ err = err || e;
+ }
+ }
+
+ if (err != null) {
+ throw err;
+ }
+ }
+
+ async forceFlush(): Promise {
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#forceflush
+
+ // TODO add a timeout - spec leaves it up the the SDK if this is configurable
+
+ // do not flush after shutdown
+ if (this._shutdown) {
+ return;
+ }
+
+ // Flush all exporters and readers.
+ // Throw the first error and log all others.
+ let err: unknown;
+ for (const exporter of this._metricExporters) {
+ try {
+ await exporter.forceFlush();
+ } catch (e) {
+ if (e instanceof Error) {
+ api.diag.error(`Error force flushing: ${e.message}`)
+ }
+ err = err || e;
+ }
+ }
+
+ for (const reader of this._metricReaders) {
+ try {
+ await reader.forceFlush();
+ } catch (e) {
+ if (e instanceof Error) {
+ api.diag.error(`Error force flushing: ${e.message}`)
+ }
+ err = err || e;
+ }
+ }
+
+ if (err != null) {
+ throw err;
+ }
+ }
+
+ public aggregate(_meter: Meter, _metric: Metric, _measurement: Measurement) {
+ // TODO actually aggregate
+
+ /**
+ * if there are no views:
+ * apply the default configuration
+ * else:
+ * for each view:
+ * if view matches:
+ * apply view configuration
+ * if no view matched:
+ * if user has not disabled default fallback:
+ * apply default configuration
+ */
+ }
+}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Metric.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Metric.ts
new file mode 100644
index 00000000000..f49497a4d2f
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/Metric.ts
@@ -0,0 +1,73 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as api from '@opentelemetry/api';
+import * as metrics from '@opentelemetry/api-metrics';
+import { Measurement } from './Measurement';
+import { Meter } from './Meter';
+
+export class Metric {
+ constructor(private _meter: Meter, private _name: string, private _version?: string) { }
+
+ getName(): string {
+ return this._name;
+ }
+
+ /**
+ * This only exists to stop typescript complaining about unused variable and may be removed.
+ */
+ getVersion(): string | undefined {
+ return this._version;
+ }
+
+ aggregate(measurement: Measurement) {
+ this._meter.aggregate(this, measurement);
+ }
+}
+
+export class UpDownCounter extends Metric implements metrics.Counter {
+ add(value: number, attributes?: api.SpanAttributes, ctx?: api.Context): void {
+ if (typeof value != 'number') {
+ api.diag.warn(`invalid type value provided to counter ${this.getName()}: ${typeof value}`);
+ return;
+ }
+
+ attributes = attributes ?? {};
+ ctx = ctx ?? api.context.active();
+
+ this.aggregate({
+ value,
+ attributes,
+ context: ctx,
+ });
+ }
+}
+
+export class Counter extends UpDownCounter implements metrics.Counter {
+ override add(value: number, attributes?: api.SpanAttributes, ctx?: api.Context): void {
+ if (value < 0) {
+ api.diag.warn(`negative value provided to counter ${this.getName()}: ${value}`);
+ return;
+ }
+
+ return super.add(value, attributes, ctx);
+ }
+}
+
+export class Histogram extends Metric implements metrics.Histogram {
+ record(_measurement: number, _labels?: metrics.Labels, _context?: api.Context): void {
+ throw new Error('Method not implemented.');
+ }
+}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MetricExporter.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MetricExporter.ts
new file mode 100644
index 00000000000..bdbbf708491
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MetricExporter.ts
@@ -0,0 +1,42 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export abstract class MetricExporter {
+ private _shutdown = false;
+
+ async shutdown(): Promise {
+ try {
+ await this.forceFlush();
+ } finally {
+ this._shutdown = true;
+ }
+ }
+
+ abstract forceFlush(): Promise;
+
+ isShutdown() {
+ return this._shutdown;
+ }
+}
+
+export class ConsoleMetricExporter extends MetricExporter {
+ export() {
+ throw new Error('Method not implemented');
+ }
+
+ // nothing to do
+ async forceFlush() {}
+}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MetricReader.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MetricReader.ts
new file mode 100644
index 00000000000..7b4e0e2a5c2
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/MetricReader.ts
@@ -0,0 +1,42 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { MetricExporter } from '.';
+
+export class MetricReader {
+ private _shutdown = false;
+
+ constructor(private _exporter: MetricExporter) {}
+
+ async shutdown(): Promise {
+ if (this._shutdown) {
+ return;
+ }
+
+ this._shutdown = true;
+ // errors thrown to caller
+ await this._exporter.shutdown();
+ }
+
+ async forceFlush(): Promise {
+ if (this._shutdown) {
+ return;
+ }
+
+ // errors thrown to caller
+ await this._exporter.forceFlush();
+ }
+}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/View.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/View.ts
new file mode 100644
index 00000000000..e936ff265d1
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/View.ts
@@ -0,0 +1,112 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { InstrumentType } from './Instruments';
+
+// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#view
+
+/**
+ * A metric view selects a stream of metrics from a MeterProvider and applies
+ * a configuration to that stream. If no configuration is provided, the default
+ * configuration is used.
+ */
+export class View {
+ private _selector: Partial;
+
+ /**
+ * Construct a metric view
+ *
+ * @param options a required object which describes the view selector and configuration
+ */
+ constructor(options: ViewOptions) {
+ if (typeof options.selector == null) {
+ throw new Error('Missing required view selector')
+ }
+
+ if (
+ options.selector.instrumentType == null &&
+ options.selector.instrumentName == null &&
+ options.selector.meterName == null &&
+ options.selector.meterVersion == null &&
+ options.selector.meterSchemaUrl == null
+ ) {
+ // It is recommended by the SDK specification to fail fast when invalid options are provided
+ throw new Error('Cannot create a view which selects no options');
+ }
+
+ this._selector = options.selector;
+ }
+
+ /**
+ * Given a metric selector, determine if all of this view's metric selectors match.
+ *
+ * @param selector selector to match
+ * @returns boolean
+ */
+ public match(selector: ViewMetricSelector) {
+ return this._matchSelectorProperty('instrumentType', selector.instrumentType) &&
+ this._matchInstrumentName(selector.instrumentName) &&
+ this._matchSelectorProperty('meterName', selector.meterName) &&
+ this._matchSelectorProperty('meterVersion', selector.meterVersion) &&
+ this._matchSelectorProperty('meterSchemaUrl', selector.meterSchemaUrl);
+ }
+
+ /**
+ * Match instrument name against the configured selector metric name, which may include wildcards
+ */
+ private _matchInstrumentName(name: string) {
+ if (this._selector.instrumentName == null) {
+ return true;
+ }
+
+ return this._selector.instrumentName === name;
+ }
+
+ private _matchSelectorProperty(property: Prop, metricProperty: ViewMetricSelector[Prop]): boolean {
+ if (this._selector[property] == null) {
+ return true;
+ }
+
+ if (this._selector[property] === metricProperty) {
+ return true;
+ }
+
+ return false;
+ }
+}
+
+export type ViewMetricSelector = {
+ instrumentType: InstrumentType;
+ instrumentName: string;
+ meterName: string;
+ meterVersion?: string;
+ meterSchemaUrl?: string;
+}
+
+export type ViewOptions = {
+ name?: string;
+ selector: Partial;
+ streamConfig?: ViewStreamConfig;
+}
+
+export type ViewStreamConfig = {
+ description: string;
+ attributeKeys?: string[];
+
+ // TODO use these types when they are defined
+ aggregation?: unknown;
+ exemplarReservoir?: unknown;
+}
+
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/index.ts b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/index.ts
new file mode 100644
index 00000000000..305b5647687
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/src/index.ts
@@ -0,0 +1,18 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export { MeterProvider, MeterProviderOptions } from './MeterProvider';
+export * from './MetricExporter';
+export * from './MetricReader';
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/tsconfig.esm.json b/experimental/packages/opentelemetry-sdk-metrics-base-wip/tsconfig.esm.json
new file mode 100644
index 00000000000..53f9deefd02
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/tsconfig.esm.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../tsconfig.base.esm.json",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "build/esm",
+ "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo"
+ },
+ "include": [
+ "src/**/*.ts"
+ ],
+ "references": [
+ {
+ "path": "../opentelemetry-api-metrics/tsconfig.esm.json"
+ }
+ ]
+}
diff --git a/experimental/packages/opentelemetry-sdk-metrics-base-wip/tsconfig.json b/experimental/packages/opentelemetry-sdk-metrics-base-wip/tsconfig.json
new file mode 100644
index 00000000000..948abef3ceb
--- /dev/null
+++ b/experimental/packages/opentelemetry-sdk-metrics-base-wip/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "extends": "../../../tsconfig.base.json",
+ "compilerOptions": {
+ "rootDir": ".",
+ "outDir": "build"
+ },
+ "include": [
+ "src/**/*.ts",
+ "test/**/*.ts"
+ ],
+ "references": [
+ {
+ "path": "../opentelemetry-api-metrics"
+ }
+ ]
+}
diff --git a/experimental/tsconfig.esm.json b/experimental/tsconfig.esm.json
index d2bedd4f38c..eed79c878e0 100644
--- a/experimental/tsconfig.esm.json
+++ b/experimental/tsconfig.esm.json
@@ -6,17 +6,26 @@
"path": "packages/opentelemetry-api-metrics/tsconfig.esm.json"
},
{
- "path": "packages/opentelemetry-exporter-trace-otlp-grpc"
+ "path": "packages/opentelemetry-exporter-metrics-otlp-grpc"
},
{
- "path": "packages/opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json"
+ "path": "packages/opentelemetry-exporter-metrics-otlp-http/tsconfig.esm.json"
},
{
- "path": "packages/opentelemetry-exporter-trace-otlp-proto"
+ "path": "packages/opentelemetry-exporter-metrics-otlp-proto"
},
{
"path": "packages/opentelemetry-exporter-prometheus"
},
+ {
+ "path": "packages/opentelemetry-exporter-trace-otlp-grpc"
+ },
+ {
+ "path": "packages/opentelemetry-exporter-trace-otlp-http/tsconfig.esm.json"
+ },
+ {
+ "path": "packages/opentelemetry-exporter-trace-otlp-proto"
+ },
{
"path": "packages/opentelemetry-instrumentation-fetch/tsconfig.esm.json"
},
@@ -32,6 +41,9 @@
{
"path": "packages/opentelemetry-instrumentation/tsconfig.esm.json"
},
+ {
+ "path": "packages/opentelemetry-sdk-metrics-base-wip/tsconfig.esm.json"
+ },
{
"path": "packages/opentelemetry-sdk-metrics-base/tsconfig.esm.json"
},
diff --git a/experimental/tsconfig.json b/experimental/tsconfig.json
index 5a53c080f2b..e64feb8eb75 100644
--- a/experimental/tsconfig.json
+++ b/experimental/tsconfig.json
@@ -6,17 +6,26 @@
"path": "packages/opentelemetry-api-metrics"
},
{
- "path": "packages/opentelemetry-exporter-trace-otlp-grpc"
+ "path": "packages/opentelemetry-exporter-metrics-otlp-grpc"
},
{
- "path": "packages/opentelemetry-exporter-trace-otlp-http"
+ "path": "packages/opentelemetry-exporter-metrics-otlp-http"
},
{
- "path": "packages/opentelemetry-exporter-trace-otlp-proto"
+ "path": "packages/opentelemetry-exporter-metrics-otlp-proto"
},
{
"path": "packages/opentelemetry-exporter-prometheus"
},
+ {
+ "path": "packages/opentelemetry-exporter-trace-otlp-grpc"
+ },
+ {
+ "path": "packages/opentelemetry-exporter-trace-otlp-http"
+ },
+ {
+ "path": "packages/opentelemetry-exporter-trace-otlp-proto"
+ },
{
"path": "packages/opentelemetry-instrumentation-fetch"
},
@@ -33,13 +42,7 @@
"path": "packages/opentelemetry-instrumentation"
},
{
- "path": "packages/opentelemetry-exporter-metrics-otlp-http"
- },
- {
- "path": "packages/opentelemetry-exporter-metrics-otlp-grpc"
- },
- {
- "path": "packages/opentelemetry-exporter-metrics-otlp-proto"
+ "path": "packages/opentelemetry-sdk-metrics-base-wip"
},
{
"path": "packages/opentelemetry-sdk-metrics-base"