-
Notifications
You must be signed in to change notification settings - Fork 4
/
provider.js
48 lines (40 loc) · 1.3 KB
/
provider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) 2018, Joyent, Inc.
*/
/*
* provider.js: DTrace probe definitions.
*/
var mod_dtrace_provider = require('dtrace-provider');
var PROBES = {
/* counter, gauge, and histogram operations */
/* [metric_name, value, labels] */
'counter-add': ['char *', 'int', 'json'],
'gauge-add': ['char *', 'int', 'json'],
'gauge-set': ['char *', 'int', 'json'],
'histogram-observe': ['char *', 'int', 'json'],
/* metric-vector operations */
/* [metric_name, labels] */
'create-metric': ['char *', 'json'],
/* metric operations */
/* [value, labels] */
'metric-add': ['int', 'json'],
'metric-set': ['int', 'json'],
'metric-reset': ['int', 'json']
};
var PROVIDER;
module.exports = function exportStaticProvider() {
if (!PROVIDER) {
PROVIDER = mod_dtrace_provider.createDTraceProvider('artedi');
Object.keys(PROBES).forEach(function (p) {
var args = PROBES[p].splice(0);
args.unshift(p);
PROVIDER.addProbe.apply(PROVIDER, args);
});
PROVIDER.enable();
}
return (PROVIDER);
}();