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

spm-metrics-js

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spm-metrics-js - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

15

lib/customMetric.js

@@ -54,2 +54,3 @@ var Measured = require('measured')

var values = {}
var filteredValues = {}
if (this.stats && this.stats.toJSON) {

@@ -63,3 +64,3 @@ m = this.stats.toJSON ()

values = extend(values, m.histogram)
//values = extend(values, m.meter)
// values = extend(values, m.meter)
} else {

@@ -69,10 +70,10 @@ values = m

for (var key in values) {
if (this.options.valueFilter instanceof Array) {
if (this.options.valueFilter && this.options.valueFilter instanceof Array) {
if (this.options.valueFilter.indexOf(key) >= 0) {
this.set(values[key], key)
} else {
this.set(values[key], key)
}
filteredValues[key] = values[key]
}
} else {
this.set(values[key], key)
filteredValues[key] = values[key]
}

@@ -82,2 +83,3 @@ }

values = m
filteredValues = values
this.set (values)

@@ -88,3 +90,4 @@ }

}
return values
// make code testable
return filteredValues
}

@@ -91,0 +94,0 @@

2

package.json
{
"name": "spm-metrics-js",
"version": "1.0.10",
"version": "1.0.11",
"description": "Node.js client for SPM - Custom Metrics and Event API",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -172,3 +172,3 @@ spm-metrics-js

## Create Events to correlatee with your metrics in SPM
## Create Events to correlate events with metrics in SPM

@@ -175,0 +175,0 @@ Add an event to SPM Events, the callback function is optional (see events of spm-metrics-js)

@@ -57,2 +57,3 @@ var SPM = require('../lib/index.js')

})
spmcm.once('send error', done)
var testMetric = spmcm.getCustomMetric({ name: 'timer', aggregation: 'avg', filter1: 'filter1', filter2: 'filter2' })

@@ -92,2 +93,30 @@ var stopwatch = testMetric.timer().start()

})
it('meter check valueFilter', function (done) {
this.timeout(30000)
try {
var spmcm = new SPM(token, 0)
var value = {}
spmcm.once('send metrics', function (event) {
if (value.count > 0) {
done()
}
})
var testMetric = spmcm.getCustomMetric({ name: 'meter', aggregation: 'avg', filter1: 'filter1', filter2: 'filter2',
valueFilter: ['count'] })
testMetric.meter()
for (var i = 0; i < Math.round(Math.random()*100+1); i++) {
testMetric.mark()
}
value = testMetric.save()
// test for "removed" property
if(value.hasOwnProperty('currentRate')) {
return done(new Error('valueFilter not working'))
}
spmcm.send()
spmcm.once('send error', done)
spmcm.once('send', done)
} catch (err) {
done(err)
}
})
it('counter', function (done) {

@@ -94,0 +123,0 @@ this.timeout(30000)

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