Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into lazy-create-gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
fungiboletus authored Nov 9, 2021
2 parents 8df94f1 + 1abda14 commit 4bb0158
Show file tree
Hide file tree
Showing 98 changed files with 1,281 additions and 869 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
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
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,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 @@ -346,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 @@ -536,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 @@ -551,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();
}
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
30 changes: 8 additions & 22 deletions experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*/

import { BatchObserverResult } from './types/BatchObserverResult';
import { Meter } from './types/Meter';
import {
MetricOptions,
Labels,
Attributes,
Counter,
Histogram,
ObservableGauge,
Expand Down Expand Up @@ -105,31 +104,20 @@ 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 {}

export class NoopCounterMetric extends NoopMetric implements Counter {
add(_value: number, _labels: Labels): void {}
add(_value: number, _attributes: Attributes): void {}
}

export class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
add(_value: number, _labels: Labels): void {}
add(_value: number, _attributes: Attributes): void {}
}

export class NoopHistogramMetric extends NoopMetric implements Histogram {
record(_value: number, _labels: Labels): void {}
record(_value: number, _attributes: Attributes): void {}
}

export class NoopObservableBaseMetric extends NoopMetric implements ObservableBase {
Expand All @@ -141,16 +129,14 @@ export class NoopObservableBaseMetric extends NoopMetric implements ObservableBa
}
}

export class NoopBatchObserver {}

export const NOOP_METER = new NoopMeter();

// Synchronous instruments
export const NOOP_COUNTER_METRIC = new NoopCounterMetric();
export const NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
export const NOOP_HISTOGRAM_METRIC = new NoopHistogramMetric();
export const NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();

// 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();
export const NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableBaseMetric();

export const NOOP_BATCH_OBSERVER = new NoopBatchObserver();
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

export * from './NoopMeter';
export * from './NoopMeterProvider';
export * from './types/BatchObserverResult';
export * from './types/Meter';
export * from './types/MeterProvider';
export * from './types/Metric';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

import { BatchObserverResult } from './BatchObserverResult';
import {
MetricOptions,
Counter,
Histogram,
ObservableGauge,
BatchObserverOptions,
UpDownCounter,
ObservableCounter,
ObservableUpDownCounter,
Expand All @@ -41,7 +39,7 @@ export interface MeterOptions {
* An interface to allow the recording metrics.
*
* {@link Metric}s are used for recording pre-defined aggregation (`Counter`),
* or raw values (`Histogram`) in which the aggregation and labels
* or raw values (`Histogram`) in which the aggregation and attributes
* for the exported metric are deferred.
*/
export interface Meter {
Expand Down Expand Up @@ -115,15 +113,4 @@ export interface Meter {
options?: MetricOptions,
callback?: (observableResult: ObservableResult) => void
): ObservableUpDownCounter;

/**
* Creates a new `BatchObserver`, can be used to update many metrics
* at the same time and when operations needs to be async
* @param callback the batch observer callback
* @param [options] the batch observer options.
*/
createBatchObserver(
callback: (batchObserverResult: BatchObserverResult) => void,
options?: BatchObserverOptions
): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export interface MetricOptions {
*/
unit?: string;

/** The map of constant labels for the Metric. */
constantLabels?: Map<string, string>;
/** The map of constant attributes for the Metric. */
constantAttributes?: Map<string, string>;

/**
* Indicates the metric is a verbose metric that is disabled by default
Expand All @@ -63,13 +63,6 @@ export interface MetricOptions {
aggregationTemporality?: AggregationTemporality;
}

export interface BatchObserverOptions {
/**
* Indicates how long the batch metric should wait to update before cancel
*/
maxTimeoutUpdateMS?: number;
}

/** The Type of value. It describes how the data is reported. */
export enum ValueType {
INT,
Expand Down Expand Up @@ -100,30 +93,30 @@ export enum AggregationTemporality {
*/
export interface Counter {
/**
* Adds the given value to the current value. Values cannot be negative.
* Increment value of counter by the input. Inputs may not be negative.
*/
add(value: number, labels?: Labels): void;
add(value: number, attributes?: Attributes): void;
}

export interface UpDownCounter {
/**
* Adds the given value to the current value. Values can be negative.
* Increment value of counter by the input. Inputs may be negative.
*/
add(value: number, labels?: Labels): void;
add(value: number, attributes?: Attributes): void;
}

export interface Histogram {
/**
* Records the given value to this histogram.
*/
record(value: number, labels?: Labels): void;
record(value: number, attributes?: Attributes): void;
}

/** Base interface for the Observable metrics. */
export interface ObservableBase {
observation: (
value: number,
labels?: Labels,
attributes?: Attributes,
) => Observation;
}

Expand All @@ -139,4 +132,4 @@ export type ObservableCounter = ObservableBase;
/**
* key-value pairs passed by the user.
*/
export type Labels = { [key: string]: string };
export type Attributes = { [key: string]: string };
Loading

0 comments on commit 4bb0158

Please sign in to comment.