Skip to content

Commit

Permalink
fix: handle receive event correctly when query is not executed inside…
Browse files Browse the repository at this point in the history
… task or transaction
  • Loading branch information
christiangalsterer committed Jul 17, 2024
1 parent d4c62a5 commit db8fe5d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/pgPromisePrometheusExporter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { monitorPgPool } from '@christiangalsterer/node-postgres-prometheus-exporter'
import { type PgPoolExporterOptions } from '@christiangalsterer/node-postgres-prometheus-exporter/dist/pgPoolExporterOptions'
import { type IDatabase, type IEventContext, type IInitOptions, type IResultExt,type ITaskContext } from 'pg-promise'
import { type IDatabase, type IEventContext, type IInitOptions, type IResultExt, type ITaskContext } from 'pg-promise'
import { Histogram, type Registry } from 'prom-client'

import { type PgPromiseExporterOptions } from './pgPromiseExporterOptions'
Expand Down Expand Up @@ -32,11 +32,11 @@ export class PgPromisePrometheusExporter {
}

static getStatus(ctx: ITaskContext | undefined): string {
let status = 'SUCCESS';
let status = 'SUCCESS'
if (ctx !== undefined) {
status = ctx.success === false ? 'ERROR' : 'SUCCESS';
status = ctx.success === false ? 'ERROR' : 'SUCCESS'
}
return status;
return status
}

constructor(db: IDatabase<unknown>, pgPromiseInitOptions: IInitOptions, register: Registry, options?: PgPromiseExporterOptions) {
Expand Down Expand Up @@ -184,5 +184,4 @@ export class PgPromisePrometheusExporter {
console.error('An error occurred in the transaction event handling', error)
}
}

}

0 comments on commit db8fe5d

Please sign in to comment.