mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-12 23:54:45 +08:00
Moved cloud-metrics into cloud-core
This commit is contained in:
parent
e772e11196
commit
25cca505b7
2 changed files with 0 additions and 62 deletions
|
@ -1,51 +0,0 @@
|
|||
/* eslint global-require:0 */
|
||||
const {env: {NODE_ENV, SIGNALFX_TOKEN}, pid} = process
|
||||
const os = require('os')
|
||||
const signalfx = require('signalfx')
|
||||
|
||||
let signalfxClient = null
|
||||
|
||||
const MetricTypes = {
|
||||
Gauge: 'gauges',
|
||||
Counter: 'counters',
|
||||
CumulativeCounter: 'cumulative_counters',
|
||||
}
|
||||
const shouldReport = NODE_ENV && NODE_ENV !== 'development'
|
||||
|
||||
|
||||
const Metrics = {
|
||||
|
||||
MetricTypes,
|
||||
|
||||
startCapturing(name) {
|
||||
if (!shouldReport) { return }
|
||||
signalfxClient = new signalfx.Ingest(SIGNALFX_TOKEN, {
|
||||
dimensions: {
|
||||
name,
|
||||
host: os.hostname(),
|
||||
pid: pid.toString(),
|
||||
env: NODE_ENV,
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
reportError(error) {
|
||||
},
|
||||
|
||||
reportMetric({name, value, type, dimensions = {}} = {}) {
|
||||
if (!signalfxClient || !shouldReport) { return }
|
||||
if (!name) {
|
||||
throw new Error('Metrics.reportMetric requires a metric.name')
|
||||
}
|
||||
if (value == null) {
|
||||
throw new Error('Metrics.reportMetric requires a metric.value')
|
||||
}
|
||||
if (!type) {
|
||||
throw new Error('Metrics.reportMetric requires a metric.type from Metrics.MetricTypes')
|
||||
}
|
||||
const metric = {metric: name, value, timestamp: Date.now(), dimensions}
|
||||
signalfxClient.send({[type]: [metric]})
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = Metrics
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"name": "cloud-metrics",
|
||||
"version": "0.0.1",
|
||||
"description": "Metrics package",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"signalfx": "3.0.1"
|
||||
},
|
||||
"author": "Nylas",
|
||||
"license": "ISC"
|
||||
}
|
Loading…
Add table
Reference in a new issue