Skip to content

Commit 2f22131

Browse files
authored
🤖 Merge PR DefinitelyTyped#72901 feat: ✨ add types for opossum-prometheus by @iamchathu
1 parent 0c44feb commit 2f22131

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type * as CircuitBreaker from "opossum";
2+
import type { Registry } from "prom-client";
3+
4+
/**
5+
* Options for configuring OpossumMetrics.
6+
*/
7+
interface OpossumMetricsOptions {
8+
/**
9+
* A list or individual circuit breaker to create metrics for.
10+
* @default undefined - No circuits.
11+
*/
12+
circuits?: CircuitBreaker[] | undefined;
13+
14+
/**
15+
* An existing registry to use for prometheus metrics.
16+
* @default undefined - The default prometheus registry will be used and default system metrics will be collected
17+
*/
18+
registry?: Registry | undefined;
19+
20+
/**
21+
* Measure the performance of breakers and report them through the registry.
22+
* @default true
23+
*/
24+
exposePerformanceMetrics?: boolean | undefined;
25+
26+
/**
27+
* Prefix for circuit breakers metrics name.
28+
*/
29+
metricPrefix?: string | undefined;
30+
}
31+
32+
/**
33+
* Class for integrating Opossum circuit breakers with Prometheus metrics.
34+
*/
35+
declare class OpossumMetrics {
36+
/**
37+
* Creates an instance of OpossumMetrics.
38+
* @param options - Configuration options for the metrics.
39+
*/
40+
constructor(options?: OpossumMetricsOptions);
41+
42+
/**
43+
* Adds a circuit breaker to be monitored.
44+
* @param circuit - The circuit breaker to add.
45+
*/
46+
add(circuit: CircuitBreaker): void;
47+
}
48+
49+
export = OpossumMetrics;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type * as CircuitBreaker from "opossum";
2+
import OpossumMetrics from "opossum-prometheus";
3+
import type { Registry } from "prom-client";
4+
5+
// $ExpectType OpossumMetrics
6+
const opossumPrometheus: OpossumMetrics = new OpossumMetrics({
7+
circuits: [{} as CircuitBreaker],
8+
registry: {} as Registry,
9+
exposePerformanceMetrics: true,
10+
metricPrefix: "my_prefix_",
11+
});
12+
13+
// $ExpectType void
14+
opossumPrometheus.add({} as CircuitBreaker);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"private": true,
3+
"name": "@types/opossum-prometheus",
4+
"version": "0.4.9999",
5+
"projects": [
6+
"https://github.com/nodeshift/opossum-prometheus#readme"
7+
],
8+
"dependencies": {
9+
"@types/node": "*",
10+
"@types/opossum": "*",
11+
"prom-client": "*"
12+
},
13+
"devDependencies": {
14+
"@types/opossum-prometheus": "workspace:."
15+
},
16+
"owners": [
17+
{
18+
"name": "Chathu Vishwaijith",
19+
"githubUsername": "iamchathu"
20+
}
21+
]
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.d.ts",
17+
"opossum-prometheus-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)