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

@promster/metrics

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@promster/metrics - npm Package Compare versions

Comparing version 10.0.0 to 11.0.0

dist/promster-metrics.cjs.d.ts.map

5

dist/declarations/src/client/client.d.ts
import * as Prometheus from 'prom-client';
declare const defaultRegister: Prometheus.Registry;
declare const configure: any;
interface TClientOptions extends Prometheus.DefaultMetricsCollectorConfiguration {
detectKubernetes?: boolean;
}
declare const configure: (options: TClientOptions) => void;
export { Prometheus, defaultRegister, configure };

2

dist/declarations/src/client/index.d.ts

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

import { Prometheus, defaultRegister, configure } from './client';
import { Prometheus, defaultRegister, configure } from "./client.js";
export { Prometheus, defaultRegister, configure };

@@ -1,4 +0,4 @@

import type { TGcMetrics } from '@promster/types';
import { type TDefaultedPromsterOptions, type TGcMetrics } from '@promster/types';
declare const createGcMetrics: {
(options: DeepRequired<import("@promster/types").TPromsterOptions>): TGcMetrics;
(options: TDefaultedPromsterOptions): TGcMetrics;
defaultOptions: {

@@ -5,0 +5,0 @@ getLabelValues: () => {};

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

import { createGcMetrics } from './create-gc-metrics';
import { createGcMetrics } from "./create-gc-metrics.js";
export { createGcMetrics };

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

declare const createGcObserver: any;
import { type TOptionalPromsterOptions, type TGcMetrics } from '@promster/types';
declare const createGcObserver: (metrics: TGcMetrics, options: TOptionalPromsterOptions) => () => void;
export { createGcObserver };

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

import { createGcObserver } from './create-gc-observer';
import { createGcObserver } from "./create-gc-observer.js";
export { createGcObserver };

@@ -1,4 +0,4 @@

import type { TGraphQlMetrics } from '@promster/types';
import { type TDefaultedPromsterOptions, type TGraphQlMetrics } from '@promster/types';
declare const createGraphQlMetrics: {
(options: DeepRequired<import("@promster/types").TPromsterOptions>): TGraphQlMetrics;
(options: TDefaultedPromsterOptions): TGraphQlMetrics;
defaultOptions: {

@@ -16,4 +16,11 @@ getLabelValues: () => {};

};
metricPercentiles: {
graphQlParseDuration: number[];
graphQlValidationDuration: number[];
graphQlResolveFieldDuration: number[];
graphQlRequestDuration: number[];
graphQlErrorsTotal: number[];
};
};
};
export { createGraphQlMetrics };

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

import { createGraphQlMetrics } from './create-graphql-metrics';
import { createGraphQlMetrics } from "./create-graphql-metrics.js";
export { createGraphQlMetrics };

@@ -1,4 +0,4 @@

import type { THttpMetrics } from '@promster/types';
import { type TDefaultedPromsterOptions, type THttpMetrics } from '@promster/types';
declare const createHttpMetrics: {
(options: DeepRequired<import("@promster/types").TPromsterOptions>): THttpMetrics;
(options: TDefaultedPromsterOptions): THttpMetrics;
defaultOptions: {

@@ -16,4 +16,12 @@ getLabelValues: () => {};

};
metricBuckets: {
httpRequestContentLengthInBytes: number[];
httpRequestDurationInSeconds: number[];
};
metricPercentiles: {
httpRequestDurationPerPercentileInSeconds: number[];
httpResponseContentLengthInBytes: number[];
};
};
};
export { createHttpMetrics };

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

import { createHttpMetrics } from './create-http-metrics';
import { createHttpMetrics } from "./create-http-metrics.js";
export { createHttpMetrics };

@@ -1,5 +0,5 @@

import type { TPromsterOptions, TLabelValues, THttpMetrics } from '@promster/types';
import type { Timing } from '../timing';
import { sortLabels } from '../sort-labels';
import { endMeasurementFrom } from '../end-measurement-from';
import { type TOptionalPromsterOptions, type TLabelValues, type THttpMetrics } from '@promster/types';
import { type Timing } from "../timing/index.js";
import { sortLabels } from "../sort-labels/index.js";
import { endMeasurementFrom } from "../end-measurement-from/index.js";
type TRecordingOptions = {

@@ -11,7 +11,7 @@ labels: TLabelValues;

type TLegacyTiming = [number, number];
export type TRequestRecorder = (timing: Timing | TLegacyTiming, recordingOptions: TRecordingOptions) => void;
export type TRequestRecorder = (_timing: Timing | TLegacyTiming, _recordingOptions: TRecordingOptions) => void;
declare const createRequestRecorder: {
(metrics: THttpMetrics, options?: TPromsterOptions): TRequestRecorder;
defaultOptions: TPromsterOptions;
(metrics: THttpMetrics, options?: TOptionalPromsterOptions): TRequestRecorder;
defaultOptions: TOptionalPromsterOptions;
};
export { createRequestRecorder, sortLabels, endMeasurementFrom };

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

import { createRequestRecorder } from './create-request-recorder';
export type { TRequestRecorder } from './create-request-recorder';
import { createRequestRecorder } from "./create-request-recorder.js";
export type { TRequestRecorder } from "./create-request-recorder.js";
export { createRequestRecorder };

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

import { endMeasurementFrom } from './end-measurement-from';
import { endMeasurementFrom } from "./end-measurement-from.js";
export { endMeasurementFrom };

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

import { isRunningInKubernetes } from './kubernetes';
import { skipMetricsInEnvironment } from './skip-metrics-in-environment';
import { isRunningInKubernetes } from "./kubernetes.js";
import { skipMetricsInEnvironment } from "./skip-metrics-in-environment.js";
export { isRunningInKubernetes, skipMetricsInEnvironment };

@@ -1,6 +0,6 @@

import type { TPromsterOptions } from '@promster/types';
import { type TOptionalPromsterOptions } from '@promster/types';
type TSkipMetricsInEnvironmentOptions = {
detectKubernetes?: TPromsterOptions['detectKubernetes'];
detectKubernetes?: TOptionalPromsterOptions['detectKubernetes'];
};
declare const skipMetricsInEnvironment: (options: TSkipMetricsInEnvironmentOptions) => boolean;
export { skipMetricsInEnvironment };

@@ -1,15 +0,16 @@

import { Prometheus, defaultRegister } from './client';
import { createHttpMetrics } from './create-http-metrics';
import { createGraphQlMetrics } from './create-graphql-metrics';
import { createGcMetrics } from './create-gc-metrics';
import { getSummary, getContentType } from './summary';
import { createRequestRecorder } from './create-request-recorder';
import { createGcObserver } from './create-gc-observer';
import { defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod } from './normalizers';
import { isRunningInKubernetes, skipMetricsInEnvironment } from './environment';
import { endMeasurementFrom } from './end-measurement-from';
import { sortLabels } from './sort-labels';
import { timing } from './timing';
export type { TRequestRecorder } from './create-request-recorder';
export type { Timing as TPromsterTiming } from './timing';
import { Prometheus, defaultRegister } from "./client/index.js";
import { createHttpMetrics } from "./create-http-metrics/index.js";
import { createGraphQlMetrics } from "./create-graphql-metrics/index.js";
import { createGcMetrics } from "./create-gc-metrics/index.js";
import { getSummary, getContentType } from "./summary/index.js";
import { createRequestRecorder } from "./create-request-recorder/index.js";
import { createGcObserver } from "./create-gc-observer/index.js";
import { defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod } from "./normalizers/index.js";
import { isRunningInKubernetes, skipMetricsInEnvironment } from "./environment/index.js";
import { endMeasurementFrom } from "./end-measurement-from/index.js";
import { sortLabels } from "./sort-labels/index.js";
import { timing } from "./timing/index.js";
export type { TRequestRecorder } from "./create-request-recorder/index.js";
export type { Timing as TPromsterTiming } from "./timing/index.js";
export { Prometheus, defaultRegister, createHttpMetrics, createGraphQlMetrics, createGcMetrics, getSummary, getContentType, createRequestRecorder, createGcObserver, defaultNormalizers, normalizeStatusCode, normalizePath, normalizeMethod, isRunningInKubernetes, skipMetricsInEnvironment, endMeasurementFrom, sortLabels, timing, };
export * from '@promster/types';

@@ -1,4 +0,4 @@

import { normalizeStatusCode } from './status-code';
import { normalizePath } from './path';
import { normalizeMethod } from './method';
import { normalizeStatusCode } from "./status-code/index.js";
import { normalizePath } from "./path/index.js";
import { normalizeMethod } from "./method/index.js";
declare const defaultNormalizers: {

@@ -5,0 +5,0 @@ normalizeStatusCode: (statusCode: number) => number;

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

import { normalizeMethod } from './method';
import { normalizeMethod } from "./method.js";
export { normalizeMethod };

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

import { normalizePath } from './path';
import { normalizePath } from "./path.js";
export { normalizePath };

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

import { normalizeStatusCode } from './status-code';
import { normalizeStatusCode } from "./status-code.js";
export { normalizeStatusCode };

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

import { sortLabels } from './sort-labels';
import { sortLabels } from "./sort-labels.js";
export { sortLabels };

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

import type { TLabelValues } from '@promster/types';
import { type TLabelValues } from '@promster/types';
declare function sortLabels(unsortedLabels: TLabelValues): TLabelValues;
export { sortLabels };

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

import { getSummary, getContentType } from './summary';
import { getSummary, getContentType } from "./summary.js";
export { getSummary, getContentType };

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

import timing, { Timing } from './timing';
import timing, { Timing } from "./timing.js";
export { timing, Timing };
export * from "./declarations/src/index";
//# sourceMappingURL=promster-metrics.cjs.d.ts.map

@@ -11,2 +11,3 @@ 'use strict';

var UrlValueParser = require('url-value-parser');
var types = require('@promster/types');

@@ -78,31 +79,51 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }

httpResponseContentLengthInBytes: ['http_response_content_length_bytes']
},
metricBuckets: {
httpRequestContentLengthInBytes: defaultHttpContentLengthInBytes,
httpRequestDurationInSeconds: defaultHttpRequestDurationInSeconds
},
metricPercentiles: {
httpRequestDurationPerPercentileInSeconds: defaultHttpRequestDurationPercentileInSeconds,
httpResponseContentLengthInBytes: defaultHttpContentLengthInBytes
}
};
const getMetrics$2 = options => ({
httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP request content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: options.buckets || defaultHttpContentLengthInBytes
})) : undefined,
httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP response content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: options.buckets || defaultHttpContentLengthInBytes
})) : undefined
httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => {
var _options$metricBucket;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP request content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: ((_options$metricBucket = options.metricBuckets) === null || _options$metricBucket === void 0 ? void 0 : _options$metricBucket.httpRequestContentLengthInBytes) || defaultHttpContentLengthInBytes
});
}) : undefined,
httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => {
var _options$metricBucket2;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP response content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: ((_options$metricBucket2 = options.metricBuckets) === null || _options$metricBucket2 === void 0 ? void 0 : _options$metricBucket2.httpResponseContentLengthInBytes) || defaultHttpContentLengthInBytes
});
}) : undefined
});
const getHttpRequestLatencyMetricsInSeconds = options => ({
httpRequestDurationPerPercentileInSeconds: shouldObserveHttpRequestsAsSummary(options) ? asArray$2(options.metricNames.httpRequestDurationPerPercentileInSeconds).map(nameOfHttpRequestDurationPerPercentileInSeconds => new Prometheus__namespace.Summary({
name: `${options.metricPrefix}${nameOfHttpRequestDurationPerPercentileInSeconds}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
percentiles: options.percentiles || defaultHttpRequestDurationPercentileInSeconds
})) : undefined,
httpRequestDurationInSeconds: shouldObserveHttpRequestsAsHistogram(options) ? asArray$2(options.metricNames.httpRequestDurationInSeconds).map(nameOfHttpRequestDurationInSecondsMetric => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpRequestDurationInSecondsMetric}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: options.buckets || defaultHttpRequestDurationInSeconds
})) : undefined
httpRequestDurationPerPercentileInSeconds: shouldObserveHttpRequestsAsSummary(options) ? asArray$2(options.metricNames.httpRequestDurationPerPercentileInSeconds).map(nameOfHttpRequestDurationPerPercentileInSeconds => {
var _options$metricPercen;
return new Prometheus__namespace.Summary({
name: `${options.metricPrefix}${nameOfHttpRequestDurationPerPercentileInSeconds}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
percentiles: ((_options$metricPercen = options.metricPercentiles) === null || _options$metricPercen === void 0 ? void 0 : _options$metricPercen.httpRequestDurationPerPercentileInSeconds) || defaultHttpRequestDurationPercentileInSeconds
});
}) : undefined,
httpRequestDurationInSeconds: shouldObserveHttpRequestsAsHistogram(options) ? asArray$2(options.metricNames.httpRequestDurationInSeconds).map(nameOfHttpRequestDurationInSecondsMetric => {
var _options$metricBucket3;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpRequestDurationInSecondsMetric}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: ((_options$metricBucket3 = options.metricBuckets) === null || _options$metricBucket3 === void 0 ? void 0 : _options$metricBucket3.httpRequestDurationInSeconds) || defaultHttpRequestDurationInSeconds
});
}) : undefined
});

@@ -147,29 +168,48 @@ const getHttpRequestCounterMetric = options => ({

graphQlErrorsTotal: ['graphql_errors_total']
},
metricPercentiles: {
graphQlParseDuration: defaultGraphQlPercentiles,
graphQlValidationDuration: defaultGraphQlPercentiles,
graphQlResolveFieldDuration: defaultGraphQlPercentiles,
graphQlRequestDuration: defaultGraphQlPercentiles,
graphQlErrorsTotal: defaultGraphQlPercentiles
}
};
const getMetrics$1 = options => ({
graphQlParseDuration: shouldObserveGraphQlParseDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlParseDuration).map(nameOfGraphQlParseDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlParseDuration}`,
help: 'The GraphQL request parse time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlValidationDuration: shouldObserveGraphQlValidationDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlValidationDuration).map(nameOfGraphQlValidationDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlValidationDuration}`,
help: 'The GraphQL request validation time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlResolveFieldDuration: shouldObserveGraphQlResolveFieldDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlResolveFieldDuration).map(nameOfGraphQlResolveFieldDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlResolveFieldDuration}`,
help: 'The GraphQL field resolving time in seconds.',
labelNames: defaultLabels$1.concat(['field_name']).concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlRequestDuration: shouldObserveGraphQlRequestDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlRequestDuration).map(nameOfGraphQlRequestDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlRequestDuration}`,
help: 'The GraphQL request duration time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlParseDuration: shouldObserveGraphQlParseDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlParseDuration).map(nameOfGraphQlParseDuration => {
var _options$metricPercen;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlParseDuration}`,
help: 'The GraphQL request parse time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: ((_options$metricPercen = options.metricPercentiles) === null || _options$metricPercen === void 0 ? void 0 : _options$metricPercen.graphQlParseDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlValidationDuration: shouldObserveGraphQlValidationDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlValidationDuration).map(nameOfGraphQlValidationDuration => {
var _options$metricPercen2;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlValidationDuration}`,
help: 'The GraphQL request validation time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: ((_options$metricPercen2 = options.metricPercentiles) === null || _options$metricPercen2 === void 0 ? void 0 : _options$metricPercen2.graphQlValidationDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlResolveFieldDuration: shouldObserveGraphQlResolveFieldDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlResolveFieldDuration).map(nameOfGraphQlResolveFieldDuration => {
var _options$metricPercen3;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlResolveFieldDuration}`,
help: 'The GraphQL field resolving time in seconds.',
labelNames: defaultLabels$1.concat(['field_name']).concat(options.labels).sort(),
buckets: ((_options$metricPercen3 = options.metricPercentiles) === null || _options$metricPercen3 === void 0 ? void 0 : _options$metricPercen3.graphQlResolveFieldDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlRequestDuration: shouldObserveGraphQlRequestDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlRequestDuration).map(nameOfGraphQlRequestDuration => {
var _options$metricPercen4;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlRequestDuration}`,
help: 'The GraphQL request duration time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: ((_options$metricPercen4 = options.metricPercentiles) === null || _options$metricPercen4 === void 0 ? void 0 : _options$metricPercen4.graphQlRequestDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlErrorsTotal: shouldObserveGraphQlErrorsTotalAsCounter(options) ? asArray$1(options.metricNames.graphQlErrorsTotal).map(nameOfGraphQlErrorsCount => new Prometheus__namespace.Counter({

@@ -262,3 +302,2 @@ name: `${options.metricPrefix}${nameOfGraphQlErrorsCount}`,

const defaultOptions$1 = {
skip: () => false,
detectKubernetes: false

@@ -332,2 +371,3 @@ };

gc().on('stats', stats => {
// @ts-expect-error
const gcType = gcTypes[stats.gctype];

@@ -347,2 +387,4 @@ metrics.countOfGcs.forEach(countOfGcMetricType => {

});
// @ts-expect-error
createGcObserver.defaultOptions = defaultOptions;

@@ -353,3 +395,7 @@

const urlValueParser = new UrlValueParser__default["default"]();
const normalizePath = path => urlValueParser.replacePathValues(url__default["default"].parse(path).pathname, '#val');
const normalizePath = path => {
const parsedPathname = url__default["default"].parse(path).pathname;
if (!parsedPathname) return '';
return urlValueParser.replacePathValues(parsedPathname, '#val');
};

@@ -415,1 +461,7 @@ const normalizeMethod = method => method.toLowerCase();

exports.timing = timing;
Object.keys(types).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () { return types[k]; }
});
});

@@ -11,2 +11,3 @@ 'use strict';

var UrlValueParser = require('url-value-parser');
var types = require('@promster/types');

@@ -78,31 +79,51 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }

httpResponseContentLengthInBytes: ['http_response_content_length_bytes']
},
metricBuckets: {
httpRequestContentLengthInBytes: defaultHttpContentLengthInBytes,
httpRequestDurationInSeconds: defaultHttpRequestDurationInSeconds
},
metricPercentiles: {
httpRequestDurationPerPercentileInSeconds: defaultHttpRequestDurationPercentileInSeconds,
httpResponseContentLengthInBytes: defaultHttpContentLengthInBytes
}
};
const getMetrics$2 = options => ({
httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP request content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: options.buckets || defaultHttpContentLengthInBytes
})) : undefined,
httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP response content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: options.buckets || defaultHttpContentLengthInBytes
})) : undefined
httpRequestContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpRequestContentLengthInBytes).map(nameOfHttpContentLengthMetric => {
var _options$metricBucket;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP request content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: ((_options$metricBucket = options.metricBuckets) === null || _options$metricBucket === void 0 ? void 0 : _options$metricBucket.httpRequestContentLengthInBytes) || defaultHttpContentLengthInBytes
});
}) : undefined,
httpResponseContentLengthInBytes: shouldObserveHttpContentLengthAsHistogram(options) ? asArray$2(options.metricNames.httpResponseContentLengthInBytes).map(nameOfHttpContentLengthMetric => {
var _options$metricBucket2;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpContentLengthMetric}`,
help: 'The HTTP response content length in bytes.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: ((_options$metricBucket2 = options.metricBuckets) === null || _options$metricBucket2 === void 0 ? void 0 : _options$metricBucket2.httpResponseContentLengthInBytes) || defaultHttpContentLengthInBytes
});
}) : undefined
});
const getHttpRequestLatencyMetricsInSeconds = options => ({
httpRequestDurationPerPercentileInSeconds: shouldObserveHttpRequestsAsSummary(options) ? asArray$2(options.metricNames.httpRequestDurationPerPercentileInSeconds).map(nameOfHttpRequestDurationPerPercentileInSeconds => new Prometheus__namespace.Summary({
name: `${options.metricPrefix}${nameOfHttpRequestDurationPerPercentileInSeconds}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
percentiles: options.percentiles || defaultHttpRequestDurationPercentileInSeconds
})) : undefined,
httpRequestDurationInSeconds: shouldObserveHttpRequestsAsHistogram(options) ? asArray$2(options.metricNames.httpRequestDurationInSeconds).map(nameOfHttpRequestDurationInSecondsMetric => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpRequestDurationInSecondsMetric}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: options.buckets || defaultHttpRequestDurationInSeconds
})) : undefined
httpRequestDurationPerPercentileInSeconds: shouldObserveHttpRequestsAsSummary(options) ? asArray$2(options.metricNames.httpRequestDurationPerPercentileInSeconds).map(nameOfHttpRequestDurationPerPercentileInSeconds => {
var _options$metricPercen;
return new Prometheus__namespace.Summary({
name: `${options.metricPrefix}${nameOfHttpRequestDurationPerPercentileInSeconds}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
percentiles: ((_options$metricPercen = options.metricPercentiles) === null || _options$metricPercen === void 0 ? void 0 : _options$metricPercen.httpRequestDurationPerPercentileInSeconds) || defaultHttpRequestDurationPercentileInSeconds
});
}) : undefined,
httpRequestDurationInSeconds: shouldObserveHttpRequestsAsHistogram(options) ? asArray$2(options.metricNames.httpRequestDurationInSeconds).map(nameOfHttpRequestDurationInSecondsMetric => {
var _options$metricBucket3;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfHttpRequestDurationInSecondsMetric}`,
help: 'The HTTP request latencies in seconds.',
labelNames: defaultLabels$2.concat(options.labels).sort(),
buckets: ((_options$metricBucket3 = options.metricBuckets) === null || _options$metricBucket3 === void 0 ? void 0 : _options$metricBucket3.httpRequestDurationInSeconds) || defaultHttpRequestDurationInSeconds
});
}) : undefined
});

@@ -147,29 +168,48 @@ const getHttpRequestCounterMetric = options => ({

graphQlErrorsTotal: ['graphql_errors_total']
},
metricPercentiles: {
graphQlParseDuration: defaultGraphQlPercentiles,
graphQlValidationDuration: defaultGraphQlPercentiles,
graphQlResolveFieldDuration: defaultGraphQlPercentiles,
graphQlRequestDuration: defaultGraphQlPercentiles,
graphQlErrorsTotal: defaultGraphQlPercentiles
}
};
const getMetrics$1 = options => ({
graphQlParseDuration: shouldObserveGraphQlParseDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlParseDuration).map(nameOfGraphQlParseDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlParseDuration}`,
help: 'The GraphQL request parse time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlValidationDuration: shouldObserveGraphQlValidationDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlValidationDuration).map(nameOfGraphQlValidationDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlValidationDuration}`,
help: 'The GraphQL request validation time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlResolveFieldDuration: shouldObserveGraphQlResolveFieldDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlResolveFieldDuration).map(nameOfGraphQlResolveFieldDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlResolveFieldDuration}`,
help: 'The GraphQL field resolving time in seconds.',
labelNames: defaultLabels$1.concat(['field_name']).concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlRequestDuration: shouldObserveGraphQlRequestDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlRequestDuration).map(nameOfGraphQlRequestDuration => new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlRequestDuration}`,
help: 'The GraphQL request duration time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: options.buckets || defaultGraphQlPercentiles
})) : undefined,
graphQlParseDuration: shouldObserveGraphQlParseDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlParseDuration).map(nameOfGraphQlParseDuration => {
var _options$metricPercen;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlParseDuration}`,
help: 'The GraphQL request parse time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: ((_options$metricPercen = options.metricPercentiles) === null || _options$metricPercen === void 0 ? void 0 : _options$metricPercen.graphQlParseDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlValidationDuration: shouldObserveGraphQlValidationDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlValidationDuration).map(nameOfGraphQlValidationDuration => {
var _options$metricPercen2;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlValidationDuration}`,
help: 'The GraphQL request validation time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: ((_options$metricPercen2 = options.metricPercentiles) === null || _options$metricPercen2 === void 0 ? void 0 : _options$metricPercen2.graphQlValidationDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlResolveFieldDuration: shouldObserveGraphQlResolveFieldDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlResolveFieldDuration).map(nameOfGraphQlResolveFieldDuration => {
var _options$metricPercen3;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlResolveFieldDuration}`,
help: 'The GraphQL field resolving time in seconds.',
labelNames: defaultLabels$1.concat(['field_name']).concat(options.labels).sort(),
buckets: ((_options$metricPercen3 = options.metricPercentiles) === null || _options$metricPercen3 === void 0 ? void 0 : _options$metricPercen3.graphQlResolveFieldDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlRequestDuration: shouldObserveGraphQlRequestDurationAsHistogram(options) ? asArray$1(options.metricNames.graphQlRequestDuration).map(nameOfGraphQlRequestDuration => {
var _options$metricPercen4;
return new Prometheus__namespace.Histogram({
name: `${options.metricPrefix}${nameOfGraphQlRequestDuration}`,
help: 'The GraphQL request duration time in seconds.',
labelNames: defaultLabels$1.concat(options.labels).sort(),
buckets: ((_options$metricPercen4 = options.metricPercentiles) === null || _options$metricPercen4 === void 0 ? void 0 : _options$metricPercen4.graphQlRequestDuration) || defaultGraphQlPercentiles
});
}) : undefined,
graphQlErrorsTotal: shouldObserveGraphQlErrorsTotalAsCounter(options) ? asArray$1(options.metricNames.graphQlErrorsTotal).map(nameOfGraphQlErrorsCount => new Prometheus__namespace.Counter({

@@ -262,3 +302,2 @@ name: `${options.metricPrefix}${nameOfGraphQlErrorsCount}`,

const defaultOptions$1 = {
skip: () => false,
detectKubernetes: false

@@ -332,2 +371,3 @@ };

gc().on('stats', stats => {
// @ts-expect-error
const gcType = gcTypes[stats.gctype];

@@ -347,2 +387,4 @@ metrics.countOfGcs.forEach(countOfGcMetricType => {

});
// @ts-expect-error
createGcObserver.defaultOptions = defaultOptions;

@@ -353,3 +395,7 @@

const urlValueParser = new UrlValueParser__default["default"]();
const normalizePath = path => urlValueParser.replacePathValues(url__default["default"].parse(path).pathname, '#val');
const normalizePath = path => {
const parsedPathname = url__default["default"].parse(path).pathname;
if (!parsedPathname) return '';
return urlValueParser.replacePathValues(parsedPathname, '#val');
};

@@ -415,1 +461,7 @@ const normalizeMethod = method => method.toLowerCase();

exports.timing = timing;
Object.keys(types).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () { return types[k]; }
});
});
{
"name": "@promster/metrics",
"version": "10.0.0",
"version": "11.0.0",
"description": "Metrics utilities used by all other server integrations",

@@ -39,2 +39,3 @@ "main": "dist/promster-metrics.cjs.js",

"dependencies": {
"@promster/types": "^5.0.0",
"lodash.memoize": "4.1.2",

@@ -44,11 +45,10 @@ "lodash.once": "4.1.1",

"optional": "0.1.4",
"ts-essentials": "9.3.2",
"tslib": "2.4.1",
"tslib": "2.6.2",
"url-value-parser": "2.2.0"
},
"devDependencies": {
"@promster/types": "^4.0.0",
"@types/lodash": "4.14.197",
"prom-client": "14.2.0",
"typescript": "4.9.5"
"typescript": "5.2.2",
"@types/node": "18.17.12",
"@types/lodash.once": "4.1.7"
},

@@ -55,0 +55,0 @@ "optionalDependencies": {

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