Skip to content

Commit

Permalink
fix: remove errorCount prefix (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinkrustev authored Dec 12, 2024
1 parent 40ad5db commit ac5e084
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"devDependencies": {
"@hapi/hapi": "^21.3.12",
"@types/node": "^22.10.1",
"@types/node": "^22.10.2",
"@types/tape": "^5.6.5",
"audit-ci": "^7.1.0",
"debug": "4.4.0",
Expand Down
8 changes: 5 additions & 3 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class Metrics {
client.AggregatorRegistry.setRegistries(this.getDefaultRegister())
return false
}
this.getDefaultRegister().clear()
this._options = options
// map the options to the normalised options specific to the prom-client
const normalisedOptions: normalisedMetricOptionsType = {
Expand Down Expand Up @@ -122,7 +123,8 @@ class Metrics {
this.getCounter(
'errorCount',
'Error count',
['code', 'system', 'operation', 'step']
['code', 'system', 'operation', 'step'],
false
)
}

Expand Down Expand Up @@ -170,13 +172,13 @@ class Metrics {
}
}

getCounter = (name: string, help?: string, labelNames?: string[]): client.Counter<string> => {
getCounter = (name: string, help?: string, labelNames?: string[], prefix: boolean = true): client.Counter<string> => {
try {
if (this._counters[name] != null) {
return this._counters[name]
}
this._counters[name] = new client.Counter({
name: `${this.getOptions().prefix}${name}`,
name: `${prefix ? this.getOptions().prefix : ''}${name}`,
help: (help != null ? help : `${name}_counter`),
labelNames
})
Expand Down

0 comments on commit ac5e084

Please sign in to comment.