prom-client
Advanced tools
Comparing version 15.1.1 to 15.1.2
@@ -84,3 +84,3 @@ // Type definitions for prom-client | ||
*/ | ||
contentType: RegistryContentType; | ||
readonly contentType: RegistryContentType; | ||
@@ -99,2 +99,12 @@ /** | ||
static merge(registers: Registry[]): Registry; | ||
/** | ||
* HTTP Prometheus Content-Type for metrics response headers. | ||
*/ | ||
static PROMETHEUS_CONTENT_TYPE: PrometheusContentType; | ||
/** | ||
* HTTP OpenMetrics Content-Type for metrics response headers. | ||
*/ | ||
static OPENMETRICS_CONTENT_TYPE: OpenMetricsContentType; | ||
} | ||
@@ -109,4 +119,4 @@ export type Collector = () => void; | ||
/** | ||
* HTTP Content-Type for metrics response headers, defaults to Prometheus text | ||
* format. | ||
* HTTP Content-Type for metrics response headers for the default registry, | ||
* defaults to Prometheus text format. | ||
*/ | ||
@@ -113,0 +123,0 @@ export const contentType: RegistryContentType; |
17
index.js
@@ -10,7 +10,14 @@ /** | ||
exports.Registry = require('./lib/registry'); | ||
exports.contentType = require('./lib/registry').globalRegistry.contentType; | ||
exports.prometheusContentType = | ||
require('./lib/registry').PROMETHEUS_CONTENT_TYPE; | ||
exports.openMetricsContentType = | ||
require('./lib/registry').OPENMETRICS_CONTENT_TYPE; | ||
Object.defineProperty(exports, 'contentType', { | ||
configurable: false, | ||
enumerable: true, | ||
get() { | ||
return exports.register.contentType; | ||
}, | ||
set(value) { | ||
exports.register.setContentType(value); | ||
}, | ||
}); | ||
exports.prometheusContentType = exports.Registry.PROMETHEUS_CONTENT_TYPE; | ||
exports.openMetricsContentType = exports.Registry.OPENMETRICS_CONTENT_TYPE; | ||
exports.validateMetricName = require('./lib/validation').validateMetricName; | ||
@@ -17,0 +24,0 @@ |
@@ -40,28 +40,35 @@ 'use strict'; | ||
let collect; | ||
if (!perf_hooks || !perf_hooks.monitorEventLoopDelay) { | ||
collect = () => { | ||
const start = process.hrtime(); | ||
setImmediate(reportEventloopLag, start, lag, labels); | ||
}; | ||
} else { | ||
const histogram = perf_hooks.monitorEventLoopDelay({ | ||
resolution: config.eventLoopMonitoringPrecision, | ||
}); | ||
histogram.enable(); | ||
let collect = () => { | ||
const start = process.hrtime(); | ||
setImmediate(reportEventloopLag, start, lag, labels); | ||
}; | ||
collect = () => { | ||
const start = process.hrtime(); | ||
setImmediate(reportEventloopLag, start, lag, labels); | ||
if (perf_hooks && perf_hooks.monitorEventLoopDelay) { | ||
try { | ||
const histogram = perf_hooks.monitorEventLoopDelay({ | ||
resolution: config.eventLoopMonitoringPrecision, | ||
}); | ||
histogram.enable(); | ||
lagMin.set(labels, histogram.min / 1e9); | ||
lagMax.set(labels, histogram.max / 1e9); | ||
lagMean.set(labels, histogram.mean / 1e9); | ||
lagStddev.set(labels, histogram.stddev / 1e9); | ||
lagP50.set(labels, histogram.percentile(50) / 1e9); | ||
lagP90.set(labels, histogram.percentile(90) / 1e9); | ||
lagP99.set(labels, histogram.percentile(99) / 1e9); | ||
collect = () => { | ||
const start = process.hrtime(); | ||
setImmediate(reportEventloopLag, start, lag, labels); | ||
histogram.reset(); | ||
}; | ||
lagMin.set(labels, histogram.min / 1e9); | ||
lagMax.set(labels, histogram.max / 1e9); | ||
lagMean.set(labels, histogram.mean / 1e9); | ||
lagStddev.set(labels, histogram.stddev / 1e9); | ||
lagP50.set(labels, histogram.percentile(50) / 1e9); | ||
lagP90.set(labels, histogram.percentile(90) / 1e9); | ||
lagP99.set(labels, histogram.percentile(99) / 1e9); | ||
histogram.reset(); | ||
}; | ||
} catch (e) { | ||
if (e.code === 'ERR_NOT_IMPLEMENTED') { | ||
return; // Bun | ||
} | ||
throw e; | ||
} | ||
} | ||
@@ -68,0 +75,0 @@ |
@@ -14,2 +14,10 @@ 'use strict'; | ||
module.exports = (registry, config = {}) => { | ||
try { | ||
v8.getHeapSpaceStatistics(); | ||
} catch (e) { | ||
if (e.code === 'ERR_NOT_IMPLEMENTED') { | ||
return; // Bun | ||
} | ||
throw e; | ||
} | ||
const registers = registry ? [registry] : undefined; | ||
@@ -16,0 +24,0 @@ const namePrefix = config.prefix ? config.prefix : ''; |
{ | ||
"name": "prom-client", | ||
"version": "15.1.1", | ||
"version": "15.1.2", | ||
"description": "Client for prometheus", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126236
3167