@forge/util 1.0.1 → 1.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/package.json +3 -3
- package/packages/analytics-node-client/src/index.js +2 -16
- package/packages/metrics-interface/CHANGELOG.md +120 -0
- package/packages/metrics-interface/README.md +62 -0
- package/packages/metrics-interface/dist/index.d.ts +2 -0
- package/packages/metrics-interface/dist/index.d.ts.map +1 -0
- package/packages/metrics-interface/dist/index.js +14 -0
- package/packages/metrics-interface/dist/index.js.map +1 -0
- package/packages/metrics-interface/dist/metrics.d.ts +40 -0
- package/packages/metrics-interface/dist/metrics.d.ts.map +1 -0
- package/packages/metrics-interface/dist/metrics.js +53 -0
- package/packages/metrics-interface/dist/metrics.js.map +1 -0
- package/packages/metrics-interface/dist/mocks/index.d.ts +34 -0
- package/packages/metrics-interface/dist/mocks/index.d.ts.map +1 -0
- package/packages/metrics-interface/dist/mocks/index.js +43 -0
- package/packages/metrics-interface/dist/mocks/index.js.map +1 -0
- package/packages/metrics-interface/package.json +34 -0
- package/scripts/build.sh +1 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# @atlassian/metrics-interface
|
|
2
|
+
|
|
3
|
+
## 1.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c0069ef: Package is now compiled with Typescript 4.4
|
|
8
|
+
|
|
9
|
+
Useful links:
|
|
10
|
+
|
|
11
|
+
- https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#more-compliant-indirect-calls-for-imported-functions
|
|
12
|
+
- http://perfectionkills.com/global-eval-what-are-the-options/
|
|
13
|
+
|
|
14
|
+
## 1.3.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- fae10a6: Fixed an issue with compiled typings files after upgrading to TypeScript 4.3. The imports in the typings.d.ts files were compiled with paths relative to the monorepo root, rather than absolute package paths. This problem has now been fixed.
|
|
19
|
+
|
|
20
|
+
## 1.3.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- fae1cc7: Minor type changes and tweaks so the package now builds with TypeScript ~4.3
|
|
25
|
+
|
|
26
|
+
## 1.3.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- 9913f59: feat: Added configurable timing precision, repalced hrtime with performance from perf_hooks
|
|
31
|
+
|
|
32
|
+
## 1.2.4
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- fae14d5: An upgrade to prettier caused some changes to linting
|
|
37
|
+
|
|
38
|
+
## 1.2.3
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- fae196c: Added a feature to the monorepo so packages with non js entrypoints can be used
|
|
43
|
+
|
|
44
|
+
## 1.2.2
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- fae1709: Fixed an issue during package building, so bumping all packages to ensure distribution assets are valid
|
|
49
|
+
|
|
50
|
+
## 1.2.1
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 97644a1: Set Typescript Compiler target to ES2018
|
|
55
|
+
|
|
56
|
+
## 1.2.0
|
|
57
|
+
|
|
58
|
+
### Minor Changes
|
|
59
|
+
|
|
60
|
+
- 3e7f6c1: feat: metrics.timing() supports passing tags in stop() function, stop() returns value
|
|
61
|
+
|
|
62
|
+
## 1.1.2
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- fae1a543: In files where @typescript-eslint/no-namespaces is already ignored, also ignore import/export.
|
|
67
|
+
|
|
68
|
+
## 1.1.1
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- fae18d7: linting updates to the monorepo
|
|
73
|
+
|
|
74
|
+
## 1.1.0
|
|
75
|
+
|
|
76
|
+
### Minor Changes
|
|
77
|
+
|
|
78
|
+
- 1f4aaad: feat: metrics.counter has new 'incrBy' and 'decrBy' interface
|
|
79
|
+
|
|
80
|
+
## 1.0.15
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- 85bb2aa: monorepo changes: rename packageJson.publishConfig to packageJson.config.publishOverrides
|
|
85
|
+
|
|
86
|
+
## 1.0.14
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- 645304b: fix: ensure all monorepo packages do not use ranges in their dependencies (for changeset's automatic bumps)
|
|
91
|
+
|
|
92
|
+
## 1.0.13
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- 6af309e: chore: update homepage field in package.json
|
|
97
|
+
|
|
98
|
+
## 1.0.12
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 37e36f9: fix: the main, types and typings fields in package.json were incorrect on publish
|
|
103
|
+
|
|
104
|
+
## 1.0.11
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- b9aad92: fix: the previous patch version did not contain dist files
|
|
109
|
+
|
|
110
|
+
## 1.0.10
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- c255e4f: Dev improvements: Updated how the package is tested and published
|
|
115
|
+
|
|
116
|
+
## 1.0.9
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- 30c71b0: Add eslint import rules.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Metrics Interface
|
|
2
|
+
|
|
3
|
+
- Do you want to have metrics inside your NodeJS Micros service?
|
|
4
|
+
- Want a nice way to use different types of metrics between services?
|
|
5
|
+
- Don't want to have to remember different APIs for different metrics?
|
|
6
|
+
|
|
7
|
+
The answer is to use this lovely and simple metrics interface!
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
This module just exports an interface that provides better interoperability for TypeScript services that use any kind of metrics.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Import each type as required by your use-case.
|
|
15
|
+
import { Metrics, Counter, Gauge, Tags, Timing } from '@atlassian/metrics-interface';
|
|
16
|
+
|
|
17
|
+
export class MyMetricsClass implements Metrics {
|
|
18
|
+
// Returns a Metrics instance to be used as child.
|
|
19
|
+
child(name: string, tags?: Tags): Metrics {
|
|
20
|
+
/* ... */
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Create a counter metric:
|
|
24
|
+
// const counter = myMetrics.counter('page_visits');
|
|
25
|
+
// counter.incr(); // <-- increase the count
|
|
26
|
+
// counter.decr(); // <-- decrease the count
|
|
27
|
+
counter(name: string, tags?: Tags): Counter {
|
|
28
|
+
/* ... */
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Create a simple gauge metric:
|
|
32
|
+
// const gauge = myMetrics.gauge('cpu_percentage');
|
|
33
|
+
// gauge.set(75);
|
|
34
|
+
gauge(name: string, tags?: Tags): Gauge {
|
|
35
|
+
/* ... */
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Create a timer metric:
|
|
39
|
+
// const initMetric = myMetrics.timing('initialisation');
|
|
40
|
+
// const timer = initMetric.measure();
|
|
41
|
+
// ...
|
|
42
|
+
// timer.stop();
|
|
43
|
+
timing(name: string, tags?: Tags): Timing {
|
|
44
|
+
/* ... */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Emit a custom event for your metrics:
|
|
48
|
+
// myMetrics.event('something_happened', 'foo bar baz quix...');
|
|
49
|
+
event(title: string, description?: string): void {
|
|
50
|
+
/* ... */
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If you want to know more specifics about how to use this interface, please see the source code. It's a really simple interface, and should be self-explanatory. You can see modules that use it below if you'd like to see how it's being consumed.
|
|
56
|
+
|
|
57
|
+
## Implementations
|
|
58
|
+
|
|
59
|
+
For great implementations of this interface, see the following:
|
|
60
|
+
|
|
61
|
+
- https://bitbucket.org/atlassian/statsd-metrics/
|
|
62
|
+
- https://bitbucket.org/atlassian/appmetrics-monitor/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./metrics"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface Tags {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
export interface Metrics {
|
|
5
|
+
child(name: string, tags?: Tags): Metrics;
|
|
6
|
+
counter(name: string, tags?: Tags): Counter;
|
|
7
|
+
gauge(name: string, tags?: Tags): Gauge;
|
|
8
|
+
timing(name: string, tags?: Tags): Timing;
|
|
9
|
+
event(title: string, description?: string): void;
|
|
10
|
+
}
|
|
11
|
+
export interface Counter {
|
|
12
|
+
incr(): void;
|
|
13
|
+
decr(): void;
|
|
14
|
+
incrBy(val: number): void;
|
|
15
|
+
decrBy(val: number): void;
|
|
16
|
+
}
|
|
17
|
+
export interface Gauge {
|
|
18
|
+
set(val: number): void;
|
|
19
|
+
}
|
|
20
|
+
export interface Timing {
|
|
21
|
+
set(val: number, extraTags?: Tags): void;
|
|
22
|
+
measure(): Timing.Stop;
|
|
23
|
+
}
|
|
24
|
+
export interface TimingOptions {
|
|
25
|
+
precision?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare namespace Timing {
|
|
28
|
+
interface Stop {
|
|
29
|
+
stop(extraTags?: Tags, opts?: TimingOptions): number;
|
|
30
|
+
}
|
|
31
|
+
const measure: (cb: (val: number, extraTags?: Tags | undefined) => void, timingOptions?: TimingOptions | undefined) => Stop;
|
|
32
|
+
}
|
|
33
|
+
export declare class NoMetrics implements Metrics {
|
|
34
|
+
child(_name: string): Metrics;
|
|
35
|
+
counter(_name: string): Counter;
|
|
36
|
+
gauge(_name: string): Gauge;
|
|
37
|
+
timing(_name: string): Timing;
|
|
38
|
+
event(_title: string, _description?: string): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,IAAI;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC;IAC1C,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC;IAC5C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IA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@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace, import/export */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NoMetrics = exports.Timing = void 0;
|
|
5
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
6
|
+
var Timing;
|
|
7
|
+
(function (Timing) {
|
|
8
|
+
Timing.measure = (cb, timingOptions) => {
|
|
9
|
+
const start = perf_hooks_1.performance.now();
|
|
10
|
+
return {
|
|
11
|
+
stop: (tags) => {
|
|
12
|
+
const latency = perf_hooks_1.performance.now() - start;
|
|
13
|
+
const result = parseFloat(latency.toFixed(timingOptions === null || timingOptions === void 0 ? void 0 : timingOptions.precision));
|
|
14
|
+
cb(result, tags);
|
|
15
|
+
return result;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
})(Timing = exports.Timing || (exports.Timing = {}));
|
|
20
|
+
// A simple class that implements the interface without actually doing anything.
|
|
21
|
+
// You can use this in tests as a stub, as part of an abstract class, or where
|
|
22
|
+
// you need to have something that implements Metrics without its functionality.
|
|
23
|
+
class NoMetrics {
|
|
24
|
+
child(_name) {
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
counter(_name) {
|
|
28
|
+
return {
|
|
29
|
+
incr: () => { },
|
|
30
|
+
decr: () => { },
|
|
31
|
+
incrBy: (_val) => { },
|
|
32
|
+
decrBy: (_val) => { },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
gauge(_name) {
|
|
36
|
+
return {
|
|
37
|
+
set: (_val) => { },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
timing(_name) {
|
|
41
|
+
return {
|
|
42
|
+
set: (_val) => { },
|
|
43
|
+
measure: () => {
|
|
44
|
+
return {
|
|
45
|
+
stop: () => 0,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
event(_title, _description) { }
|
|
51
|
+
}
|
|
52
|
+
exports.NoMetrics = NoMetrics;
|
|
53
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":";AAAA,mEAAmE;;;AAEnE,2CAAyC;AAmCzC,IAAiB,MAAM,CAgBtB;AAhBD,WAAiB,MAAM;IAKR,cAAO,GAAG,CAAC,EAA2C,EAAE,aAA6B,EAAQ,EAAE;QAC1G,MAAM,KAAK,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAChC,OAAO;YACL,IAAI,EAAE,CAAC,IAAW,EAAE,EAAE;gBACpB,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;gBAC1C,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAAC,CAAC,CAAC;gBACrE,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBACjB,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EAhBgB,MAAM,GAAN,cAAM,KAAN,cAAM,QAgBtB;AAED,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF,MAAa,SAAS;IACpB,KAAK,CAAC,KAAa;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,KAAa;QACnB,OAAO;YACL,IAAI,EAAE,GAAS,EAAE,GAAE,CAAC;YACpB,IAAI,EAAE,GAAS,EAAE,GAAE,CAAC;YACpB,MAAM,EAAE,CAAC,IAAY,EAAQ,EAAE,GAAE,CAAC;YAClC,MAAM,EAAE,CAAC,IAAY,EAAQ,EAAE,GAAE,CAAC;SACnC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAa;QACjB,OAAO;YACL,GAAG,EAAE,CAAC,IAAY,EAAQ,EAAE,GAAE,CAAC;SAChC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO;YACL,GAAG,EAAE,CAAC,IAAY,EAAQ,EAAE,GAAE,CAAC;YAC/B,OAAO,EAAE,GAAgB,EAAE;gBACzB,OAAO;oBACL,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;iBACd,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,MAAc,EAAE,YAAqB,IAAS,CAAC;CACtD;AAhCD,8BAgCC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { Counter, Gauge, Metrics, Tags, Timing } from '../index';
|
|
3
|
+
export declare class MockCounter implements Counter {
|
|
4
|
+
name: string;
|
|
5
|
+
tags?: Tags | undefined;
|
|
6
|
+
incr: jest.Mock<any, any>;
|
|
7
|
+
decr: jest.Mock<any, any>;
|
|
8
|
+
incrBy: jest.Mock<any, any>;
|
|
9
|
+
decrBy: jest.Mock<any, any>;
|
|
10
|
+
constructor(name: string, tags?: Tags | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare class MockGauge implements Gauge {
|
|
13
|
+
name: string;
|
|
14
|
+
tags?: Tags | undefined;
|
|
15
|
+
set: jest.Mock<any, any>;
|
|
16
|
+
constructor(name: string, tags?: Tags | undefined);
|
|
17
|
+
}
|
|
18
|
+
export declare class MockTiming implements Timing {
|
|
19
|
+
name: string;
|
|
20
|
+
tags?: Tags | undefined;
|
|
21
|
+
set: jest.Mock<any, any>;
|
|
22
|
+
measure: jest.Mock<{
|
|
23
|
+
stop: jest.Mock<any, any>;
|
|
24
|
+
}, []>;
|
|
25
|
+
constructor(name: string, tags?: Tags | undefined);
|
|
26
|
+
}
|
|
27
|
+
export declare class MockMetrics implements Metrics {
|
|
28
|
+
child: jest.Mock<MockMetrics, []>;
|
|
29
|
+
counter: jest.Mock<MockCounter, [name: any, tags: any]>;
|
|
30
|
+
gauge: jest.Mock<MockGauge, [name: any, tags: any]>;
|
|
31
|
+
timing: jest.Mock<MockTiming, [name: any, tags: any]>;
|
|
32
|
+
event: jest.Mock<any, any>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mocks/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEjE,qBAAa,WAAY,YAAW,OAAO;IAKtB,IAAI,EAAE,MAAM;IAAS,IAAI,CAAC;IAJ7C,IAAI,sBAAa;IACjB,IAAI,sBAAa;IACjB,MAAM,sBAAa;IACnB,MAAM,sBAAa;gBACA,IAAI,EAAE,MAAM,EAAS,IAAI,CAAC,kBAAM;CACpD;AAED,qBAAa,SAAU,YAAW,KAAK;IAElB,IAAI,EAAE,MAAM;IAAS,IAAI,CAAC;IAD7C,GAAG,sBAAa;gBACG,IAAI,EAAE,MAAM,EAAS,IAAI,CAAC,kBAAM;CACpD;AAED,qBAAa,UAAW,YAAW,MAAM;IAGpB,IAAI,EAAE,MAAM;IAAS,IAAI,CAAC;IAF7C,GAAG,sBAAa;IAChB,OAAO;;WAAwC;gBAC5B,IAAI,EAAE,MAAM,EAAS,IAAI,CAAC,kBAAM;CACpD;AAGD,qBAAa,WAAY,YAAW,OAAO;IACzC,KAAK,6BAAoC;IACzC,OAAO,iDAAwD;IAC/D,KAAK,+CAAsD;IAC3D,MAAM,gDAAuD;IAC7D,KAAK,sBAAa;CACnB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockMetrics = exports.MockTiming = exports.MockGauge = exports.MockCounter = void 0;
|
|
4
|
+
class MockCounter {
|
|
5
|
+
constructor(name, tags) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.tags = tags;
|
|
8
|
+
this.incr = jest.fn();
|
|
9
|
+
this.decr = jest.fn();
|
|
10
|
+
this.incrBy = jest.fn();
|
|
11
|
+
this.decrBy = jest.fn();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.MockCounter = MockCounter;
|
|
15
|
+
class MockGauge {
|
|
16
|
+
constructor(name, tags) {
|
|
17
|
+
this.name = name;
|
|
18
|
+
this.tags = tags;
|
|
19
|
+
this.set = jest.fn();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.MockGauge = MockGauge;
|
|
23
|
+
class MockTiming {
|
|
24
|
+
constructor(name, tags) {
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.tags = tags;
|
|
27
|
+
this.set = jest.fn();
|
|
28
|
+
this.measure = jest.fn(() => ({ stop: jest.fn() }));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.MockTiming = MockTiming;
|
|
32
|
+
// Export a mock so any users of this library that use jest can use it.
|
|
33
|
+
class MockMetrics {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.child = jest.fn(() => new MockMetrics());
|
|
36
|
+
this.counter = jest.fn((name, tags) => new MockCounter(name, tags));
|
|
37
|
+
this.gauge = jest.fn((name, tags) => new MockGauge(name, tags));
|
|
38
|
+
this.timing = jest.fn((name, tags) => new MockTiming(name, tags));
|
|
39
|
+
this.event = jest.fn();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.MockMetrics = MockMetrics;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mocks/index.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;IAKtB,YAAmB,IAAY,EAAS,IAAW;QAAhC,SAAI,GAAJ,IAAI,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAO;QAJnD,SAA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AU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC7D,UAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;IACpB,CAAC;CAAA;AAND,kCAMC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "metrics-interface",
|
|
3
|
+
"version": "1.3.3",
|
|
4
|
+
"contributors": [
|
|
5
|
+
{
|
|
6
|
+
"name": "Callum Osmotherly",
|
|
7
|
+
"email": "cosmotherly@atlassian.com"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "Luciano Leggieri",
|
|
11
|
+
"email": "lleggieri@atlassian.com"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/index",
|
|
15
|
+
"license": "Proprietary",
|
|
16
|
+
"repository": {
|
|
17
|
+
"directory": "src/packages/metrics/metrics-interface",
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git@bitbucket.org:atlassian/incredible-monorepo.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://bitbucket.org/atlassian/incredible-monorepo/src/master/src/packages/metrics/metrics-interface",
|
|
22
|
+
"files": [
|
|
23
|
+
"bin/",
|
|
24
|
+
"dist/",
|
|
25
|
+
"package.json",
|
|
26
|
+
"CHANGELOG.md",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"typings": "dist/index.d.ts",
|
|
31
|
+
"config": {
|
|
32
|
+
"registry": "atlassian"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/scripts/build.sh
CHANGED