-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pushgateway): add support for Pushgateway
Closes #1628 Signed-off-by: Will Soto <willsoto@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Injectable, Module } from "@nestjs/common"; | ||
import { expect } from "chai"; | ||
import { Pushgateway, register } from "prom-client"; | ||
import { PrometheusOptions, PrometheusOptionsFactory } from "../src"; | ||
import { createAsyncPrometheusModule, createPrometheusModule } from "./utils"; | ||
|
||
describe("Pushgateway", function () { | ||
@Injectable() | ||
class OptionsService implements PrometheusOptionsFactory { | ||
createPrometheusOptions(): PrometheusOptions | Promise<PrometheusOptions> { | ||
return { | ||
pushgateway: { | ||
url: "http://127.0.0.1:9091", | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
@Module({ | ||
providers: [OptionsService], | ||
exports: [OptionsService], | ||
}) | ||
class OptionsModule {} | ||
|
||
afterEach(function () { | ||
register.clear(); | ||
}); | ||
|
||
it("should register a pushgateway if options are provided (sync)", async function () { | ||
const { testingModule, app } = await createPrometheusModule({ | ||
pushgateway: { | ||
url: "http://127.0.0.1:9091", | ||
}, | ||
}); | ||
const gateway = testingModule.get(Pushgateway); | ||
|
||
expect(gateway).to.be.instanceOf(Pushgateway); | ||
|
||
await app.close(); | ||
}); | ||
|
||
it("should register a pushgateway if options are provided (async)", async function () { | ||
const { testingModule, app } = await createAsyncPrometheusModule({ | ||
imports: [OptionsModule], | ||
useExisting: OptionsService, | ||
inject: [OptionsService], | ||
}); | ||
const gateway = testingModule.get(Pushgateway); | ||
|
||
expect(gateway).to.be.instanceOf(Pushgateway); | ||
|
||
await app.close(); | ||
}); | ||
}); |