New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/metrics

Package Overview
Dependencies
Maintainers
5
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.3.1 to 0.3.2

build/src/BoundInstrument.d.ts

2

build/src/index.d.ts

@@ -16,3 +16,3 @@ /*!

*/
export * from './Handle';
export * from './BoundInstrument';
export * from './Meter';

@@ -19,0 +19,0 @@ export * from './Metric';

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

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Handle"));
__export(require("./BoundInstrument"));
__export(require("./Meter"));

@@ -24,0 +24,0 @@ __export(require("./Metric"));

@@ -36,3 +36,3 @@ /*!

*/
createMeasure(name: string, options?: types.MetricOptions): types.Metric<types.MeasureHandle>;
createMeasure(name: string, options?: types.MetricOptions): types.Metric<types.BoundMeasure>;
/**

@@ -45,3 +45,3 @@ * Creates a new counter metric. Generally, this kind of metric when the

*/
createCounter(name: string, options?: types.MetricOptions): types.Metric<types.CounterHandle>;
createCounter(name: string, options?: types.MetricOptions): types.Metric<types.BoundCounter>;
/**

@@ -55,3 +55,3 @@ * Creates a new gauge metric. Generally, this kind of metric should be used

*/
createGauge(name: string, options?: types.MetricOptions): types.Metric<types.GaugeHandle>;
createGauge(name: string, options?: types.MetricOptions): types.Metric<types.BoundGauge>;
/**

@@ -58,0 +58,0 @@ * Gets a collection of Metrics to be exported.

@@ -17,7 +17,7 @@ /*!

import * as types from '@opentelemetry/types';
import { CounterHandle, GaugeHandle, BaseHandle } from './Handle';
import { BoundCounter, BoundGauge, BaseBoundInstrument } from './BoundInstrument';
import { MetricOptions } from './types';
import { ReadableMetric, MetricDescriptorType } from './export/types';
/** This is a SDK implementation of {@link Metric} interface. */
export declare abstract class Metric<T extends BaseHandle> implements types.Metric<T> {
export declare abstract class Metric<T extends BaseBoundInstrument> implements types.Metric<T> {
private readonly _name;

@@ -31,22 +31,22 @@ private readonly _options;

private readonly _metricDescriptor;
private readonly _handles;
private readonly _instruments;
constructor(_name: string, _options: MetricOptions, _type: MetricDescriptorType);
/**
* Returns a Handle associated with specified LabelSet.
* It is recommended to keep a reference to the Handle instead of always
* Returns an Instrument associated with specified LabelSet.
* It is recommended to keep a reference to the Instrument instead of always
* calling this method for each operation.
* @param labelSet the canonicalized LabelSet used to associate with this metric handle.
* @param labelSet the canonicalized LabelSet used to associate with this metric instrument.
*/
getHandle(labelSet: types.LabelSet): T;
bind(labelSet: types.LabelSet): T;
/**
* Returns a Handle for a metric with all labels not set.
* Returns a Instrument for a metric with all labels not set.
*/
getDefaultHandle(): T;
getDefaultBound(): T;
/**
* Removes the Handle from the metric, if it is present.
* @param labelSet the canonicalized LabelSet used to associate with this metric handle.
* Removes the Instrument from the metric, if it is present.
* @param labelSet the canonicalized LabelSet used to associate with this metric instrument.
*/
removeHandle(labelSet: types.LabelSet): void;
unbind(labelSet: types.LabelSet): void;
/**
* Clears all Handles from the Metric.
* Clears all Instruments from the Metric.
*/

@@ -62,13 +62,13 @@ clear(): void;

private _getMetricDescriptor;
protected abstract _makeHandle(labelSet: types.LabelSet): T;
protected abstract _makeInstrument(labelSet: types.LabelSet): T;
}
/** This is a SDK implementation of Counter Metric. */
export declare class CounterMetric extends Metric<CounterHandle> implements Pick<types.MetricUtils, 'add'> {
export declare class CounterMetric extends Metric<BoundCounter> implements Pick<types.MetricUtils, 'add'> {
private readonly _onUpdate;
constructor(name: string, options: MetricOptions, _onUpdate: Function);
protected _makeHandle(labelSet: types.LabelSet): CounterHandle;
protected _makeInstrument(labelSet: types.LabelSet): BoundCounter;
/**
* Adds the given value to the current value. Values cannot be negative.
* @param value the value to add.
* @param labelSet the canonicalized LabelSet used to associate with this metric's handle.
* @param labelSet the canonicalized LabelSet used to associate with this metric's instrument.
*/

@@ -78,12 +78,12 @@ add(value: number, labelSet: types.LabelSet): void;

/** This is a SDK implementation of Gauge Metric. */
export declare class GaugeMetric extends Metric<GaugeHandle> implements Pick<types.MetricUtils, 'set'> {
export declare class GaugeMetric extends Metric<BoundGauge> implements Pick<types.MetricUtils, 'set'> {
private readonly _onUpdate;
constructor(name: string, options: MetricOptions, _onUpdate: Function);
protected _makeHandle(labelSet: types.LabelSet): GaugeHandle;
protected _makeInstrument(labelSet: types.LabelSet): BoundGauge;
/**
* Sets the given value. Values can be negative.
* @param value the new value.
* @param labelSet the canonicalized LabelSet used to associate with this metric's handle.
* @param labelSet the canonicalized LabelSet used to associate with this metric's instrument.
*/
set(value: number, labelSet: types.LabelSet): void;
}

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

const core_1 = require("@opentelemetry/core");
const Handle_1 = require("./Handle");
const BoundInstrument_1 = require("./BoundInstrument");
const types_1 = require("./export/types");

@@ -29,3 +29,3 @@ /** This is a SDK implementation of {@link Metric} interface. */

this._type = _type;
this._handles = new Map();
this._instruments = new Map();
this._monotonic = _options.monotonic;

@@ -38,18 +38,18 @@ this._disabled = _options.disabled;

/**
* Returns a Handle associated with specified LabelSet.
* It is recommended to keep a reference to the Handle instead of always
* Returns an Instrument associated with specified LabelSet.
* It is recommended to keep a reference to the Instrument instead of always
* calling this method for each operation.
* @param labelSet the canonicalized LabelSet used to associate with this metric handle.
* @param labelSet the canonicalized LabelSet used to associate with this metric instrument.
*/
getHandle(labelSet) {
if (this._handles.has(labelSet.identifier))
return this._handles.get(labelSet.identifier);
const handle = this._makeHandle(labelSet);
this._handles.set(labelSet.identifier, handle);
return handle;
bind(labelSet) {
if (this._instruments.has(labelSet.identifier))
return this._instruments.get(labelSet.identifier);
const instrument = this._makeInstrument(labelSet);
this._instruments.set(labelSet.identifier, instrument);
return instrument;
}
/**
* Returns a Handle for a metric with all labels not set.
* Returns a Instrument for a metric with all labels not set.
*/
getDefaultHandle() {
getDefaultBound() {
// @todo: implement this method

@@ -60,13 +60,13 @@ this._logger.error('not implemented yet');

/**
* Removes the Handle from the metric, if it is present.
* @param labelSet the canonicalized LabelSet used to associate with this metric handle.
* Removes the Instrument from the metric, if it is present.
* @param labelSet the canonicalized LabelSet used to associate with this metric instrument.
*/
removeHandle(labelSet) {
this._handles.delete(labelSet.identifier);
unbind(labelSet) {
this._instruments.delete(labelSet.identifier);
}
/**
* Clears all Handles from the Metric.
* Clears all Instruments from the Metric.
*/
clear() {
this._handles.clear();
this._instruments.clear();
}

@@ -84,3 +84,3 @@ setCallback(fn) {

get() {
if (this._handles.size === 0)
if (this._instruments.size === 0)
return null;

@@ -90,3 +90,3 @@ const timestamp = core_1.hrTime();

descriptor: this._metricDescriptor,
timeseries: Array.from(this._handles, ([_, handle]) => handle.getTimeSeries(timestamp)),
timeseries: Array.from(this._instruments, ([_, instrument]) => instrument.getTimeSeries(timestamp)),
};

@@ -114,4 +114,4 @@ }

}
_makeHandle(labelSet) {
return new Handle_1.CounterHandle(labelSet, this._disabled, this._monotonic, this._valueType, this._logger, this._onUpdate);
_makeInstrument(labelSet) {
return new BoundInstrument_1.BoundCounter(labelSet, this._disabled, this._monotonic, this._valueType, this._logger, this._onUpdate);
}

@@ -121,6 +121,6 @@ /**

* @param value the value to add.
* @param labelSet the canonicalized LabelSet used to associate with this metric's handle.
* @param labelSet the canonicalized LabelSet used to associate with this metric's instrument.
*/
add(value, labelSet) {
this.getHandle(labelSet).add(value);
this.bind(labelSet).add(value);
}

@@ -137,4 +137,4 @@ }

}
_makeHandle(labelSet) {
return new Handle_1.GaugeHandle(labelSet, this._disabled, this._monotonic, this._valueType, this._logger, this._onUpdate);
_makeInstrument(labelSet) {
return new BoundInstrument_1.BoundGauge(labelSet, this._disabled, this._monotonic, this._valueType, this._logger, this._onUpdate);
}

@@ -144,6 +144,6 @@ /**

* @param value the new value.
* @param labelSet the canonicalized LabelSet used to associate with this metric's handle.
* @param labelSet the canonicalized LabelSet used to associate with this metric's instrument.
*/
set(value, labelSet) {
this.getHandle(labelSet).set(value);
this.bind(labelSet).set(value);
}

@@ -150,0 +150,0 @@ }

{
"name": "@opentelemetry/metrics",
"version": "0.3.1",
"version": "0.3.2",
"description": "OpenTelemetry metrics SDK",

@@ -15,3 +15,4 @@ "main": "build/src/index.js",

"precompile": "tsc --version",
"compile": "tsc -p .",
"version:update": "node ../../scripts/version-update.js",
"compile": "npm run version:update && tsc -p .",
"fix": "gts fix",

@@ -59,6 +60,6 @@ "prepare": "npm run compile"

"dependencies": {
"@opentelemetry/base": "^0.3.1",
"@opentelemetry/core": "^0.3.1",
"@opentelemetry/types": "^0.3.1"
"@opentelemetry/base": "^0.3.2",
"@opentelemetry/core": "^0.3.2",
"@opentelemetry/types": "^0.3.2"
}
}

@@ -34,5 +34,5 @@ # OpenTelemetry Metrics SDK

// Create a Handle associated with specified label values.
const handle = counter.getHandle(labels);
handle.add(10);
// Create a BoundInstrument associated with specified label values.
const boundCounter = counter.bind(labels);
boundCounter.add(10);
```

@@ -56,5 +56,5 @@

// Create a Handle associated with specified label values.
const handle = gauge.getHandle(labels);
handle.set(10); // Set to 10
// Create a BoundInstrument associated with specified label values.
const boundGauge = gauge.bind(labels);
boundGauge.set(10); // Set to 10
```

@@ -61,0 +61,0 @@

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