This repository has been archived by the owner on May 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
chore(deps): bump prom-client from 14.2.0 to 15.1.0 #1272
Merged
10xLaCroixDrinker
merged 6 commits into
main
from
dependabot/npm_and_yarn/main/prom-client-15.1.0
Feb 5, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1afd9d1
chore(deps): bump prom-client from 14.2.0 to 15.1.0
dependabot[bot] 651a333
test(metrics): dont mock prom-client
10xLaCroixDrinker 58646df
Merge branch 'main' into dependabot/npm_and_yarn/main/prom-client-15.1.0
10xLaCroixDrinker d5d2da2
test(counters): additional arguments
10xLaCroixDrinker 82ba781
Merge branch 'dependabot/npm_and_yarn/main/prom-client-15.1.0' of htt…
10xLaCroixDrinker 954de06
fix(metrics): provide promClient for fastify-metrics
10xLaCroixDrinker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -14,15 +14,15 @@ | |
* permissions and limitations under the License. | ||
*/ | ||
|
||
/* eslint-disable no-underscore-dangle -- prom-client uses dangling underscore */ | ||
|
||
describe('gauges', () => { | ||
let Gauge; | ||
let register; | ||
|
||
function load() { | ||
jest.resetModules(); | ||
|
||
jest.mock('prom-client'); | ||
({ Gauge } = require('prom-client')); | ||
|
||
({ Gauge, register } = require('prom-client')); | ||
return require('../../../src/server/metrics/gauges'); | ||
} | ||
|
||
|
@@ -34,18 +34,19 @@ describe('gauges', () => { | |
|
||
it('creates a gauge with the options', () => { | ||
const { createGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
expect(Gauge).toHaveBeenCalledTimes(1); | ||
const gauge = Gauge.mock.instances[0]; | ||
expect(register._metrics).toEqual({}); | ||
createGauge({ name: 'yup', help: 'yup_help' }); | ||
const gauge = register._metrics.yup; | ||
expect(gauge).toBeInstanceOf(Gauge); | ||
}); | ||
|
||
it('does not create a new gauge if one with the same name already exists', () => { | ||
const { createGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
expect(Gauge).toHaveBeenCalledTimes(1); | ||
createGauge({ name: 'yup' }); | ||
expect(Gauge).toHaveBeenCalledTimes(1); | ||
expect(register._metrics).toEqual({}); | ||
createGauge({ name: 'yup', help: 'yup_help' }); | ||
const gauge = register._metrics.yup; | ||
createGauge({ name: 'yup', help: 'yup_help' }); | ||
expect(register._metrics.yup).toBe(gauge); | ||
}); | ||
}); | ||
|
||
|
@@ -57,24 +58,38 @@ describe('gauges', () => { | |
|
||
it('throws an error if the gauge does not exist', () => { | ||
const { incrementGauge } = load(); | ||
expect(() => incrementGauge('nope')).toThrowErrorMatchingSnapshot(); | ||
expect(() => incrementGauge('nope')).toThrowErrorMatchingInlineSnapshot( | ||
'"unable to find gauge nope, please create it first"' | ||
); | ||
}); | ||
|
||
it('calls the inc method of the gauge', () => { | ||
const { createGauge, incrementGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
const gauge = Gauge.mock.instances[0]; | ||
createGauge({ name: 'yup', help: 'yup_help' }); | ||
const gauge = register._metrics.yup; | ||
expect(gauge.hashMap[''].value).toBe(0); | ||
incrementGauge('yup'); | ||
expect(gauge.inc).toHaveBeenCalledTimes(1); | ||
expect(gauge.hashMap[''].value).toBe(1); | ||
incrementGauge('yup', 2); | ||
expect(gauge.hashMap[''].value).toBe(3); | ||
}); | ||
|
||
it('calls the inc method of the gauge with the arguments', () => { | ||
const { createGauge, incrementGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
const gauge = Gauge.mock.instances[0]; | ||
incrementGauge('yup', 1, 'two', [null, null, null]); | ||
expect(gauge.inc).toHaveBeenCalledTimes(1); | ||
expect(gauge.inc).toHaveBeenCalledWith(1, 'two', [null, null, null]); | ||
createGauge({ name: 'yup', help: 'yup_help', labelNames: ['foo'] }); | ||
const gauge = register._metrics.yup; | ||
expect(gauge.hashMap).toEqual({}); | ||
incrementGauge('yup', { foo: 'bar' }, 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An object of labels (defined at metric creation) is the only other valid argument |
||
expect(gauge.hashMap).toMatchInlineSnapshot(` | ||
{ | ||
"foo:bar,": { | ||
"labels": { | ||
"foo": "bar", | ||
}, | ||
"value": 2, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
|
@@ -86,24 +101,36 @@ describe('gauges', () => { | |
|
||
it('throws an error if the gauge does not exist', () => { | ||
const { setGauge } = load(); | ||
expect(() => setGauge('nope')).toThrowErrorMatchingSnapshot(); | ||
expect(() => setGauge('nope')).toThrowErrorMatchingInlineSnapshot( | ||
'"unable to find gauge nope, please create it first"' | ||
); | ||
}); | ||
|
||
it('calls the set method of the gauge', () => { | ||
const { createGauge, setGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
const gauge = Gauge.mock.instances[0]; | ||
setGauge('yup'); | ||
expect(gauge.set).toHaveBeenCalledTimes(1); | ||
createGauge({ name: 'yup', help: 'yup_help' }); | ||
const gauge = register._metrics.yup; | ||
expect(gauge.hashMap[''].value).toBe(0); | ||
setGauge('yup', 101); | ||
expect(gauge.hashMap[''].value).toBe(101); | ||
}); | ||
|
||
it('calls the set method of the gauge with the arguments', () => { | ||
const { createGauge, setGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
const gauge = Gauge.mock.instances[0]; | ||
setGauge('yup', 1, 'two', [null, null, null]); | ||
expect(gauge.set).toHaveBeenCalledTimes(1); | ||
expect(gauge.set).toHaveBeenCalledWith(1, 'two', [null, null, null]); | ||
createGauge({ name: 'yup', help: 'yup_help', labelNames: ['foo'] }); | ||
const gauge = register._metrics.yup; | ||
expect(gauge.hashMap).toEqual({}); | ||
setGauge('yup', { foo: 'bar' }, 101); | ||
expect(gauge.hashMap).toMatchInlineSnapshot(` | ||
{ | ||
"foo:bar,": { | ||
"labels": { | ||
"foo": "bar", | ||
}, | ||
"value": 101, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
|
@@ -115,24 +142,19 @@ describe('gauges', () => { | |
|
||
it('throws an error if the gauge does not exist', () => { | ||
const { resetGauge } = load(); | ||
expect(() => resetGauge('nope')).toThrowErrorMatchingSnapshot(); | ||
expect(() => resetGauge('nope')).toThrowErrorMatchingInlineSnapshot( | ||
'"unable to find gauge nope, please create it first"' | ||
); | ||
}); | ||
|
||
it('calls the reset method of the gauge', () => { | ||
const { createGauge, resetGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
const gauge = Gauge.mock.instances[0]; | ||
const { createGauge, resetGauge, setGauge } = load(); | ||
createGauge({ name: 'yup', help: 'yup_help' }); | ||
const gauge = register._metrics.yup; | ||
setGauge('yup', 101); | ||
expect(gauge.hashMap[''].value).toBe(101); | ||
resetGauge('yup'); | ||
expect(gauge.reset).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('calls the reset method of the gauge with the arguments', () => { | ||
const { createGauge, resetGauge } = load(); | ||
createGauge({ name: 'yup' }); | ||
const gauge = Gauge.mock.instances[0]; | ||
resetGauge('yup', 1, 'two', [null, null, null]); | ||
expect(gauge.reset).toHaveBeenCalledTimes(1); | ||
expect(gauge.reset).toHaveBeenCalledWith(1, 'two', [null, null, null]); | ||
expect(gauge.hashMap[''].value).toBe(0); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An internal, non-breaking change to
prom-client
broke this mock.