Comparing version 2.5.2 to 2.6.0
@@ -6,3 +6,3 @@ /* | ||
* | ||
* Copyright (c) 2017, Joyent, Inc. | ||
* Copyright (c) 2018, Joyent, Inc. | ||
*/ | ||
@@ -43,2 +43,4 @@ | ||
this.collector = mod_utils.createErrorMetrics(options); | ||
EventEmitter.call(this); | ||
@@ -143,3 +145,4 @@ | ||
log: this.log, | ||
recovery: this.cba_recovery | ||
recovery: this.cba_recovery, | ||
collector: this.collector | ||
}; | ||
@@ -497,2 +500,6 @@ function constructSocket(backend) { | ||
CueBallAgent.prototype.isStopped = function () { | ||
return (this.cba_stopped); | ||
}; | ||
function CueBallHttpAgent(options) { | ||
@@ -499,0 +506,0 @@ options.protocol = 'http'; |
@@ -6,3 +6,3 @@ /* | ||
* | ||
* Copyright 2017 Joyent, Inc. | ||
* Copyright 2018 Joyent, Inc. | ||
*/ | ||
@@ -159,2 +159,4 @@ | ||
this.p_collector = mod_utils.createErrorMetrics(options); | ||
mod_assert.number(options.spares, 'options.spares'); | ||
@@ -224,6 +226,13 @@ mod_assert.number(options.maximum, 'options.maximum'); | ||
mod_assert.optionalFinite(options.decoherenceInterval, | ||
'options.decoherenceInterval'); | ||
var shuffleIntvl = options.decoherenceInterval; | ||
if (shuffleIntvl === undefined || shuffleIntvl === null || | ||
shuffleIntvl < 60) { | ||
shuffleIntvl = 60; | ||
} | ||
this.p_shuffleTimer = new EventEmitter(); | ||
this.p_shuffleTimerInst = setInterval(function () { | ||
self.p_shuffleTimer.emit('timeout'); | ||
}, 60000); | ||
}, shuffleIntvl * 1000); | ||
this.p_shuffleTimerInst.unref(); | ||
@@ -252,2 +261,3 @@ | ||
CueBallConnectionPool.prototype._incrCounter = function (counter) { | ||
mod_utils.updateErrorMetrics(this.p_collector, this.p_uuid, counter); | ||
if (this.p_counters[counter] === undefined) | ||
@@ -254,0 +264,0 @@ this.p_counters[counter] = 0; |
@@ -6,3 +6,3 @@ /* | ||
* | ||
* Copyright 2017 Joyent, Inc. | ||
* Copyright 2018 Joyent, Inc. | ||
*/ | ||
@@ -65,2 +65,4 @@ | ||
this.cs_collector = mod_utils.createErrorMetrics(options); | ||
mod_assert.number(options.target, 'options.target'); | ||
@@ -612,2 +614,3 @@ mod_assert.number(options.maximum, 'options.maximum'); | ||
CueBallConnectionSet.prototype._incrCounter = function (counter) { | ||
mod_utils.updateErrorMetrics(this.cs_collector, this.cs_uuid, counter); | ||
if (this.cs_counters[counter] === undefined) | ||
@@ -614,0 +617,0 @@ this.cs_counters[counter] = 0; |
@@ -6,3 +6,3 @@ /* | ||
* | ||
* Copyright (c) 2016, Joyent, Inc. | ||
* Copyright (c) 2018, Joyent, Inc. | ||
*/ | ||
@@ -18,11 +18,33 @@ | ||
stackTracesEnabled: stackTracesEnabled, | ||
maybeCaptureStackTrace: maybeCaptureStackTrace | ||
maybeCaptureStackTrace: maybeCaptureStackTrace, | ||
createErrorMetrics: createErrorMetrics, | ||
updateErrorMetrics: updateErrorMetrics | ||
}; | ||
const mod_assert = require('assert-plus'); | ||
const mod_artedi = require('artedi'); | ||
const mod_os = require('os'); | ||
stackTracesEnabled.ENABLED = false; | ||
var mod_dtrace, dtProvider, dtProbe; | ||
var METRIC_CUEBALL_EVENT_COUNTER = 'cueball_events'; | ||
/* | ||
* This table is intended to contain a list of cueball error-related events that | ||
* we intend to track. Currently, it is consumed by `updateErrorMetrics()' and | ||
* if the error string supplied by the caller is not part of this table, it | ||
* will not be tracked. | ||
*/ | ||
var array_metrics_err = [ | ||
'timeout-during-connect', | ||
'error-during-connect', | ||
'close-during-connect', | ||
'timeout-during-connect', | ||
'error-while-connected', | ||
'retries-exhausted', | ||
'claim-timeout', | ||
'error-while-claimed', | ||
'failed-state']; | ||
/* | ||
* Returns true if cueball should collect stack traces at every claim() and | ||
@@ -367,1 +389,52 @@ * release() from a Pool. | ||
} | ||
function createErrorMetrics(options) | ||
{ | ||
var collector; | ||
mod_assert.optionalObject(options.collector, 'options.collector'); | ||
if (options.collector === undefined || options.collector === null) { | ||
collector = mod_artedi.createCollector({ | ||
labels: {component: 'cueball'} | ||
}); | ||
} else { | ||
collector = options.collector; | ||
} | ||
/* | ||
* This is idempotent, so if we're performing this on a collector that | ||
* already has this counter (like one created in the cueball agent | ||
* and then passed to a set or pool), there's no harm done. | ||
*/ | ||
collector.counter({ | ||
name: METRIC_CUEBALL_EVENT_COUNTER, | ||
help: 'Total number of cueball error events' | ||
}); | ||
return (collector); | ||
} | ||
function updateErrorMetrics(collector, uuid, errStr) | ||
{ | ||
var errors; | ||
mod_assert.object(collector, 'collector'); | ||
mod_assert.uuid(uuid, 'uuid'); | ||
mod_assert.string(errStr, 'errStr'); | ||
/* | ||
* If the error string supplied by the caller is not part of | ||
* `array_metrics_err', then we aren't tracking it -- at least not as | ||
* an error. | ||
*/ | ||
if (array_metrics_err.indexOf(errStr) < 0) | ||
return; | ||
errors = collector.getCollector(METRIC_CUEBALL_EVENT_COUNTER); | ||
errors.increment({ | ||
hostname: mod_os.hostname(), | ||
uuid: uuid, | ||
type: 'error', | ||
evt: errStr | ||
}); | ||
} |
{ | ||
"name": "cueball", | ||
"version": "2.5.2", | ||
"version": "2.6.0", | ||
"description": "manage a pool of connections to a multi-node service where nodes are listed in DNS", | ||
"main": "lib/index.js", | ||
"dependencies": { | ||
"artedi": "1.3.0", | ||
"assert-plus": ">=1.0.0 <2.0.0", | ||
@@ -8,0 +9,0 @@ "bunyan": ">=1.5.1 <2.0.0", |
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
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
192650
5220
8
13
+ Addedartedi@1.3.0
+ Addedartedi@1.3.0(transitive)
+ Addeddtrace-provider@0.8.6(transitive)
+ Addedextsprintf@1.0.2(transitive)
+ Addedjson-schema@0.2.3(transitive)
+ Addedjsprim@1.4.0(transitive)
+ Addedverror@1.3.6(transitive)