@opentelemetry/exporter-prometheus
Advanced tools
Comparing version 0.11.1-alpha.48 to 0.11.1-alpha.53
@@ -26,6 +26,6 @@ import * as api from '@opentelemetry/api'; | ||
/** | ||
* Define if the Prometheus exporter server will be started | ||
* Prevent the Prometheus exporter server from starting | ||
* @default false | ||
*/ | ||
startServer?: boolean; | ||
preventServerStart?: boolean; | ||
/** Standard logging interface */ | ||
@@ -32,0 +32,0 @@ logger?: api.Logger; |
@@ -7,3 +7,2 @@ import { ExportResult } from '@opentelemetry/core'; | ||
port: number; | ||
startServer: boolean; | ||
endpoint: string; | ||
@@ -41,17 +40,12 @@ prefix: string; | ||
* Shuts down the export server and clears the registry | ||
* | ||
* @param cb called when server is stopped | ||
*/ | ||
shutdown(cb?: () => void): void; | ||
shutdown(): Promise<void>; | ||
/** | ||
* Stops the Prometheus export server | ||
* @param callback A callback that will be executed once the server is stopped | ||
*/ | ||
stopServer(callback?: () => void): void; | ||
stopServer(): Promise<void>; | ||
/** | ||
* Starts the Prometheus export server | ||
* | ||
* @param callback called once the server is ready | ||
*/ | ||
startServer(callback?: () => void): void; | ||
startServer(): Promise<void>; | ||
/** | ||
@@ -58,0 +52,0 @@ * Request handler used by http library to respond to incoming requests |
@@ -75,4 +75,4 @@ "use strict"; | ||
this._endpoint = (config.endpoint || PrometheusExporter.DEFAULT_OPTIONS.endpoint).replace(/^([^/])/, '/$1'); | ||
if (config.startServer || PrometheusExporter.DEFAULT_OPTIONS.startServer) { | ||
this.startServer(callback); | ||
if (config.preventServerStart !== true) { | ||
this.startServer().then(callback); | ||
} | ||
@@ -111,25 +111,28 @@ else if (callback) { | ||
* Shuts down the export server and clears the registry | ||
* | ||
* @param cb called when server is stopped | ||
*/ | ||
shutdown(cb) { | ||
this.stopServer(cb); | ||
shutdown() { | ||
return this.stopServer(); | ||
} | ||
/** | ||
* Stops the Prometheus export server | ||
* @param callback A callback that will be executed once the server is stopped | ||
*/ | ||
stopServer(callback) { | ||
stopServer() { | ||
if (!this._server) { | ||
this._logger.debug('Prometheus stopServer() was called but server was never started.'); | ||
if (callback) { | ||
callback(); | ||
} | ||
return Promise.resolve(); | ||
} | ||
else { | ||
this._server.close(() => { | ||
this._logger.debug('Prometheus exporter was stopped'); | ||
if (callback) { | ||
callback(); | ||
} | ||
return new Promise(resolve => { | ||
this._server.close(err => { | ||
if (!err) { | ||
this._logger.debug('Prometheus exporter was stopped'); | ||
} | ||
else { | ||
if (err.code !== | ||
'ERR_SERVER_NOT_RUNNING') { | ||
core_1.globalErrorHandler(err); | ||
} | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
@@ -140,11 +143,9 @@ } | ||
* Starts the Prometheus export server | ||
* | ||
* @param callback called once the server is ready | ||
*/ | ||
startServer(callback) { | ||
this._server.listen(this._port, () => { | ||
this._logger.debug(`Prometheus exporter started on port ${this._port} at endpoint ${this._endpoint}`); | ||
if (callback) { | ||
callback(); | ||
} | ||
startServer() { | ||
return new Promise(resolve => { | ||
this._server.listen(this._port, () => { | ||
this._logger.debug(`Prometheus exporter started on port ${this._port} at endpoint ${this._endpoint}`); | ||
resolve(); | ||
}); | ||
}); | ||
@@ -156,3 +157,2 @@ } | ||
port: 9464, | ||
startServer: false, | ||
endpoint: '/metrics', | ||
@@ -159,0 +159,0 @@ prefix: '', |
@@ -79,4 +79,2 @@ "use strict"; | ||
return 'gauge'; | ||
case metrics_1.AggregatorKind.DISTRIBUTION: | ||
return 'summary'; | ||
case metrics_1.AggregatorKind.HISTOGRAM: | ||
@@ -142,16 +140,2 @@ return 'histogram'; | ||
} | ||
case metrics_1.AggregatorKind.DISTRIBUTION: { | ||
const { value, timestamp: hrtime } = record.aggregator.toPoint(); | ||
const timestamp = core_1.hrTimeToMilliseconds(hrtime); | ||
for (const key of ['count', 'sum']) { | ||
results += stringify(name + '_' + key, record.labels, value[key], this._appendTimestamp ? timestamp : undefined, undefined); | ||
} | ||
results += stringify(name, record.labels, value.min, this._appendTimestamp ? timestamp : undefined, { | ||
quantile: '0', | ||
}); | ||
results += stringify(name, record.labels, value.max, this._appendTimestamp ? timestamp : undefined, { | ||
quantile: '1', | ||
}); | ||
break; | ||
} | ||
case metrics_1.AggregatorKind.HISTOGRAM: { | ||
@@ -164,5 +148,7 @@ const { value, timestamp: hrtime } = record.aggregator.toPoint(); | ||
} | ||
let cumulativeSum = 0; | ||
for (const [idx, val] of value.buckets.counts.entries()) { | ||
cumulativeSum += val; | ||
const upperBound = value.buckets.boundaries[idx]; | ||
results += stringify(name + '_bucket', record.labels, val, this._appendTimestamp ? timestamp : undefined, { | ||
results += stringify(name + '_bucket', record.labels, cumulativeSum, this._appendTimestamp ? timestamp : undefined, { | ||
le: upperBound === undefined ? '+Inf' : String(upperBound), | ||
@@ -169,0 +155,0 @@ }); |
@@ -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/exporter-prometheus", | ||
"version": "0.11.1-alpha.48+15174c6", | ||
"version": "0.11.1-alpha.53+00a8ce7f", | ||
"description": "OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus", | ||
@@ -52,11 +52,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/metrics": "^0.11.1-alpha.48+15174c6" | ||
"@opentelemetry/api": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/core": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/metrics": "^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
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
2
48208
561