test
This commit is contained in:
parent
8966727672
commit
fdc66a6bc4
17
index.ts
17
index.ts
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
import { createServer, Server } from "http";
|
import { createServer, Server } from "http";
|
||||||
import IConfig from "./interfaces/IConfig";
|
import IConfig from "./interfaces/IConfig";
|
||||||
|
import IMetric from "./interfaces/IMetric";
|
||||||
|
|
||||||
export default abstract class SimpleProm {
|
export default class SimpleProm {
|
||||||
static instance?:SimpleProm;
|
static instance?:SimpleProm;
|
||||||
|
|
||||||
public config:IConfig;
|
public config:IConfig;
|
||||||
|
@ -16,12 +17,26 @@ export default abstract class SimpleProm {
|
||||||
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
|
if (this.config.selfHost) {
|
||||||
|
this.config.selfHostPort = this.config.selfHostPort ?? 9100;
|
||||||
|
|
||||||
this.selfHostServer = createServer((req, res) => {
|
this.selfHostServer = createServer((req, res) => {
|
||||||
res.end("SimpleProm exporter");
|
res.end("SimpleProm exporter");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.selfHostServer.listen(this.config.selfHostPort);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static init(config:IConfig) {
|
static init(config:IConfig) {
|
||||||
|
return new SimpleProm(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public addMetric(metric:IMetric) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public removeMetric(metric:IMetric) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default interface IMetric {
|
||||||
|
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "A simple and easy to use module for Prometheus metric exporting.",
|
"description": "A simple and easy to use module for Prometheus metric exporting.",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.js",
|
"types": "./lib/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"updateCheck": "check-outdated",
|
"updateCheck": "check-outdated",
|
||||||
"_clean": "tsc --build --clean",
|
"_clean": "tsc --build --clean",
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import SimpleProm from "..";
|
||||||
|
|
||||||
|
SimpleProm.init({
|
||||||
|
selfHost: true
|
||||||
|
});
|
Loading…
Reference in New Issue