diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 1d576cc70d..554b4ebfee 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -15,8 +15,29 @@ Before creating a pull request, please make sure:
## Which problem is this PR solving?
--
+Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
+
+Fixes # (issue)
## Short description of the changes
--
+## Type of change
+
+Please delete options that are not relevant.
+
+- [ ] Bug fix (non-breaking change which fixes an issue)
+- [ ] New feature (non-breaking change which adds functionality)
+- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
+- [ ] This change requires a documentation update
+
+## How Has This Been Tested?
+
+Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
+
+- [ ] Test A
+
+## Checklist:
+
+- [ ] Followed the style guidelines of this project
+- [ ] Unit tests have been added
+- [ ] Documentation has been updated
diff --git a/.github/workflows/peer-api.yaml b/.github/workflows/peer-api.yaml
index 2917235bc3..f4f1731ea9 100644
--- a/.github/workflows/peer-api.yaml
+++ b/.github/workflows/peer-api.yaml
@@ -18,9 +18,13 @@ jobs:
- name: Install lerna
run: npm install -g lerna
+ - name: Install semver
+ run: npm install semver
+
- name: Check API dependency semantics (stable)
- run: lerna exec --ignore propagation-validation-server "node ../../scripts/peer-api-check.js"
+ working-directory: packages
+ run: lerna exec --ignore propagation-validation-server --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests "node ../../scripts/peer-api-check.js"
- name: Check API dependency semantics (experimental)
working-directory: experimental
- run: lerna exec --ignore propagation-validation-server "node ../../../scripts/peer-api-check.js"
+ run: lerna exec --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests "node ../../../scripts/peer-api-check.js"
diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index 6352235f8b..4cc9daca63 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -35,7 +35,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --ignore-scripts
- npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
+ npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --ignore @opentelemetry/selenium-tests
- name: Build 🔧
run: |
@@ -111,7 +111,7 @@ jobs:
working-directory: experimental
run: |
npm install --ignore-scripts
- npx lerna bootstrap --no-ci --hoist --nohoist='zone.js'
+ npx lerna bootstrap --no-ci --hoist --nohoist='zone.js' --ignore @opentelemetry/selenium-tests
- name: Build 🔧
working-directory: experimental
diff --git a/.gitmodules b/.gitmodules
index ac506a776f..278e2d9a57 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,12 @@
-[submodule "experimental/packages/opentelemetry-exporter-otlp-proto/protos"]
- path = experimental/packages/opentelemetry-exporter-otlp-proto/protos
+[submodule "experimental/packages/opentelemetry-exporter-trace-otlp-proto/protos"]
+ path = experimental/packages/opentelemetry-exporter-trace-otlp-proto/protos
url = https://github.com/open-telemetry/opentelemetry-proto.git
-[submodule "experimental/packages/opentelemetry-exporter-otlp-grpc/protos"]
- path = experimental/packages/opentelemetry-exporter-otlp-grpc/protos
+[submodule "experimental/packages/opentelemetry-exporter-trace-otlp-grpc/protos"]
+ path = experimental/packages/opentelemetry-exporter-trace-otlp-grpc/protos
+ url = https://github.com/open-telemetry/opentelemetry-proto.git
+[submodule "experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/protos"]
+ path = experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/protos
+ url = https://github.com/open-telemetry/opentelemetry-proto.git
+[submodule "experimental/packages/opentelemetry-exporter-metrics-otlp-proto/protos"]
+ path = experimental/packages/opentelemetry-exporter-metrics-otlp-proto/protos
url = https://github.com/open-telemetry/opentelemetry-proto.git
diff --git a/README.md b/README.md
index d5e2f0d917..ab729fc636 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
---
- Getting Started
+ Getting Started
•
API Reference
•
@@ -49,7 +49,7 @@ This is the JavaScript version of [OpenTelemetry](https://opentelemetry.io/), a
| API Version | Core version | Experimental Packages | Contrib Version |
| ----------- |--------------| --------------------- |-------------------------|
-| 1.0.x | 1.x | 0.26.x | ------ |
+| 1.0.x | 1.x | 0.26.x | 0.26.x |
| 1.0.x | 0.26.x | ----- | ------ |
| 1.0.x | 0.25.x | ----- | ------ |
| 1.0.x | 0.24.x | ----- | 0.24.x |
@@ -131,7 +131,7 @@ process.on('SIGTERM', () => {
node -r ./tracing.js app.js
```
-The above example will emit auto-instrumented telemetry about your Node.js application to the console. For a more in-depth example, see the [Getting Started Guide](https://github.com/open-telemetry/opentelemetry-js/blob/main/getting-started/README.md). For more information about automatic instrumentation see [@opentelemetry/sdk-trace-node][otel-node], which provides auto-instrumentation for Node.js applications. If the automatic instrumentation does not suit your needs, or you would like to create manual traces, see [@opentelemetry/sdk-trace-base][otel-tracing]
+The above example will emit auto-instrumented telemetry about your Node.js application to the console. For a more in-depth example, see the [Getting Started Guide](https://opentelemetry.io/docs/js/getting-started/). For more information about automatic instrumentation see [@opentelemetry/sdk-trace-node][otel-node], which provides auto-instrumentation for Node.js applications. If the automatic instrumentation does not suit your needs, or you would like to create manual traces, see [@opentelemetry/sdk-trace-base][otel-tracing]
### Library Author
@@ -286,6 +286,35 @@ To request automatic tracing support for a module not on this list, please [file
## Upgrade guidelines
+### 0.26.x to 0.27.x
+
+Metric and trace exporters are split into separate packages:
+
+- `@opentelemetry/exporter-otlp-http` => `@opentelemetry/exporter-trace-otlp-http` and `@opentelemetry/exporter-metrics-otlp-http`
+- `@opentelemetry/exporter-otlp-grpc` => `@opentelemetry/exporter-trace-otlp-grpc` and `@opentelemetry/exporter-metrics-otlp-grpc`
+- `@opentelemetry/exporter-otlp-proto` => `@opentelemetry/exporter-trace-otlp-proto` and `@opentelemetry/exporter-metrics-otlp-proto`
+
+Metric types are renamed:
+
+- `@openetelemetry/api-metrics`
+ - `Meter`
+ - `createValueRecorder` => `createHistogram`
+ - `createValueObserver` => `createObservableGauge`
+ - `createSumObserver` => `createObservableCounter`
+ - `createUpDownSumObserver` => `createObservableUpDownCounter`
+ - `ValueRecorder` => `Histogram`
+ - `ValueObserver` => `ObservableGauge`
+ - `SumObserver` => `ObservableCounter`
+ - `UpDownSumObserver` => `ObservableUpDownCounter`
+ - `ObserverResult` => `ObservableResult`
+ - `Observation.observer` => `Observation.observable`
+- `@opentelemetry/sdk-metrics-base`
+ - `MetricKind`
+ - `VALUE_RECORDER` => `HISTOGRAM`
+ - `SUM_OBSERVER` => `OBSERVABLE_COUNTER`
+ - `UP_DOWN_SUM_OBSERVER` => `OBSERVABLE_UP_DOWN_COUNTER`
+ - `VALUE_OBSERVER` => `OBSERVABLE_GAUGE`
+
### 0.25.x to 1.x.y
Collector exporter packages and types are renamed:
@@ -308,6 +337,9 @@ Collector exporter packages and types are renamed:
- `CollectorExporterNodeBase` => `OTLPExporterNodeBase`
- `CollectorMetricExporter` => `OTLPMetricExporter`
- `CollectorTraceExporter` => `OTLPTraceExporter`
+- W3C propagators in @opentelemetry/core were renamed
+ - `HttpTraceContextPropagator` -> `W3CTraceContextPropagator`
+ - `HttpBaggagePropagator` -> `W3CBaggagePropagator`
### 0.24.x to 0.25.x
@@ -317,9 +349,6 @@ Collector exporter packages and types are renamed:
- @opentelemetry/web -> @opentelemetry/sdk-trace-web
- @opentelemetry/metrics -> @opentelemetry/sdk-metrics-base
- @opentelemetry/node-sdk -> @opentelemetry/sdk-node
-- W3C propagators in @opentelemetry/core were renamed
- - `HttpTraceContextPropagator` -> `W3CTraceContextPropagator`
- - `W3CBaggagePropagator` -> `W3CBaggagePropagator`
### 0.23.x to 0.24.x
@@ -507,13 +536,13 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[docs]: https://open-telemetry.github.io/opentelemetry-js
[compliance-matrix]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md
-[otel-metrics]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-metrics-base
+[otel-metrics]: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-metrics-base
[otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node
-[otel-instrumentation-fetch]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-fetch
-[otel-instrumentation-grpc]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-grpc
-[otel-instrumentation-http]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http
-[otel-instrumentation-xml-http-request]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-xml-http-request
+[otel-instrumentation-fetch]: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-fetch
+[otel-instrumentation-grpc]: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-grpc
+[otel-instrumentation-http]: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-http
+[otel-instrumentation-xml-http-request]: https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-xml-http-request
[otel-shim-opentracing]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-shim-opentracing
[otel-tracing]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-base
@@ -522,16 +551,16 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
[otel-core]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core
[generate-api-documentation]: https://github.com/open-telemetry/opentelemetry-js/blob/main/CONTRIBUTING.md#generating-api-documentation
-[otel-contrib-instrumentation-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-dns
-[otel-contrib-instrumentation-ioredis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-ioredis
-[otel-contrib-instrumentation-mongodb]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-mongodb
-[otel-contrib-instrumentation-mysql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-mysql
-[otel-contrib-instrumentation-pg]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-pg
-[otel-contrib-instrumentation-redis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-redis
-[otel-contrib-instrumentation-express]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-express
-[otel-contrib-instrumentation-user-interaction]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-instrumentation-user-interaction
-[otel-contrib-instrumentation-document-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-instrumentation-document-load
-[otel-contrib-instrumentation-hapi]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-hapi
-[otel-contrib-instrumentation-koa]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-koa
+[otel-contrib-instrumentation-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-dns
+[otel-contrib-instrumentation-ioredis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-ioredis
+[otel-contrib-instrumentation-mongodb]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mongodb
+[otel-contrib-instrumentation-mysql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mysql
+[otel-contrib-instrumentation-pg]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-pg
+[otel-contrib-instrumentation-redis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis
+[otel-contrib-instrumentation-express]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express
+[otel-contrib-instrumentation-user-interaction]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-user-interaction
+[otel-contrib-instrumentation-document-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-instrumentation-document-load
+[otel-contrib-instrumentation-hapi]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-hapi
+[otel-contrib-instrumentation-koa]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-koa
[spec-versioning]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md
diff --git a/doc/processor-api.md b/doc/processor-api.md
index b3abbcdecc..944834b038 100644
--- a/doc/processor-api.md
+++ b/doc/processor-api.md
@@ -138,7 +138,7 @@ const meter = new MeterProvider({
interval: 1000,
}).getMeter('example-custom-processor');
-const requestsLatency = meter.createValueRecorder('requests', {
+const requestsLatency = meter.createHistogram('requests', {
monotonic: true,
description: 'Average latency'
});
diff --git a/examples/metrics/metrics/observer.js b/examples/metrics/metrics/observer.js
index def56d872b..a2ad804e2c 100644
--- a/examples/metrics/metrics/observer.js
+++ b/examples/metrics/metrics/observer.js
@@ -21,72 +21,18 @@ const exporter = new PrometheusExporter(
const meter = new MeterProvider({
exporter,
interval: 2000,
-}).getMeter('example-observer');
+}).getMeter('example-meter');
-meter.createValueObserver('cpu_core_usage', {
- description: 'Example of a sync value observer with callback',
-}, async (observerResult) => { // this callback is called once per each interval
+meter.createObservableGauge('cpu_core_usage', {
+ description: 'Example of a sync observable gauge with callback',
+}, async (observableResult) => { // this callback is called once per each interval
await new Promise((resolve) => {
- setTimeout(()=> {resolve()}, 50);
+ setTimeout(() => { resolve(); }, 50);
});
- observerResult.observe(getRandomValue(), { core: '1' });
- observerResult.observe(getRandomValue(), { core: '2' });
+ observableResult.observe(getRandomValue(), { core: '1' });
+ observableResult.observe(getRandomValue(), { core: '2' });
});
-// no callback as they will be updated in batch observer
-const tempMetric = meter.createValueObserver('cpu_temp_per_app', {
- description: 'Example of sync value observer used with async batch observer',
-});
-
-// no callback as they will be updated in batch observer
-const cpuUsageMetric = meter.createValueObserver('cpu_usage_per_app', {
- description: 'Example of sync value observer used with async batch observer',
-});
-
-meter.createBatchObserver((observerBatchResult) => {
- Promise.all([
- someAsyncMetrics(),
- // simulate waiting
- new Promise((resolve, reject) => {
- setTimeout(resolve, 300);
- }),
- ]).then(([apps, waiting]) => {
- apps.forEach(app => {
- observerBatchResult.observe({ app: app.name, core: '1' }, [
- tempMetric.observation(app.core1.temp),
- cpuUsageMetric.observation(app.core1.usage),
- ]);
- observerBatchResult.observe({ app: app.name, core: '2' }, [
- tempMetric.observation(app.core2.temp),
- cpuUsageMetric.observation(app.core2.usage),
- ]);
- });
- });
- }, {
- maxTimeoutUpdateMS: 500,
- },
-);
-
-function someAsyncMetrics() {
- return new Promise((resolve) => {
- setTimeout(() => {
- const stats = [
- {
- name: 'app1',
- core1: { usage: getRandomValue(), temp: getRandomValue() * 100 },
- core2: { usage: getRandomValue(), temp: getRandomValue() * 100 },
- },
- {
- name: 'app2',
- core1: { usage: getRandomValue(), temp: getRandomValue() * 100 },
- core2: { usage: getRandomValue(), temp: getRandomValue() * 100 },
- },
- ];
- resolve(stats);
- }, 200);
- });
-}
-
function getRandomValue() {
return Math.random();
}
diff --git a/examples/otlp-exporter-node/metrics.js b/examples/otlp-exporter-node/metrics.js
index e0065aa697..cb90169405 100644
--- a/examples/otlp-exporter-node/metrics.js
+++ b/examples/otlp-exporter-node/metrics.js
@@ -31,14 +31,14 @@ const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
description: 'Example of a UpDownCounter',
});
-const recorder = meter.createValueRecorder('test_value_recorder', {
- description: 'Example of a ValueRecorder',
+const histogram = meter.createHistogram('test_histogram', {
+ description: 'Example of a Histogram',
});
const labels = { pid: process.pid, environment: 'staging' };
setInterval(() => {
- requestCounter.bind(labels).add(1);
- upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
- recorder.bind(labels).record(Math.random());
+ requestCounter.add(1, labels);
+ upDownCounter.add(Math.random() > 0.5 ? 1 : -1, labels);
+ histogram.record(Math.random(), labels);
}, 1000);
diff --git a/examples/prometheus/index.js b/examples/prometheus/index.js
index e486c2701e..ea3f2e6882 100644
--- a/examples/prometheus/index.js
+++ b/examples/prometheus/index.js
@@ -30,6 +30,6 @@ const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
const labels = { pid: process.pid, environment: 'staging' };
setInterval(() => {
- requestCounter.bind(labels).add(1);
- upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
+ requestCounter.add(1, labels);
+ upDownCounter.add(Math.random() > 0.5 ? 1 : -1, labels);
}, 1000);
diff --git a/examples/tracer-web/examples/metrics/index.js b/examples/tracer-web/examples/metrics/index.js
index 53d6ac6a07..e067e30c7e 100644
--- a/examples/tracer-web/examples/metrics/index.js
+++ b/examples/tracer-web/examples/metrics/index.js
@@ -41,8 +41,8 @@ function startMetrics() {
const labels = { pid: process.pid, environment: 'staging' };
interval = setInterval(() => {
- requestCounter.bind(labels).add(1);
- upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
+ requestCounter.add(1, labels);
+ upDownCounter.add(Math.random() > 0.5 ? 1 : -1, labels);
}, 1000);
}
diff --git a/experimental/packages/opentelemetry-api-metrics/package.json b/experimental/packages/opentelemetry-api-metrics/package.json
index 5cb9e1503b..cb99f06016 100644
--- a/experimental/packages/opentelemetry-api-metrics/package.json
+++ b/experimental/packages/opentelemetry-api-metrics/package.json
@@ -54,17 +54,13 @@
"publishConfig": {
"access": "public"
},
- "peerDependencies": {
- "@opentelemetry/api": "^1.0.2"
- },
"devDependencies": {
- "@opentelemetry/api": "^1.0.2",
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/webpack-env": "1.16.2",
"codecov": "3.8.3",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.2.3",
+ "karma": "6.3.7",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
diff --git a/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts b/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
index 6e0fd5bd20..a5568b545d 100644
--- a/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
+++ b/experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
@@ -14,25 +14,19 @@
* limitations under the License.
*/
-import { BatchObserverResult } from './types/BatchObserverResult';
import { Meter } from './types/Meter';
import {
MetricOptions,
- UnboundMetric,
- Labels,
+ Attributes,
Counter,
- ValueRecorder,
- ValueObserver,
+ Histogram,
+ ObservableGauge,
UpDownCounter,
- BaseObserver,
- UpDownSumObserver,
+ ObservableBase,
+ ObservableCounter,
+ ObservableUpDownCounter,
} from './types/Metric';
-import {
- BoundValueRecorder,
- BoundCounter,
- BoundBaseObserver,
-} from './types/BoundInstrument';
-import { ObserverResult } from './types/ObserverResult';
+import { ObservableResult } from './types/ObservableResult';
import { Observation } from './types/Observation';
/**
@@ -43,12 +37,12 @@ export class NoopMeter implements Meter {
constructor() {}
/**
- * Returns constant noop value recorder.
+ * Returns a constant noop histogram.
* @param name the name of the metric.
* @param [options] the metric options.
*/
- createValueRecorder(_name: string, _options?: MetricOptions): ValueRecorder {
- return NOOP_VALUE_RECORDER_METRIC;
+ createHistogram(_name: string, _options?: MetricOptions): Histogram {
+ return NOOP_HISTOGRAM_METRIC;
}
/**
@@ -66,162 +60,83 @@ export class NoopMeter implements Meter {
* @param [options] the metric options.
*/
createUpDownCounter(_name: string, _options?: MetricOptions): UpDownCounter {
- return NOOP_COUNTER_METRIC;
+ return NOOP_UP_DOWN_COUNTER_METRIC;
}
/**
- * Returns constant noop value observer.
+ * Returns a constant noop observable gauge.
* @param name the name of the metric.
* @param [options] the metric options.
- * @param [callback] the value observer callback
+ * @param [callback] the observable gauge callback
*/
- createValueObserver(
+ createObservableGauge(
_name: string,
_options?: MetricOptions,
- _callback?: (observerResult: ObserverResult) => void
- ): ValueObserver {
- return NOOP_VALUE_OBSERVER_METRIC;
+ _callback?: (observableResult: ObservableResult) => void
+ ): ObservableGauge {
+ return NOOP_OBSERVABLE_GAUGE_METRIC;
}
/**
- * Returns constant noop sum observer.
+ * Returns a constant noop observable counter.
* @param name the name of the metric.
* @param [options] the metric options.
- * @param [callback] the sum observer callback
+ * @param [callback] the observable counter callback
*/
- createSumObserver(
+ createObservableCounter(
_name: string,
_options?: MetricOptions,
- _callback?: (observerResult: ObserverResult) => void
- ): ValueObserver {
- return NOOP_SUM_OBSERVER_METRIC;
+ _callback?: (observableResult: ObservableResult) => void
+ ): ObservableCounter {
+ return NOOP_OBSERVABLE_COUNTER_METRIC;
}
/**
- * Returns constant noop up down sum observer.
+ * Returns a constant noop up down observable counter.
* @param name the name of the metric.
* @param [options] the metric options.
- * @param [callback] the up down sum observer callback
+ * @param [callback] the up down observable counter callback
*/
- createUpDownSumObserver(
+ createObservableUpDownCounter(
_name: string,
_options?: MetricOptions,
- _callback?: (observerResult: ObserverResult) => void
- ): UpDownSumObserver {
- return NOOP_UP_DOWN_SUM_OBSERVER_METRIC;
- }
-
- /**
- * Returns constant noop batch observer.
- * @param name the name of the metric.
- * @param callback the batch observer callback
- */
- createBatchObserver(
- _callback: (batchObserverResult: BatchObserverResult) => void
- ): NoopBatchObserver {
- return NOOP_BATCH_OBSERVER;
+ _callback?: (observableResult: ObservableResult) => void
+ ): ObservableUpDownCounter {
+ return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
}
}
-export class NoopMetric implements UnboundMetric {
- private readonly _instrument: T;
-
- constructor(instrument: T) {
- this._instrument = instrument;
- }
-
- /**
- * Returns a Bound Instrument associated with specified Labels.
- * It is recommended to keep a reference to the Bound Instrument instead of
- * always calling this method for every operations.
- * @param labels key-values pairs that are associated with a specific metric
- * that you want to record.
- */
- bind(_labels: Labels): T {
- return this._instrument;
- }
-
- /**
- * Removes the Binding from the metric, if it is present.
- * @param labels key-values pairs that are associated with a specific metric.
- */
- unbind(_labels: Labels): void {
- return;
- }
+export class NoopMetric {}
- /**
- * Clears all timeseries from the Metric.
- */
- clear(): void {
- return;
- }
+export class NoopCounterMetric extends NoopMetric implements Counter {
+ add(_value: number, _attributes: Attributes): void {}
}
-export class NoopCounterMetric
- extends NoopMetric
- implements Counter {
- add(value: number, labels: Labels): void {
- this.bind(labels).add(value);
- }
+export class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
+ add(_value: number, _attributes: Attributes): void {}
}
-export class NoopValueRecorderMetric
- extends NoopMetric
- implements ValueRecorder {
- record(value: number, labels: Labels): void {
- this.bind(labels).record(value);
- }
+export class NoopHistogramMetric extends NoopMetric implements Histogram {
+ record(_value: number, _attributes: Attributes): void {}
}
-export class NoopBaseObserverMetric
- extends NoopMetric
- implements BaseObserver {
+export class NoopObservableBaseMetric extends NoopMetric implements ObservableBase {
observation(): Observation {
return {
- observer: this as BaseObserver,
+ observable: this as ObservableBase,
value: 0,
};
}
}
-export class NoopBatchObserver {}
-
-export class NoopBoundCounter implements BoundCounter {
- add(_value: number): void {
- return;
- }
-}
-
-export class NoopBoundValueRecorder implements BoundValueRecorder {
- record(_value: number, _baggage?: unknown, _spanContext?: unknown): void {
- return;
- }
-}
-
-export class NoopBoundBaseObserver implements BoundBaseObserver {
- update(_value: number): void {}
-}
-
export const NOOP_METER = new NoopMeter();
-export const NOOP_BOUND_COUNTER = new NoopBoundCounter();
-export const NOOP_COUNTER_METRIC = new NoopCounterMetric(NOOP_BOUND_COUNTER);
-
-export const NOOP_BOUND_VALUE_RECORDER = new NoopBoundValueRecorder();
-export const NOOP_VALUE_RECORDER_METRIC = new NoopValueRecorderMetric(
- NOOP_BOUND_VALUE_RECORDER
-);
-
-export const NOOP_BOUND_BASE_OBSERVER = new NoopBoundBaseObserver();
-export const NOOP_VALUE_OBSERVER_METRIC = new NoopBaseObserverMetric(
- NOOP_BOUND_BASE_OBSERVER
-);
-
-export const NOOP_UP_DOWN_SUM_OBSERVER_METRIC = new NoopBaseObserverMetric(
- NOOP_BOUND_BASE_OBSERVER
-);
-export const NOOP_SUM_OBSERVER_METRIC = new NoopBaseObserverMetric(
- NOOP_BOUND_BASE_OBSERVER
-);
+// Synchronous instruments
+export const NOOP_COUNTER_METRIC = new NoopCounterMetric();
+export const NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();
+export const NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
-export const NOOP_BATCH_OBSERVER = new NoopBatchObserver();
+// Asynchronous instruments
+export const NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableBaseMetric();
+export const NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableBaseMetric();
+export const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableBaseMetric();
diff --git a/experimental/packages/opentelemetry-api-metrics/src/NoopMeterProvider.ts b/experimental/packages/opentelemetry-api-metrics/src/NoopMeterProvider.ts
index 2cc737960e..97628d7122 100644
--- a/experimental/packages/opentelemetry-api-metrics/src/NoopMeterProvider.ts
+++ b/experimental/packages/opentelemetry-api-metrics/src/NoopMeterProvider.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Meter } from './types/Meter';
+import { Meter, MeterOptions } from './types/Meter';
import { MeterProvider } from './types/MeterProvider';
import { NOOP_METER } from './NoopMeter';
@@ -23,7 +23,7 @@ import { NOOP_METER } from './NoopMeter';
* for all calls to `getMeter`
*/
export class NoopMeterProvider implements MeterProvider {
- getMeter(_name?: string, _version?: string): Meter {
+ getMeter(_name: string, _version?: string, _options?: MeterOptions): Meter {
return NOOP_METER;
}
}
diff --git a/experimental/packages/opentelemetry-api-metrics/src/api/global-utils.ts b/experimental/packages/opentelemetry-api-metrics/src/api/global-utils.ts
index a23f76396d..e371d5165d 100644
--- a/experimental/packages/opentelemetry-api-metrics/src/api/global-utils.ts
+++ b/experimental/packages/opentelemetry-api-metrics/src/api/global-utils.ts
@@ -52,4 +52,4 @@ export function makeGetter(
* version. If the global API is not compatible with the API package
* attempting to get it, a NOOP API implementation will be returned.
*/
-export const API_BACKWARDS_COMPATIBILITY_VERSION = 3;
+export const API_BACKWARDS_COMPATIBILITY_VERSION = 4;
diff --git a/experimental/packages/opentelemetry-api-metrics/src/api/metrics.ts b/experimental/packages/opentelemetry-api-metrics/src/api/metrics.ts
index 079fc952e4..3e5fb6015a 100644
--- a/experimental/packages/opentelemetry-api-metrics/src/api/metrics.ts
+++ b/experimental/packages/opentelemetry-api-metrics/src/api/metrics.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { Meter } from '../types/Meter';
+import { Meter, MeterOptions } from '../types/Meter';
import { MeterProvider } from '../types/MeterProvider';
import { NOOP_METER_PROVIDER } from '../NoopMeterProvider';
import {
@@ -73,8 +73,8 @@ export class MetricsAPI {
/**
* Returns a meter from the global meter provider.
*/
- public getMeter(name: string, version?: string): Meter {
- return this.getMeterProvider().getMeter(name, version);
+ public getMeter(name: string, version?: string, options?: MeterOptions): Meter {
+ return this.getMeterProvider().getMeter(name, version, options);
}
/** Remove the global meter provider */
diff --git a/experimental/packages/opentelemetry-api-metrics/src/index.ts b/experimental/packages/opentelemetry-api-metrics/src/index.ts
index de39eb0821..ffdac63125 100644
--- a/experimental/packages/opentelemetry-api-metrics/src/index.ts
+++ b/experimental/packages/opentelemetry-api-metrics/src/index.ts
@@ -16,13 +16,11 @@
export * from './NoopMeter';
export * from './NoopMeterProvider';
-export * from './types/BatchObserverResult';
-export * from './types/BoundInstrument';
export * from './types/Meter';
export * from './types/MeterProvider';
export * from './types/Metric';
export * from './types/Observation';
-export * from './types/ObserverResult';
+export * from './types/ObservableResult';
import { MetricsAPI } from './api/metrics';
/** Entrypoint for metrics API */
diff --git a/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts b/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts
index 34a8254b88..693547b7c2 100644
--- a/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts
+++ b/experimental/packages/opentelemetry-api-metrics/src/platform/browser/globalThis.ts
@@ -14,6 +14,22 @@
* limitations under the License.
*/
+// Updates to this file should also be replicated to @opentelemetry/api and
+// @opentelemetry/core too.
+
+/**
+ * - globalThis (New standard)
+ * - self (Will return the current window instance for supported browsers)
+ * - window (fallback for older browser implementations)
+ * - global (NodeJS implementation)
+ * -