Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/metrics

Package Overview
Dependencies
Maintainers
4
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/metrics - npm Package Compare versions

Comparing version 0.11.1-alpha.48 to 0.11.1-alpha.53

build/src/export/aggregators/LastValue.d.ts

2

build/src/BatchObserverMetric.js

@@ -29,3 +29,3 @@ "use strict";

var _a;
super(name, options, types_1.MetricKind.VALUE_OBSERVER, resource, instrumentationLibrary);
super(name, options, types_1.MetricKind.BATCH_OBSERVER, resource, instrumentationLibrary);
this._batcher = _batcher;

@@ -32,0 +32,0 @@ this._maxTimeoutUpdateMS = (_a = options.maxTimeoutUpdateMS) !== null && _a !== void 0 ? _a : MAX_TIMEOUT_UPDATE_MS;

@@ -38,2 +38,3 @@ "use strict";

update(value) {
this._lastUpdateTime = core_1.hrTime();
this._current.count += 1;

@@ -40,0 +41,0 @@ this._current.sum += value;

export * from './Histogram';
export * from './MinMaxLastSumCount';
export * from './LastValue';
export * from './Sum';
//# sourceMappingURL=index.d.ts.map

@@ -29,4 +29,4 @@ "use strict";

__exportStar(require("./Histogram"), exports);
__exportStar(require("./MinMaxLastSumCount"), exports);
__exportStar(require("./LastValue"), exports);
__exportStar(require("./Sum"), exports);
//# sourceMappingURL=index.js.map

@@ -50,6 +50,7 @@ "use strict";

case types_1.MetricKind.VALUE_RECORDER:
return new aggregators.HistogramAggregator(metricDescriptor.boundaries || [Infinity]);
case types_1.MetricKind.VALUE_OBSERVER:
return new aggregators.MinMaxLastSumCountAggregator();
return new aggregators.LastValueAggregator();
default:
return new aggregators.MinMaxLastSumCountAggregator();
return new aggregators.LastValueAggregator();
}

@@ -56,0 +57,0 @@ }

@@ -9,4 +9,4 @@ import { MetricExporter, MetricRecord } from './types';

export(metrics: MetricRecord[], resultCallback: (result: ExportResult) => void): void;
shutdown(): void;
shutdown(): Promise<void>;
}
//# sourceMappingURL=ConsoleMetricExporter.d.ts.map

@@ -38,11 +38,3 @@ "use strict";

else {
const distribution = point.value;
console.log('min: ' +
distribution.min +
', max: ' +
distribution.max +
', count: ' +
distribution.count +
', sum: ' +
distribution.sum);
console.log(point.value);
}

@@ -54,2 +46,3 @@ }

// By default does nothing
return Promise.resolve();
}

@@ -56,0 +49,0 @@ }

@@ -35,5 +35,5 @@ "use strict";

}
async shutdown() {
shutdown() {
clearInterval(this._timer);
await this._collect();
return this._collect();
}

@@ -44,9 +44,6 @@ async _collect() {

this._exporter.export(this._meter.getBatcher().checkPointSet(), result => {
if (result === core_1.ExportResult.SUCCESS) {
resolve();
if (result !== core_1.ExportResult.SUCCESS) {
core_1.globalErrorHandler(new Error('PushController: export failed in _collect'));
}
else {
// @todo log error
reject();
}
resolve();
});

@@ -53,0 +50,0 @@ });

@@ -5,4 +5,4 @@ import { MetricExporter, MetricRecord } from './types';

export(metrics: MetricRecord[], resultCallback: (result: ExportResult) => void): void;
shutdown(): void;
shutdown(): Promise<void>;
}
//# sourceMappingURL=NoopExporter.d.ts.map

@@ -23,5 +23,7 @@ "use strict";

// By default does nothing
shutdown() { }
shutdown() {
return Promise.resolve();
}
}
exports.NoopExporter = NoopExporter;
//# sourceMappingURL=NoopExporter.js.map

@@ -11,4 +11,6 @@ import { ValueType, HrTime, Labels } from '@opentelemetry/api';

UP_DOWN_SUM_OBSERVER = 4,
VALUE_OBSERVER = 5
VALUE_OBSERVER = 5,
BATCH_OBSERVER = 6
}
export declare const MetricKindValues: (string | MetricKind)[];
/** The kind of aggregator. */

@@ -18,4 +20,3 @@ export declare enum AggregatorKind {

LAST_VALUE = 1,
DISTRIBUTION = 2,
HISTOGRAM = 3
HISTOGRAM = 2
}

@@ -26,10 +27,2 @@ /** Sum returns an aggregated sum. */

export declare type LastValue = number;
/** Distribution returns an aggregated distribution. */
export interface Distribution {
min: number;
max: number;
last: number;
count: number;
sum: number;
}
export interface Histogram {

@@ -59,3 +52,3 @@ /**

}
export declare type PointValueType = Sum | LastValue | Distribution | Histogram;
export declare type PointValueType = Sum | LastValue | Histogram;
export interface MetricRecord {

@@ -74,2 +67,3 @@ readonly descriptor: MetricDescriptor;

readonly valueType: ValueType;
readonly boundaries?: number[];
}

@@ -83,3 +77,3 @@ /**

/** Stops the exporter. */
shutdown(): void;
shutdown(): Promise<void>;
}

@@ -114,11 +108,2 @@ /**

/**
* DistributionAggregatorType aggregate values into a {@link Distribution}
* point type.
*/
export interface DistributionAggregatorType extends BaseAggregator {
kind: AggregatorKind.DISTRIBUTION;
/** Returns snapshot of the current point (value with timestamp). */
toPoint(): Point<Distribution>;
}
/**
* HistogramAggregatorType aggregate values into a {@link Histogram} point

@@ -132,3 +117,3 @@ * type.

}
export declare type Aggregator = SumAggregatorType | LastValueAggregatorType | DistributionAggregatorType | HistogramAggregatorType;
export declare type Aggregator = SumAggregatorType | LastValueAggregatorType | HistogramAggregatorType;
/**

@@ -135,0 +120,0 @@ * Point represents a snapshot of aggregated values of aggregators.

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregatorKind = exports.MetricKind = void 0;
exports.AggregatorKind = exports.MetricKindValues = exports.MetricKind = void 0;
/** The kind of metric. */

@@ -29,3 +29,5 @@ var MetricKind;

MetricKind[MetricKind["VALUE_OBSERVER"] = 5] = "VALUE_OBSERVER";
MetricKind[MetricKind["BATCH_OBSERVER"] = 6] = "BATCH_OBSERVER";
})(MetricKind = exports.MetricKind || (exports.MetricKind = {}));
exports.MetricKindValues = Object.values(MetricKind);
/** The kind of aggregator. */

@@ -36,5 +38,4 @@ var AggregatorKind;

AggregatorKind[AggregatorKind["LAST_VALUE"] = 1] = "LAST_VALUE";
AggregatorKind[AggregatorKind["DISTRIBUTION"] = 2] = "DISTRIBUTION";
AggregatorKind[AggregatorKind["HISTOGRAM"] = 3] = "HISTOGRAM";
AggregatorKind[AggregatorKind["HISTOGRAM"] = 2] = "HISTOGRAM";
})(AggregatorKind = exports.AggregatorKind || (exports.AggregatorKind = {}));
//# sourceMappingURL=types.js.map

@@ -15,2 +15,4 @@ import * as api from '@opentelemetry/api';

private readonly _controller;
private _isShutdown;
private _shuttingDownPromise;
/**

@@ -17,0 +19,0 @@ * Constructs a new Meter instance.

@@ -23,2 +23,3 @@ "use strict";

const BatchObserverMetric_1 = require("./BatchObserverMetric");
const types_1 = require("./export/types");
const UpDownCounterMetric_1 = require("./UpDownCounterMetric");

@@ -30,3 +31,3 @@ const CounterMetric_1 = require("./CounterMetric");

const SumObserverMetric_1 = require("./SumObserverMetric");
const types_1 = require("./types");
const types_2 = require("./types");
const Batcher_1 = require("./export/Batcher");

@@ -42,5 +43,7 @@ const Controller_1 = require("./export/Controller");

*/
constructor(instrumentationLibrary, config = types_1.DEFAULT_CONFIG) {
constructor(instrumentationLibrary, config = types_2.DEFAULT_CONFIG) {
var _a;
this._metrics = new Map();
this._isShutdown = false;
this._shuttingDownPromise = Promise.resolve();
this._logger = config.logger || new core_1.ConsoleLogger(config.logLevel);

@@ -65,3 +68,3 @@ this._batcher = (_a = config.batcher) !== null && _a !== void 0 ? _a : new Batcher_1.UngroupedBatcher();

}
const opt = Object.assign(Object.assign({ logger: this._logger }, types_1.DEFAULT_METRIC_OPTIONS), options);
const opt = Object.assign(Object.assign({ logger: this._logger }, types_2.DEFAULT_METRIC_OPTIONS), options);
const valueRecorder = new ValueRecorderMetric_1.ValueRecorderMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary);

@@ -83,3 +86,3 @@ this._registerMetric(name, valueRecorder);

}
const opt = Object.assign(Object.assign({ logger: this._logger }, types_1.DEFAULT_METRIC_OPTIONS), options);
const opt = Object.assign(Object.assign({ logger: this._logger }, types_2.DEFAULT_METRIC_OPTIONS), options);
const counter = new CounterMetric_1.CounterMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary);

@@ -104,3 +107,3 @@ this._registerMetric(name, counter);

}
const opt = Object.assign(Object.assign(Object.assign({}, types_1.DEFAULT_METRIC_OPTIONS), { logger: this._logger }), options);
const opt = Object.assign(Object.assign(Object.assign({}, types_2.DEFAULT_METRIC_OPTIONS), { logger: this._logger }), options);
const upDownCounter = new UpDownCounterMetric_1.UpDownCounterMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary);

@@ -121,3 +124,3 @@ this._registerMetric(name, upDownCounter);

}
const opt = Object.assign(Object.assign({ logger: this._logger }, types_1.DEFAULT_METRIC_OPTIONS), options);
const opt = Object.assign(Object.assign({ logger: this._logger }, types_2.DEFAULT_METRIC_OPTIONS), options);
const valueObserver = new ValueObserverMetric_1.ValueObserverMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary, callback);

@@ -132,3 +135,3 @@ this._registerMetric(name, valueObserver);

}
const opt = Object.assign(Object.assign({ logger: this._logger }, types_1.DEFAULT_METRIC_OPTIONS), options);
const opt = Object.assign(Object.assign({ logger: this._logger }, types_2.DEFAULT_METRIC_OPTIONS), options);
const sumObserver = new SumObserverMetric_1.SumObserverMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary, callback);

@@ -149,3 +152,3 @@ this._registerMetric(name, sumObserver);

}
const opt = Object.assign(Object.assign({ logger: this._logger }, types_1.DEFAULT_METRIC_OPTIONS), options);
const opt = Object.assign(Object.assign({ logger: this._logger }, types_2.DEFAULT_METRIC_OPTIONS), options);
const upDownSumObserver = new UpDownSumObserverMetric_1.UpDownSumObserverMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary, callback);

@@ -166,3 +169,3 @@ this._registerMetric(name, upDownSumObserver);

}
const opt = Object.assign(Object.assign({ logger: this._logger }, types_1.DEFAULT_METRIC_OPTIONS), options);
const opt = Object.assign(Object.assign({ logger: this._logger }, types_2.DEFAULT_METRIC_OPTIONS), options);
const batchObserver = new BatchObserverMetric_1.BatchObserverMetric(name, opt, this._batcher, this._resource, this._instrumentationLibrary, callback);

@@ -180,5 +183,23 @@ this._registerMetric(name, batchObserver);

async collect() {
const metrics = Array.from(this._metrics.values()).map(metric => {
// call batch observers first
const batchObservers = Array.from(this._metrics.values())
.filter(metric => {
return metric.getKind() === types_1.MetricKind.BATCH_OBSERVER;
})
.map(metric => {
return metric.getMetricRecord();
});
await Promise.all(batchObservers).then(records => {
records.forEach(metrics => {
metrics.forEach(metric => this._batcher.process(metric));
});
});
// after this all remaining metrics can be run
const metrics = Array.from(this._metrics.values())
.filter(metric => {
return metric.getKind() !== types_1.MetricKind.BATCH_OBSERVER;
})
.map(metric => {
return metric.getMetricRecord();
});
await Promise.all(metrics).then(records => {

@@ -193,4 +214,18 @@ records.forEach(metrics => {

}
async shutdown() {
await this._controller.shutdown();
shutdown() {
if (this._isShutdown) {
return this._shuttingDownPromise;
}
this._isShutdown = true;
this._shuttingDownPromise = new Promise((resolve, reject) => {
Promise.resolve()
.then(() => {
return this._controller.shutdown();
})
.then(resolve)
.catch(e => {
reject(e);
});
});
return this._shuttingDownPromise;
}

@@ -197,0 +232,0 @@ /**

@@ -11,3 +11,4 @@ import * as api from '@opentelemetry/api';

private readonly _meters;
private _cleanNotifyOnGlobalShutdown;
private _shuttingDownPromise;
private _isShutdown;
readonly resource: Resource;

@@ -22,5 +23,4 @@ readonly logger: api.Logger;

getMeter(name: string, version?: string, config?: MeterConfig): Meter;
shutdown(cb?: () => void): void;
private _shutdownAllMeters;
shutdown(): Promise<void>;
}
//# sourceMappingURL=MeterProvider.d.ts.map

@@ -30,2 +30,4 @@ "use strict";

this._meters = new Map();
this._shuttingDownPromise = Promise.resolve();
this._isShutdown = false;
this.logger = (_a = config.logger) !== null && _a !== void 0 ? _a : new core_1.ConsoleLogger(config.logLevel);

@@ -37,5 +39,2 @@ this.resource = (_b = config.resource) !== null && _b !== void 0 ? _b : resources_1.Resource.createTelemetrySDKResource();

});
if (this._config.gracefulShutdown) {
this._cleanNotifyOnGlobalShutdown = core_1.notifyOnGlobalShutdown(this._shutdownAllMeters.bind(this));
}
}

@@ -54,19 +53,27 @@ /**

}
shutdown(cb = () => { }) {
this._shutdownAllMeters().then(() => {
setTimeout(cb, 0);
shutdown() {
if (this._isShutdown) {
return this._shuttingDownPromise;
}
this._isShutdown = true;
this._shuttingDownPromise = new Promise((resolve, reject) => {
Promise.resolve()
.then(() => {
return Promise.all(Array.from(this._meters, ([_, meter]) => meter.shutdown()));
})
.then(() => {
if (this._config.exporter) {
return this._config.exporter.shutdown();
}
return;
})
.then(resolve)
.catch(e => {
reject(e);
});
});
if (this._cleanNotifyOnGlobalShutdown) {
this._cleanNotifyOnGlobalShutdown();
this._cleanNotifyOnGlobalShutdown = undefined;
}
return this._shuttingDownPromise;
}
_shutdownAllMeters() {
if (this._config.exporter) {
this._config.exporter.shutdown();
}
return Promise.all(Array.from(this._meters, ([_, meter]) => meter.shutdown()));
}
}
exports.MeterProvider = MeterProvider;
//# sourceMappingURL=MeterProvider.js.map

@@ -36,2 +36,6 @@ import * as api from '@opentelemetry/api';

clear(): void;
/**
* Returns kind of metric
*/
getKind(): MetricKind;
getMetricRecord(): Promise<MetricRecord[]>;

@@ -38,0 +42,0 @@ private _getMetricDescriptor;

@@ -68,2 +68,8 @@ "use strict";

}
/**
* Returns kind of metric
*/
getKind() {
return this._kind;
}
getMetricRecord() {

@@ -70,0 +76,0 @@ return new Promise(resolve => {

@@ -20,4 +20,2 @@ import { LogLevel } from '@opentelemetry/core';

batcher?: Batcher;
/** Bool for whether or not graceful shutdown is enabled. If disabled metrics will not be exported when SIGTERM is recieved */
gracefulShutdown?: boolean;
}

@@ -27,3 +25,2 @@ /** Default Meter configuration. */

logLevel: LogLevel;
gracefulShutdown: boolean;
};

@@ -30,0 +27,0 @@ /** The default metric creation options value. */

@@ -24,3 +24,2 @@ "use strict";

logLevel: core_1.getEnv().OTEL_LOG_LEVEL,
gracefulShutdown: true,
};

@@ -27,0 +26,0 @@ /** The default metric creation options value. */

@@ -1,2 +0,2 @@

export declare const VERSION = "0.11.1-alpha.48+15174c6";
export declare const VERSION = "0.11.1-alpha.53+00a8ce7f";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.11.1-alpha.48+15174c6';
exports.VERSION = '0.11.1-alpha.53+00a8ce7f';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/metrics",
"version": "0.11.1-alpha.48+15174c6",
"version": "0.11.1-alpha.53+00a8ce7f",
"description": "OpenTelemetry metrics SDK",

@@ -55,11 +55,11 @@ "main": "build/src/index.js",

"ts-mocha": "7.0.0",
"ts-node": "8.10.2",
"ts-node": "9.0.0",
"typescript": "3.9.7"
},
"dependencies": {
"@opentelemetry/api": "^0.11.1-alpha.48+15174c6",
"@opentelemetry/core": "^0.11.1-alpha.48+15174c6",
"@opentelemetry/resources": "^0.11.1-alpha.48+15174c6"
"@opentelemetry/api": "^0.11.1-alpha.53+00a8ce7f",
"@opentelemetry/core": "^0.11.1-alpha.53+00a8ce7f",
"@opentelemetry/resources": "^0.11.1-alpha.53+00a8ce7f"
},
"gitHead": "15174c6647ab9863dfc1424412fa60f2fddb3351"
"gitHead": "00a8ce7f982ea24bcd4bc398477112894078ab29"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc