Skip to content

Commit

Permalink
Merge branch 'main' into feature/fix-broken-links
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierAlbertini authored Nov 5, 2021
2 parents 0552e3e + c827274 commit 7731dc6
Show file tree
Hide file tree
Showing 201 changed files with 3,122 additions and 1,754 deletions.
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
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ To request automatic tracing support for a module not on this list, please [file

### 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`
Expand Down Expand Up @@ -331,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 @@ -340,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 @@ -530,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 @@ -545,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
56 changes: 1 addition & 55 deletions examples/metrics/metrics/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,66 +27,12 @@ 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);
});
observableResult.observe(getRandomValue(), { core: '1' });
observableResult.observe(getRandomValue(), { core: '2' });
});

// no callback as they will be updated in batch observer
const tempMetric = meter.createObservableGauge('cpu_temp_per_app', {
description: 'Example of sync observable gauge used with async batch observer',
});

// no callback as they will be updated in batch observer
const cpuUsageMetric = meter.createObservableGauge('cpu_usage_per_app', {
description: 'Example of sync observable gauge used with async batch observer',
});

meter.createBatchObserver((batchObserverResult) => {
Promise.all([
someAsyncMetrics(),
// simulate waiting
new Promise((resolve, reject) => {
setTimeout(resolve, 300);
}),
]).then(([apps, waiting]) => {
apps.forEach(app => {
batchObserverResult.observe({ app: app.name, core: '1' }, [
tempMetric.observation(app.core1.temp),
cpuUsageMetric.observation(app.core1.usage),
]);
batchObserverResult.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();
}
6 changes: 3 additions & 3 deletions examples/otlp-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const histogram = meter.createHistogram('test_histogram', {
const labels = { pid: process.pid, environment: 'staging' };

setInterval(() => {
requestCounter.bind(labels).add(1);
upDownCounter.bind(labels).add(Math.random() > 0.5 ? 1 : -1);
histogram.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
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@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
120 changes: 17 additions & 103 deletions experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
* limitations under the License.
*/

import { BatchObserverResult } from './types/BatchObserverResult';
import { Meter } from './types/Meter';
import {
MetricOptions,
UnboundMetric,
Labels,
Counter,
Histogram,
Expand All @@ -28,11 +26,6 @@ import {
ObservableCounter,
ObservableUpDownCounter,
} from './types/Metric';
import {
BoundHistogram,
BoundCounter,
BoundObservableBase,
} from './types/BoundInstrument';
import { ObservableResult } from './types/ObservableResult';
import { Observation } from './types/Observation';

Expand Down Expand Up @@ -67,7 +60,7 @@ 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;
}

/**
Expand Down Expand Up @@ -111,72 +104,23 @@ export class NoopMeter implements Meter {
): ObservableUpDownCounter {
return NOOP_OBSERVABLE_UP_DOWN_COUNTER_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;
}
}

export class NoopMetric<T> implements UnboundMetric<T> {
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, _labels: Labels): void {}
}

export class NoopCounterMetric
extends NoopMetric<BoundCounter>
implements Counter {
add(value: number, labels: Labels): void {
this.bind(labels).add(value);
}
export class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
add(_value: number, _labels: Labels): void {}
}

export class NoopHistogramMetric
extends NoopMetric<BoundHistogram>
implements Histogram {
record(value: number, labels: Labels): void {
this.bind(labels).record(value);
}
export class NoopHistogramMetric extends NoopMetric implements Histogram {
record(_value: number, _labels: Labels): void {}
}

export class NoopObservableBaseMetric
extends NoopMetric<BoundObservableBase>
implements ObservableBase {
export class NoopObservableBaseMetric extends NoopMetric implements ObservableBase {
observation(): Observation {
return {
observable: this as ObservableBase,
Expand All @@ -185,44 +129,14 @@ export class NoopObservableBaseMetric
}
}

export class NoopBatchObserver {}

export class NoopBoundCounter implements BoundCounter {
add(_value: number): void {
return;
}
}

export class NoopBoundHistogram implements BoundHistogram {
record(_value: number, _baggage?: unknown, _spanContext?: unknown): void {
return;
}
}

export class NoopBoundObservableBase implements BoundObservableBase {
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_HISTOGRAM = new NoopBoundHistogram();
export const NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric(
NOOP_BOUND_HISTOGRAM
);

export const NOOP_BOUND_OBSERVABLE_BASE = new NoopBoundObservableBase();
export const NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableBaseMetric(
NOOP_BOUND_OBSERVABLE_BASE
);

export const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableBaseMetric(
NOOP_BOUND_OBSERVABLE_BASE
);

export const NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableBaseMetric(
NOOP_BOUND_OBSERVABLE_BASE
);
// 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();
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
}
}
Expand Down
Loading

0 comments on commit 7731dc6

Please sign in to comment.