Skip to content

Commit

Permalink
feat: allow the module to be registered as global
Browse files Browse the repository at this point in the history
  • Loading branch information
microwavekonijn authored and willsoto committed Sep 15, 2023
1 parent da38036 commit 113c02a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export interface PrometheusDefaultMetrics {
* @public
*/
export interface PrometheusOptions {
/**
* Make the module global when set to true
* */
global?: boolean;
/**
* Similar to `defaultMetrics.prefix`, this will be applied to each custom
* metric created using the various providers. Will suffix the given prefix
Expand Down Expand Up @@ -98,6 +102,8 @@ export interface PrometheusOptionsFactory {
*/
export interface PrometheusAsyncOptions
extends Pick<ModuleMetadata, "imports"> {
global?: boolean;

useExisting?: Type<PrometheusOptionsFactory>;
useClass?: Type<PrometheusOptionsFactory>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class PrometheusModule {

return {
module: PrometheusModule,
global: opts.global,
providers,
controllers: [opts.controller],
exports: providers,
Expand All @@ -58,6 +59,7 @@ export class PrometheusModule {

return {
module: PrometheusModule,
global: options.global,
controllers: [controller],
imports: options.imports,
providers: [
Expand Down Expand Up @@ -181,6 +183,7 @@ export class PrometheusModule {
options?: PrometheusOptions,
): PrometheusOptionsWithDefaults {
return {
global: false,
path: "/metrics",
defaultMetrics: {
enabled: true,
Expand Down

0 comments on commit 113c02a

Please sign in to comment.