Socket
Socket
Sign inDemoInstall

@opentelemetry/api-metrics

Package Overview
Dependencies
1
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.27.0 to 0.28.0

build/esnext/api/global-utils.d.ts

1

build/esm/index.d.ts

@@ -6,3 +6,2 @@ export * from './NoopMeter';

export * from './types/Metric';
export * from './types/Observation';
export * from './types/ObservableResult';

@@ -9,0 +8,0 @@ import { MetricsAPI } from './api/metrics';

@@ -21,3 +21,2 @@ /*

export * from './types/Metric';
export * from './types/Observation';
export * from './types/ObservableResult';

@@ -24,0 +23,0 @@ import { MetricsAPI } from './api/metrics';

import { Meter } from './types/Meter';
import { MetricOptions, Attributes, Counter, Histogram, ObservableGauge, UpDownCounter, ObservableBase, ObservableCounter, ObservableUpDownCounter } from './types/Metric';
import { ObservableResult } from './types/ObservableResult';
import { Observation } from './types/Observation';
import { MetricOptions, MetricAttributes, Counter, Histogram, UpDownCounter, ObservableCallback } from './types/Metric';
/**

@@ -32,20 +30,20 @@ * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses

* @param name the name of the metric.
* @param callback the observable gauge callback
* @param [options] the metric options.
* @param [callback] the observable gauge callback
*/
createObservableGauge(_name: string, _options?: MetricOptions, _callback?: (observableResult: ObservableResult) => void): ObservableGauge;
createObservableGauge(_name: string, _callback: ObservableCallback, _options?: MetricOptions): void;
/**
* Returns a constant noop observable counter.
* @param name the name of the metric.
* @param callback the observable counter callback
* @param [options] the metric options.
* @param [callback] the observable counter callback
*/
createObservableCounter(_name: string, _options?: MetricOptions, _callback?: (observableResult: ObservableResult) => void): ObservableCounter;
createObservableCounter(_name: string, _callback: ObservableCallback, _options?: MetricOptions): void;
/**
* Returns a constant noop up down observable counter.
* @param name the name of the metric.
* @param callback the up down observable counter callback
* @param [options] the metric options.
* @param [callback] the up down observable counter callback
*/
createObservableUpDownCounter(_name: string, _options?: MetricOptions, _callback?: (observableResult: ObservableResult) => void): ObservableUpDownCounter;
createObservableUpDownCounter(_name: string, _callback: ObservableCallback, _options?: MetricOptions): void;
}

@@ -55,13 +53,10 @@ export declare class NoopMetric {

export declare class NoopCounterMetric extends NoopMetric implements Counter {
add(_value: number, _attributes: Attributes): void;
add(_value: number, _attributes: MetricAttributes): void;
}
export declare class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
add(_value: number, _attributes: Attributes): void;
add(_value: number, _attributes: MetricAttributes): void;
}
export declare class NoopHistogramMetric extends NoopMetric implements Histogram {
record(_value: number, _attributes: Attributes): void;
record(_value: number, _attributes: MetricAttributes): void;
}
export declare class NoopObservableBaseMetric extends NoopMetric implements ObservableBase {
observation(): Observation;
}
export declare const NOOP_METER: NoopMeter;

@@ -71,5 +66,2 @@ export declare const NOOP_COUNTER_METRIC: NoopCounterMetric;

export declare const NOOP_UP_DOWN_COUNTER_METRIC: NoopUpDownCounterMetric;
export declare const NOOP_OBSERVABLE_COUNTER_METRIC: NoopObservableBaseMetric;
export declare const NOOP_OBSERVABLE_GAUGE_METRIC: NoopObservableBaseMetric;
export declare const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC: NoopObservableBaseMetric;
//# sourceMappingURL=NoopMeter.d.ts.map

@@ -65,26 +65,20 @@ /*

* @param name the name of the metric.
* @param callback the observable gauge callback
* @param [options] the metric options.
* @param [callback] the observable gauge callback
*/
NoopMeter.prototype.createObservableGauge = function (_name, _options, _callback) {
return NOOP_OBSERVABLE_GAUGE_METRIC;
};
NoopMeter.prototype.createObservableGauge = function (_name, _callback, _options) { };
/**
* Returns a constant noop observable counter.
* @param name the name of the metric.
* @param callback the observable counter callback
* @param [options] the metric options.
* @param [callback] the observable counter callback
*/
NoopMeter.prototype.createObservableCounter = function (_name, _options, _callback) {
return NOOP_OBSERVABLE_COUNTER_METRIC;
};
NoopMeter.prototype.createObservableCounter = function (_name, _callback, _options) { };
/**
* Returns a constant noop up down observable counter.
* @param name the name of the metric.
* @param callback the up down observable counter callback
* @param [options] the metric options.
* @param [callback] the up down observable counter callback
*/
NoopMeter.prototype.createObservableUpDownCounter = function (_name, _options, _callback) {
return NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
};
NoopMeter.prototype.createObservableUpDownCounter = function (_name, _callback, _options) { };
return NoopMeter;

@@ -126,16 +120,2 @@ }());

export { NoopHistogramMetric };
var NoopObservableBaseMetric = /** @class */ (function (_super) {
__extends(NoopObservableBaseMetric, _super);
function NoopObservableBaseMetric() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoopObservableBaseMetric.prototype.observation = function () {
return {
observable: this,
value: 0,
};
};
return NoopObservableBaseMetric;
}(NoopMetric));
export { NoopObservableBaseMetric };
export var NOOP_METER = new NoopMeter();

@@ -146,6 +126,2 @@ // Synchronous instruments

export var NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
// Asynchronous instruments
export var NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableBaseMetric();
export var NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableBaseMetric();
export var NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableBaseMetric();
//# sourceMappingURL=NoopMeter.js.map

@@ -1,3 +0,3 @@

import { MetricOptions, Counter, Histogram, ObservableGauge, UpDownCounter, ObservableCounter, ObservableUpDownCounter } from './Metric';
import { ObservableResult } from './ObservableResult';
import { CounterOptions, HistogramOptions, UpDownCounterOptions } from '..';
import { Counter, Histogram, ObservableCallback, ObservableCounterOptions, ObservableGaugeOptions, ObservableUpDownCounterOptions, UpDownCounter } from './Metric';
/**

@@ -25,3 +25,3 @@ * An interface describes additional metadata of a meter.

*/
createHistogram(name: string, options?: MetricOptions): Histogram;
createHistogram(name: string, options?: HistogramOptions): Histogram;
/**

@@ -34,3 +34,3 @@ * Creates a new `Counter` metric. Generally, this kind of metric when the

*/
createCounter(name: string, options?: MetricOptions): Counter;
createCounter(name: string, options?: CounterOptions): Counter;
/**

@@ -53,25 +53,25 @@ * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous

*/
createUpDownCounter(name: string, options?: MetricOptions): UpDownCounter;
createUpDownCounter(name: string, options?: UpDownCounterOptions): UpDownCounter;
/**
* Creates a new `ObservableGauge` metric.
* @param name the name of the metric.
* @param callback the observable callback
* @param [options] the metric options.
* @param [callback] the observable callback
*/
createObservableGauge(name: string, options?: MetricOptions, callback?: (observableResult: ObservableResult) => void): ObservableGauge;
createObservableGauge(name: string, callback: ObservableCallback, options?: ObservableGaugeOptions): void;
/**
* Creates a new `ObservableCounter` metric.
* @param name the name of the metric.
* @param callback the observable callback
* @param [options] the metric options.
* @param [callback] the observable callback
*/
createObservableCounter(name: string, options?: MetricOptions, callback?: (observableResult: ObservableResult) => void): ObservableCounter;
createObservableCounter(name: string, callback: ObservableCallback, options?: ObservableCounterOptions): void;
/**
* Creates a new `ObservableUpDownCounter` metric.
* @param name the name of the metric.
* @param callback the observable callback
* @param [options] the metric options.
* @param [callback] the observable callback
*/
createObservableUpDownCounter(name: string, options?: MetricOptions, callback?: (observableResult: ObservableResult) => void): ObservableUpDownCounter;
createObservableUpDownCounter(name: string, callback: ObservableCallback, options?: ObservableUpDownCounterOptions): void;
}
//# sourceMappingURL=Meter.d.ts.map

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

import { Observation } from './Observation';
import { Context } from '@opentelemetry/api';
import { ObservableResult } from './ObservableResult';
/**

@@ -6,4 +7,2 @@ * Options needed for metric creation

export interface MetricOptions {
/** The name of the component that reports the Metric. */
component?: string;
/**

@@ -16,13 +15,6 @@ * The description of the Metric.

* The unit of the Metric values.
* @default '1'
* @default ''
*/
unit?: 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
* @default false
*/
disabled?: boolean;
/**
* Indicates the type of the recorded value.

@@ -32,11 +24,9 @@ * @default {@link ValueType.DOUBLE}

valueType?: ValueType;
/**
* Boundaries optional for histogram
*/
boundaries?: number[];
/**
* Aggregation Temporality of metric
*/
aggregationTemporality?: AggregationTemporality;
}
export declare type CounterOptions = MetricOptions;
export declare type UpDownCounterOptions = MetricOptions;
export declare type ObservableGaugeOptions = MetricOptions;
export declare type ObservableCounterOptions = MetricOptions;
export declare type ObservableUpDownCounterOptions = MetricOptions;
export declare type HistogramOptions = MetricOptions;
/** The Type of value. It describes how the data is reported. */

@@ -47,8 +37,2 @@ export declare enum ValueType {

}
/** The kind of aggregator. */
export declare enum AggregationTemporality {
AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,
AGGREGATION_TEMPORALITY_DELTA = 1,
AGGREGATION_TEMPORALITY_CUMULATIVE = 2
}
/**

@@ -73,3 +57,3 @@ * Counter is the most common synchronous instrument. This instrument supports

*/
add(value: number, attributes?: Attributes): void;
add(value: number, attributes?: MetricAttributes, context?: Context): void;
}

@@ -80,26 +64,20 @@ export interface UpDownCounter {

*/
add(value: number, attributes?: Attributes): void;
add(value: number, attributes?: MetricAttributes, context?: Context): void;
}
export interface Histogram {
/**
* Records the given value to this histogram.
* Records a measurement. Value of the measurement must not be negative.
*/
record(value: number, attributes?: Attributes): void;
record(value: number, attributes?: MetricAttributes, context?: Context): void;
}
/** Base interface for the Observable metrics. */
export interface ObservableBase {
observation: (value: number, attributes?: Attributes) => Observation;
}
/** Base interface for the ObservableGauge metrics. */
export declare type ObservableGauge = ObservableBase;
/** Base interface for the ObservableUpDownCounter metrics. */
export declare type ObservableUpDownCounter = ObservableBase;
/** Base interface for the ObservableCounter metrics. */
export declare type ObservableCounter = ObservableBase;
/**
* key-value pairs passed by the user.
*/
export declare type Attributes = {
export declare type MetricAttributes = {
[key: string]: string;
};
/**
* The observable callback for Observable instruments.
*/
export declare type ObservableCallback = (observableResult: ObservableResult) => void | Promise<void>;
//# sourceMappingURL=Metric.d.ts.map

@@ -22,9 +22,2 @@ /*

})(ValueType || (ValueType = {}));
/** The kind of aggregator. */
export var AggregationTemporality;
(function (AggregationTemporality) {
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_UNSPECIFIED"] = 0] = "AGGREGATION_TEMPORALITY_UNSPECIFIED";
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_DELTA"] = 1] = "AGGREGATION_TEMPORALITY_DELTA";
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_CUMULATIVE"] = 2] = "AGGREGATION_TEMPORALITY_CUMULATIVE";
})(AggregationTemporality || (AggregationTemporality = {}));
//# sourceMappingURL=Metric.js.map

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

import { Attributes } from './Metric';
import { MetricAttributes } from './Metric';
/**

@@ -6,4 +6,12 @@ * Interface that is being used in callback function for Observable Metric

export interface ObservableResult {
observe(value: number, attributes: Attributes): void;
/**
* Observe a measurement of the value associated with the given attributes.
*
* @param value The value to be observed.
* @param attributes The attributes associated with the value. If more than
* one values associated with the same attributes values, SDK may pick the
* last one or simply drop the entire observable result.
*/
observe(value: number, attributes?: MetricAttributes): void;
}
//# sourceMappingURL=ObservableResult.d.ts.map

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

export declare const VERSION = "0.27.0";
export declare const VERSION = "0.28.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '0.27.0';
export var VERSION = '0.28.0';
//# sourceMappingURL=version.js.map

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

exports.API_BACKWARDS_COMPATIBILITY_VERSION = exports.makeGetter = exports._global = exports.GLOBAL_METRICS_API_KEY = void 0;
var platform_1 = require("../platform");
const platform_1 = require("../platform");
exports.GLOBAL_METRICS_API_KEY = Symbol.for('io.opentelemetry.js.api.metrics');

@@ -32,5 +32,3 @@ exports._global = platform_1._globalThis;

function makeGetter(requiredVersion, instance, fallback) {
return function (version) {
return version === requiredVersion ? instance : fallback;
};
return (version) => version === requiredVersion ? instance : fallback;
}

@@ -37,0 +35,0 @@ exports.makeGetter = makeGetter;

@@ -19,13 +19,12 @@ "use strict";

exports.MetricsAPI = void 0;
var NoopMeterProvider_1 = require("../NoopMeterProvider");
var global_utils_1 = require("./global-utils");
const NoopMeterProvider_1 = require("../NoopMeterProvider");
const global_utils_1 = require("./global-utils");
/**
* Singleton object which represents the entry point to the OpenTelemetry Metrics API
*/
var MetricsAPI = /** @class */ (function () {
class MetricsAPI {
/** Empty private constructor prevents end users from constructing a new instance of the API */
function MetricsAPI() {
}
constructor() { }
/** Get the singleton instance of the Metrics API */
MetricsAPI.getInstance = function () {
static getInstance() {
if (!this._instance) {

@@ -35,7 +34,7 @@ this._instance = new MetricsAPI();

return this._instance;
};
}
/**
* Set the current global meter. Returns the initialized global meter provider.
*/
MetricsAPI.prototype.setGlobalMeterProvider = function (provider) {
setGlobalMeterProvider(provider) {
if (global_utils_1._global[global_utils_1.GLOBAL_METRICS_API_KEY]) {

@@ -45,25 +44,24 @@ // global meter provider has already been set

}
global_utils_1._global[global_utils_1.GLOBAL_METRICS_API_KEY] = global_utils_1.makeGetter(global_utils_1.API_BACKWARDS_COMPATIBILITY_VERSION, provider, NoopMeterProvider_1.NOOP_METER_PROVIDER);
global_utils_1._global[global_utils_1.GLOBAL_METRICS_API_KEY] = (0, global_utils_1.makeGetter)(global_utils_1.API_BACKWARDS_COMPATIBILITY_VERSION, provider, NoopMeterProvider_1.NOOP_METER_PROVIDER);
return provider;
};
}
/**
* Returns the global meter provider.
*/
MetricsAPI.prototype.getMeterProvider = function () {
getMeterProvider() {
var _a, _b;
return ((_b = (_a = global_utils_1._global[global_utils_1.GLOBAL_METRICS_API_KEY]) === null || _a === void 0 ? void 0 : _a.call(global_utils_1._global, global_utils_1.API_BACKWARDS_COMPATIBILITY_VERSION)) !== null && _b !== void 0 ? _b : NoopMeterProvider_1.NOOP_METER_PROVIDER);
};
}
/**
* Returns a meter from the global meter provider.
*/
MetricsAPI.prototype.getMeter = function (name, version, options) {
getMeter(name, version, options) {
return this.getMeterProvider().getMeter(name, version, options);
};
}
/** Remove the global meter provider */
MetricsAPI.prototype.disable = function () {
disable() {
delete global_utils_1._global[global_utils_1.GLOBAL_METRICS_API_KEY];
};
return MetricsAPI;
}());
}
}
exports.MetricsAPI = MetricsAPI;
//# sourceMappingURL=metrics.js.map

@@ -6,3 +6,2 @@ export * from './NoopMeter';

export * from './types/Metric';
export * from './types/Observation';
export * from './types/ObservableResult';

@@ -9,0 +8,0 @@ import { MetricsAPI } from './api/metrics';

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

__exportStar(require("./types/Metric"), exports);
__exportStar(require("./types/Observation"), exports);
__exportStar(require("./types/ObservableResult"), exports);
var metrics_1 = require("./api/metrics");
const metrics_1 = require("./api/metrics");
/** Entrypoint for metrics API */
exports.metrics = metrics_1.MetricsAPI.getInstance();
//# sourceMappingURL=index.js.map
import { Meter } from './types/Meter';
import { MetricOptions, Attributes, Counter, Histogram, ObservableGauge, UpDownCounter, ObservableBase, ObservableCounter, ObservableUpDownCounter } from './types/Metric';
import { ObservableResult } from './types/ObservableResult';
import { Observation } from './types/Observation';
import { MetricOptions, MetricAttributes, Counter, Histogram, UpDownCounter, ObservableCallback } from './types/Metric';
/**

@@ -32,20 +30,20 @@ * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses

* @param name the name of the metric.
* @param callback the observable gauge callback
* @param [options] the metric options.
* @param [callback] the observable gauge callback
*/
createObservableGauge(_name: string, _options?: MetricOptions, _callback?: (observableResult: ObservableResult) => void): ObservableGauge;
createObservableGauge(_name: string, _callback: ObservableCallback, _options?: MetricOptions): void;
/**
* Returns a constant noop observable counter.
* @param name the name of the metric.
* @param callback the observable counter callback
* @param [options] the metric options.
* @param [callback] the observable counter callback
*/
createObservableCounter(_name: string, _options?: MetricOptions, _callback?: (observableResult: ObservableResult) => void): ObservableCounter;
createObservableCounter(_name: string, _callback: ObservableCallback, _options?: MetricOptions): void;
/**
* Returns a constant noop up down observable counter.
* @param name the name of the metric.
* @param callback the up down observable counter callback
* @param [options] the metric options.
* @param [callback] the up down observable counter callback
*/
createObservableUpDownCounter(_name: string, _options?: MetricOptions, _callback?: (observableResult: ObservableResult) => void): ObservableUpDownCounter;
createObservableUpDownCounter(_name: string, _callback: ObservableCallback, _options?: MetricOptions): void;
}

@@ -55,13 +53,10 @@ export declare class NoopMetric {

export declare class NoopCounterMetric extends NoopMetric implements Counter {
add(_value: number, _attributes: Attributes): void;
add(_value: number, _attributes: MetricAttributes): void;
}
export declare class NoopUpDownCounterMetric extends NoopMetric implements UpDownCounter {
add(_value: number, _attributes: Attributes): void;
add(_value: number, _attributes: MetricAttributes): void;
}
export declare class NoopHistogramMetric extends NoopMetric implements Histogram {
record(_value: number, _attributes: Attributes): void;
record(_value: number, _attributes: MetricAttributes): void;
}
export declare class NoopObservableBaseMetric extends NoopMetric implements ObservableBase {
observation(): Observation;
}
export declare const NOOP_METER: NoopMeter;

@@ -71,5 +66,2 @@ export declare const NOOP_COUNTER_METRIC: NoopCounterMetric;

export declare const NOOP_UP_DOWN_COUNTER_METRIC: NoopUpDownCounterMetric;
export declare const NOOP_OBSERVABLE_COUNTER_METRIC: NoopObservableBaseMetric;
export declare const NOOP_OBSERVABLE_GAUGE_METRIC: NoopObservableBaseMetric;
export declare const NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC: NoopObservableBaseMetric;
//# sourceMappingURL=NoopMeter.d.ts.map

@@ -17,19 +17,4 @@ "use strict";

*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = exports.NOOP_OBSERVABLE_GAUGE_METRIC = exports.NOOP_OBSERVABLE_COUNTER_METRIC = exports.NOOP_UP_DOWN_COUNTER_METRIC = exports.NOOP_HISTOGRAM_METRIC = exports.NOOP_COUNTER_METRIC = exports.NOOP_METER = exports.NoopObservableBaseMetric = exports.NoopHistogramMetric = exports.NoopUpDownCounterMetric = exports.NoopCounterMetric = exports.NoopMetric = exports.NoopMeter = void 0;
exports.NOOP_UP_DOWN_COUNTER_METRIC = exports.NOOP_HISTOGRAM_METRIC = exports.NOOP_COUNTER_METRIC = exports.NOOP_METER = exports.NoopHistogramMetric = exports.NoopUpDownCounterMetric = exports.NoopCounterMetric = exports.NoopMetric = exports.NoopMeter = void 0;
/**

@@ -39,5 +24,4 @@ * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses

*/
var NoopMeter = /** @class */ (function () {
function NoopMeter() {
}
class NoopMeter {
constructor() { }
/**

@@ -48,5 +32,5 @@ * Returns a constant noop histogram.

*/
NoopMeter.prototype.createHistogram = function (_name, _options) {
createHistogram(_name, _options) {
return exports.NOOP_HISTOGRAM_METRIC;
};
}
/**

@@ -57,5 +41,5 @@ * Returns a constant noop counter.

*/
NoopMeter.prototype.createCounter = function (_name, _options) {
createCounter(_name, _options) {
return exports.NOOP_COUNTER_METRIC;
};
}
/**

@@ -66,82 +50,43 @@ * Returns a constant noop UpDownCounter.

*/
NoopMeter.prototype.createUpDownCounter = function (_name, _options) {
createUpDownCounter(_name, _options) {
return exports.NOOP_UP_DOWN_COUNTER_METRIC;
};
}
/**
* Returns a constant noop observable gauge.
* @param name the name of the metric.
* @param callback the observable gauge callback
* @param [options] the metric options.
* @param [callback] the observable gauge callback
*/
NoopMeter.prototype.createObservableGauge = function (_name, _options, _callback) {
return exports.NOOP_OBSERVABLE_GAUGE_METRIC;
};
createObservableGauge(_name, _callback, _options) { }
/**
* Returns a constant noop observable counter.
* @param name the name of the metric.
* @param callback the observable counter callback
* @param [options] the metric options.
* @param [callback] the observable counter callback
*/
NoopMeter.prototype.createObservableCounter = function (_name, _options, _callback) {
return exports.NOOP_OBSERVABLE_COUNTER_METRIC;
};
createObservableCounter(_name, _callback, _options) { }
/**
* Returns a constant noop up down observable counter.
* @param name the name of the metric.
* @param callback the up down observable counter callback
* @param [options] the metric options.
* @param [callback] the up down observable counter callback
*/
NoopMeter.prototype.createObservableUpDownCounter = function (_name, _options, _callback) {
return exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC;
};
return NoopMeter;
}());
createObservableUpDownCounter(_name, _callback, _options) { }
}
exports.NoopMeter = NoopMeter;
var NoopMetric = /** @class */ (function () {
function NoopMetric() {
}
return NoopMetric;
}());
class NoopMetric {
}
exports.NoopMetric = NoopMetric;
var NoopCounterMetric = /** @class */ (function (_super) {
__extends(NoopCounterMetric, _super);
function NoopCounterMetric() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoopCounterMetric.prototype.add = function (_value, _attributes) { };
return NoopCounterMetric;
}(NoopMetric));
class NoopCounterMetric extends NoopMetric {
add(_value, _attributes) { }
}
exports.NoopCounterMetric = NoopCounterMetric;
var NoopUpDownCounterMetric = /** @class */ (function (_super) {
__extends(NoopUpDownCounterMetric, _super);
function NoopUpDownCounterMetric() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoopUpDownCounterMetric.prototype.add = function (_value, _attributes) { };
return NoopUpDownCounterMetric;
}(NoopMetric));
class NoopUpDownCounterMetric extends NoopMetric {
add(_value, _attributes) { }
}
exports.NoopUpDownCounterMetric = NoopUpDownCounterMetric;
var NoopHistogramMetric = /** @class */ (function (_super) {
__extends(NoopHistogramMetric, _super);
function NoopHistogramMetric() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoopHistogramMetric.prototype.record = function (_value, _attributes) { };
return NoopHistogramMetric;
}(NoopMetric));
class NoopHistogramMetric extends NoopMetric {
record(_value, _attributes) { }
}
exports.NoopHistogramMetric = NoopHistogramMetric;
var NoopObservableBaseMetric = /** @class */ (function (_super) {
__extends(NoopObservableBaseMetric, _super);
function NoopObservableBaseMetric() {
return _super !== null && _super.apply(this, arguments) || this;
}
NoopObservableBaseMetric.prototype.observation = function () {
return {
observable: this,
value: 0,
};
};
return NoopObservableBaseMetric;
}(NoopMetric));
exports.NoopObservableBaseMetric = NoopObservableBaseMetric;
exports.NOOP_METER = new NoopMeter();

@@ -152,6 +97,2 @@ // Synchronous instruments

exports.NOOP_UP_DOWN_COUNTER_METRIC = new NoopUpDownCounterMetric();
// Asynchronous instruments
exports.NOOP_OBSERVABLE_COUNTER_METRIC = new NoopObservableBaseMetric();
exports.NOOP_OBSERVABLE_GAUGE_METRIC = new NoopObservableBaseMetric();
exports.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC = new NoopObservableBaseMetric();
//# sourceMappingURL=NoopMeter.js.map

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

exports.NOOP_METER_PROVIDER = exports.NoopMeterProvider = void 0;
var NoopMeter_1 = require("./NoopMeter");
const NoopMeter_1 = require("./NoopMeter");
/**

@@ -25,12 +25,9 @@ * An implementation of the {@link MeterProvider} which returns an impotent Meter

*/
var NoopMeterProvider = /** @class */ (function () {
function NoopMeterProvider() {
class NoopMeterProvider {
getMeter(_name, _version, _options) {
return NoopMeter_1.NOOP_METER;
}
NoopMeterProvider.prototype.getMeter = function (_name, _version, _options) {
return NoopMeter_1.NOOP_METER;
};
return NoopMeterProvider;
}());
}
exports.NoopMeterProvider = NoopMeterProvider;
exports.NOOP_METER_PROVIDER = new NoopMeterProvider();
//# sourceMappingURL=NoopMeterProvider.js.map

@@ -1,3 +0,3 @@

import { MetricOptions, Counter, Histogram, ObservableGauge, UpDownCounter, ObservableCounter, ObservableUpDownCounter } from './Metric';
import { ObservableResult } from './ObservableResult';
import { CounterOptions, HistogramOptions, UpDownCounterOptions } from '..';
import { Counter, Histogram, ObservableCallback, ObservableCounterOptions, ObservableGaugeOptions, ObservableUpDownCounterOptions, UpDownCounter } from './Metric';
/**

@@ -25,3 +25,3 @@ * An interface describes additional metadata of a meter.

*/
createHistogram(name: string, options?: MetricOptions): Histogram;
createHistogram(name: string, options?: HistogramOptions): Histogram;
/**

@@ -34,3 +34,3 @@ * Creates a new `Counter` metric. Generally, this kind of metric when the

*/
createCounter(name: string, options?: MetricOptions): Counter;
createCounter(name: string, options?: CounterOptions): Counter;
/**

@@ -53,25 +53,25 @@ * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous

*/
createUpDownCounter(name: string, options?: MetricOptions): UpDownCounter;
createUpDownCounter(name: string, options?: UpDownCounterOptions): UpDownCounter;
/**
* Creates a new `ObservableGauge` metric.
* @param name the name of the metric.
* @param callback the observable callback
* @param [options] the metric options.
* @param [callback] the observable callback
*/
createObservableGauge(name: string, options?: MetricOptions, callback?: (observableResult: ObservableResult) => void): ObservableGauge;
createObservableGauge(name: string, callback: ObservableCallback, options?: ObservableGaugeOptions): void;
/**
* Creates a new `ObservableCounter` metric.
* @param name the name of the metric.
* @param callback the observable callback
* @param [options] the metric options.
* @param [callback] the observable callback
*/
createObservableCounter(name: string, options?: MetricOptions, callback?: (observableResult: ObservableResult) => void): ObservableCounter;
createObservableCounter(name: string, callback: ObservableCallback, options?: ObservableCounterOptions): void;
/**
* Creates a new `ObservableUpDownCounter` metric.
* @param name the name of the metric.
* @param callback the observable callback
* @param [options] the metric options.
* @param [callback] the observable callback
*/
createObservableUpDownCounter(name: string, options?: MetricOptions, callback?: (observableResult: ObservableResult) => void): ObservableUpDownCounter;
createObservableUpDownCounter(name: string, callback: ObservableCallback, options?: ObservableUpDownCounterOptions): void;
}
//# sourceMappingURL=Meter.d.ts.map

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

import { Observation } from './Observation';
import { Context } from '@opentelemetry/api';
import { ObservableResult } from './ObservableResult';
/**

@@ -6,4 +7,2 @@ * Options needed for metric creation

export interface MetricOptions {
/** The name of the component that reports the Metric. */
component?: string;
/**

@@ -16,13 +15,6 @@ * The description of the Metric.

* The unit of the Metric values.
* @default '1'
* @default ''
*/
unit?: 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
* @default false
*/
disabled?: boolean;
/**
* Indicates the type of the recorded value.

@@ -32,11 +24,9 @@ * @default {@link ValueType.DOUBLE}

valueType?: ValueType;
/**
* Boundaries optional for histogram
*/
boundaries?: number[];
/**
* Aggregation Temporality of metric
*/
aggregationTemporality?: AggregationTemporality;
}
export declare type CounterOptions = MetricOptions;
export declare type UpDownCounterOptions = MetricOptions;
export declare type ObservableGaugeOptions = MetricOptions;
export declare type ObservableCounterOptions = MetricOptions;
export declare type ObservableUpDownCounterOptions = MetricOptions;
export declare type HistogramOptions = MetricOptions;
/** The Type of value. It describes how the data is reported. */

@@ -47,8 +37,2 @@ export declare enum ValueType {

}
/** The kind of aggregator. */
export declare enum AggregationTemporality {
AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,
AGGREGATION_TEMPORALITY_DELTA = 1,
AGGREGATION_TEMPORALITY_CUMULATIVE = 2
}
/**

@@ -73,3 +57,3 @@ * Counter is the most common synchronous instrument. This instrument supports

*/
add(value: number, attributes?: Attributes): void;
add(value: number, attributes?: MetricAttributes, context?: Context): void;
}

@@ -80,26 +64,20 @@ export interface UpDownCounter {

*/
add(value: number, attributes?: Attributes): void;
add(value: number, attributes?: MetricAttributes, context?: Context): void;
}
export interface Histogram {
/**
* Records the given value to this histogram.
* Records a measurement. Value of the measurement must not be negative.
*/
record(value: number, attributes?: Attributes): void;
record(value: number, attributes?: MetricAttributes, context?: Context): void;
}
/** Base interface for the Observable metrics. */
export interface ObservableBase {
observation: (value: number, attributes?: Attributes) => Observation;
}
/** Base interface for the ObservableGauge metrics. */
export declare type ObservableGauge = ObservableBase;
/** Base interface for the ObservableUpDownCounter metrics. */
export declare type ObservableUpDownCounter = ObservableBase;
/** Base interface for the ObservableCounter metrics. */
export declare type ObservableCounter = ObservableBase;
/**
* key-value pairs passed by the user.
*/
export declare type Attributes = {
export declare type MetricAttributes = {
[key: string]: string;
};
/**
* The observable callback for Observable instruments.
*/
export declare type ObservableCallback = (observableResult: ObservableResult) => void | Promise<void>;
//# sourceMappingURL=Metric.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregationTemporality = exports.ValueType = void 0;
exports.ValueType = void 0;
/** The Type of value. It describes how the data is reported. */

@@ -26,9 +26,2 @@ var ValueType;

})(ValueType = exports.ValueType || (exports.ValueType = {}));
/** The kind of aggregator. */
var AggregationTemporality;
(function (AggregationTemporality) {
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_UNSPECIFIED"] = 0] = "AGGREGATION_TEMPORALITY_UNSPECIFIED";
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_DELTA"] = 1] = "AGGREGATION_TEMPORALITY_DELTA";
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_CUMULATIVE"] = 2] = "AGGREGATION_TEMPORALITY_CUMULATIVE";
})(AggregationTemporality = exports.AggregationTemporality || (exports.AggregationTemporality = {}));
//# sourceMappingURL=Metric.js.map

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

import { Attributes } from './Metric';
import { MetricAttributes } from './Metric';
/**

@@ -6,4 +6,12 @@ * Interface that is being used in callback function for Observable Metric

export interface ObservableResult {
observe(value: number, attributes: Attributes): void;
/**
* Observe a measurement of the value associated with the given attributes.
*
* @param value The value to be observed.
* @param attributes The attributes associated with the value. If more than
* one values associated with the same attributes values, SDK may pick the
* last one or simply drop the entire observable result.
*/
observe(value: number, attributes?: MetricAttributes): void;
}
//# sourceMappingURL=ObservableResult.d.ts.map

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

export declare const VERSION = "0.27.0";
export declare const VERSION = "0.28.0";
//# sourceMappingURL=version.d.ts.map

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

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.27.0';
exports.VERSION = '0.28.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/api-metrics",
"version": "0.27.0",
"version": "0.28.0",
"description": "Public metrics API for OpenTelemetry",
"main": "build/src/index.js",
"module": "build/esm/index.js",
"esnext": "build/esnext/index.js",
"types": "build/src/index.d.ts",

@@ -11,2 +12,3 @@ "browser": {

"./build/esm/platform/index.js": "./build/esm/platform/browser/index.js",
"./build/esnext/platform/index.js": "./build/esnext/platform/browser/index.js",
"./build/src/platform/index.js": "./build/src/platform/browser/index.js"

@@ -16,8 +18,9 @@ },

"scripts": {
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.all.json",
"clean": "tsc --build --clean tsconfig.all.json",
"test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",
"test:browser": "nyc karma start --single-run",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
"codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
"build": "npm run compile",

@@ -27,4 +30,4 @@ "lint": "eslint . --ext .ts",

"version": "node ../../../scripts/version-update.js",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json",
"precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies",
"watch": "tsc --build --watch tsconfig.all.json",
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
"prewatch": "node ../../../scripts/version-update.js"

@@ -44,3 +47,3 @@ },

"engines": {
"node": ">=8.0.0"
"node": ">=8.12.0"
},

@@ -51,2 +54,5 @@ "files": [

"build/esm/**/*.d.ts",
"build/esnext/**/*.js",
"build/esnext/**/*.js.map",
"build/esnext/**/*.d.ts",
"build/src/**/*.js",

@@ -62,9 +68,12 @@ "build/src/**/*.js.map",

},
"dependencies": {
"@opentelemetry/api": "^1.0.0"
},
"devDependencies": {
"@types/mocha": "8.2.3",
"@types/node": "14.17.11",
"@types/webpack-env": "1.16.2",
"@types/node": "14.17.33",
"@types/webpack-env": "1.16.3",
"codecov": "3.8.3",
"istanbul-instrumenter-loader": "3.0.1",
"karma": "6.3.7",
"karma": "6.3.16",
"karma-chrome-launcher": "3.1.0",

@@ -79,6 +88,6 @@ "karma-coverage-istanbul-reporter": "3.0.3",

"ts-mocha": "8.0.0",
"typescript": "4.3.5",
"typescript": "4.4.4",
"webpack": "4.46.0"
},
"gitHead": "f5e227f0cb829df1ca2dc220a3e0e8ae0e607405"
"gitHead": "28a177ffe3950c5602a91391af582a7a8c813c7d"
}
# OpenTelemetry API for JavaScript
[![NPM Published Version][npm-img]][npm-url]
[![dependencies][dependencies-image]][dependencies-url]
[![devDependencies][devDependencies-image]][devDependencies-url]
[![Apache License][license-image]][license-image]

@@ -93,19 +91,7 @@

[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-api-metrics
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-api-metrics
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=packages%2Fopentelemetry-api-metrics&type=dev
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-api-metrics&type=dev
[npm-url]: https://www.npmjs.com/package/@opentelemetry/api-metrics
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi-metrics.svg
[trace-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/traceapi.html
[metrics-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/metricsapi.html
[propagation-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/propagationapi.html
[context-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/contextapi.html
[metrics-api-docs]: https://open-telemetry.github.io/opentelemetry-js/modules/_opentelemetry_api_metrics.html
[web]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-web
[tracing]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-base
[node]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node
[metrics]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-metrics-base
[other-tracing-backends]: https://github.com/open-telemetry/opentelemetry-js#trace-exporters

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc