Skip to content

Commit

Permalink
Merge branch 'main' into chore/add-stale-issue-gha
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Nov 10, 2021
2 parents 6ddbb90 + 2e378fd commit 34588a4
Show file tree
Hide file tree
Showing 314 changed files with 5,477 additions and 4,350 deletions.
25 changes: 23 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
73 changes: 51 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
<p align="center">
<strong>
<a href="https://github.com/open-telemetry/opentelemetry-js/blob/main/getting-started/README.md">Getting Started</a>
<a href="https://opentelemetry.io/docs/js/getting-started/">Getting Started</a>
&nbsp;&nbsp;&bull;&nbsp;&nbsp;
<a href="https://open-telemetry.github.io/opentelemetry-js-api">API Reference</a>
&nbsp;&nbsp;&bull;&nbsp;&nbsp;
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion doc/processor-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
});
Expand Down
68 changes: 7 additions & 61 deletions examples/metrics/metrics/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
10 changes: 5 additions & 5 deletions examples/otlp-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 2 additions & 2 deletions examples/prometheus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 2 additions & 2 deletions examples/tracer-web/examples/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 1 addition & 5 deletions experimental/packages/opentelemetry-api-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 34588a4

Please sign in to comment.