Comparing version 2.1.0 to 2.2.0
@@ -5,2 +5,16 @@ # Changelog | ||
## [2.2.0](https://github.com/nodeshift/opossum/compare/v2.1.0...v2.2.0) (2019-06-24) | ||
### Bug Fixes | ||
* ensure that including dist/opossum.js works ([#341](https://github.com/nodeshift/opossum/issues/341)) ([873deb5](https://github.com/nodeshift/opossum/commit/873deb5)), closes [/github.com/lance/elizabethan-insults/commit/ebabdf359c54090cfde31a06ad09576eeba82488#diff-23fce1009af5652674e09470cda3c008R9](https://github.com/nodeshift/opossum/issues/diff-23fce1009af5652674e09470cda3c008R9) | ||
### Features | ||
* add prometheusRegistry option ([#332](https://github.com/nodeshift/opossum/issues/332)) ([0056cdc](https://github.com/nodeshift/opossum/commit/0056cdc)) | ||
## [2.1.0](https://github.com/nodeshift/opossum/compare/v2.0.0...v2.1.0) (2019-06-12) | ||
@@ -7,0 +21,0 @@ |
@@ -189,3 +189,6 @@ 'use strict'; | ||
if (PrometheusMetrics && options.usePrometheus) { | ||
this[PROMETHEUS_METRICS] = new PrometheusMetrics(this); | ||
this[PROMETHEUS_METRICS] = new PrometheusMetrics( | ||
this, | ||
options.prometheusRegistry | ||
); | ||
} | ||
@@ -192,0 +195,0 @@ } |
@@ -17,4 +17,5 @@ 'use strict'; | ||
class PrometheusMetrics { | ||
constructor (circuit) { | ||
constructor (circuit, registry) { | ||
this.circuit = circuit; | ||
this._registry = registry || client.register | ||
this._client = client; | ||
@@ -24,4 +25,6 @@ this.counters = []; | ||
this.interval = this._client | ||
.collectDefaultMetrics({ prefix, timeout: 5000 }); | ||
if (!registry) { | ||
this.interval = this._client | ||
.collectDefaultMetrics({ prefix, timeout: 5000 }); | ||
} | ||
@@ -31,3 +34,4 @@ for (let eventName of this.circuit.eventNames()) { | ||
name: `${prefix}${eventName}`, | ||
help: `A count of the ${circuit.name} circuit's ${eventName} event` | ||
help: `A count of the ${circuit.name} circuit's ${eventName} event`, | ||
registers: [this._registry] | ||
}); | ||
@@ -43,7 +47,7 @@ this.circuit.on(eventName, _ => { | ||
clearInterval(this.interval); | ||
this._client.register.clear(); | ||
this._registry.clear(); | ||
} | ||
get metrics () { | ||
return this._client.register.metrics(); | ||
return this._registry.metrics(); | ||
} | ||
@@ -50,0 +54,0 @@ |
{ | ||
"name": "opossum", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"author": "Red Hat, Inc.", | ||
@@ -13,5 +13,4 @@ "license": "Apache-2.0", | ||
"prebuild": "npm run lint", | ||
"build": "npm run build:browser && npm run build:node && npm run build:docs", | ||
"build:node": "webpack --config=config/webpack.config.js", | ||
"build:browser": "webpack --config=config/webpack.browser.config.js", | ||
"build": "./test/browser/generate-index.sh && npm run build:browser && npm run build:docs", | ||
"build:browser": "webpack --config=config/webpack.config.js", | ||
"build:docs": "npm run build:docs:html && npm run build:docs:markdown", | ||
@@ -59,3 +58,3 @@ "build:docs:html": "documentation build index.js -f html -o docs --config documentation.yml", | ||
"tape": "~4.10.1", | ||
"webpack": "~4.33.0", | ||
"webpack": "~4.35.0", | ||
"webpack-cli": "~3.3.0" | ||
@@ -62,0 +61,0 @@ }, |
@@ -262,2 +262,23 @@ # opossum [![CircleCI](https://circleci.com/gh/nodeshift/opossum/tree/master.svg?style=svg&circle-token=0742302baa8c95cef354997ea52a383d3d078ff1)](https://circleci.com/gh/nodeshift/opossum/tree/master) | ||
The `prometheusRegistry` option allows to provide a existing | ||
[prom-client](https://github.com/siimon/prom-client) registry. | ||
The metrics about the circuit will be added to the provided registry instead | ||
of the global registry. | ||
The [default metrics](https://github.com/siimon/prom-client#default-metrics) | ||
will not be added to the provided registry. | ||
```js | ||
const opossum = require('opossum'); | ||
const { Registry } = require('prom-client'); | ||
// Create a registry | ||
const prometheusRegistry = new Registry(); | ||
// create a circuit | ||
const circuit = opossum(functionThatMightFail, { | ||
usePrometheus: true, | ||
prometheusRegistry | ||
}); | ||
``` | ||
#### Hystrix | ||
@@ -264,0 +285,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a 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
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1434804
0
314
1
1
18
9195