Skip to content

Commit

Permalink
refactor!: upgrade to prom-client 15.1.0
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop support for node 16
  • Loading branch information
p-kuen authored and SkeLLLa committed Mar 8, 2024
1 parent 87b403c commit bf31d38
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pnpm i fastify-metrics --save
---

- Requires fastify `>=4.0.0`.
- Node.js `>=16.0.0`.
- Node.js `>=18.0.0`.

<sub>[Back to top](#toc)</sub>

Expand Down
4 changes: 2 additions & 2 deletions docs/api/fastify-metrics.idefaultmetricsconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Default prom-client metrics config
<b>Signature:</b>

```typescript
export interface IDefaultMetricsConfig extends DefaultMetricsCollectorConfiguration
export interface IDefaultMetricsConfig extends DefaultMetricsCollectorConfiguration<'text/plain; version=0.0.4; charset=utf-8'>
```
<b>Extends:</b> DefaultMetricsCollectorConfiguration
<b>Extends:</b> DefaultMetricsCollectorConfiguration&lt;'text/plain; version=0.0.4; charset=utf-8'&gt;
## Remarks
Expand Down
2 changes: 1 addition & 1 deletion etc/fastify-metrics.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default _default;

// @public
export interface IDefaultMetricsConfig
extends DefaultMetricsCollectorConfiguration {
extends DefaultMetricsCollectorConfiguration<'text/plain; version=0.0.4; charset=utf-8'> {
enabled: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"fastify-plugin": "^4.3.0",
"prom-client": "^14.2.0"
"prom-client": "^15.1.0"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
Expand Down
16 changes: 11 additions & 5 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/__tests__/edge-cases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('edge cases', () => {
expect.stringMatching(
/process_cpu_user_seconds_total\{foo="bar"\} \d+/
),
'http_request_duration_seconds_count{method="GET",route="/test",status_code="200",foo="bar"} 1',
'http_request_duration_seconds_count{foo="bar",method="GET",route="/test",status_code="200"} 1',
'http_request_summary_seconds_count{method="GET",route="/test",status_code="200",foo="bar"} 1',
])
);
Expand Down
7 changes: 5 additions & 2 deletions src/fastify-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import promClient, {
Histogram,
LabelValues,
PrometheusContentType,
Registry,
Summary,
} from 'prom-client';
Expand Down Expand Up @@ -191,8 +192,10 @@ export class FastifyMetrics implements IFastifyMetrics {
return [];
}
return [
...(routeMetrics.overrides?.histogram?.registers ?? []),
...(routeMetrics.overrides?.summary?.registers ?? []),
...((routeMetrics.overrides?.histogram?.registers ??
[]) as Registry<PrometheusContentType>[]),
...((routeMetrics.overrides?.summary?.registers ??
[]) as Registry<PrometheusContentType>[]),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface IMetricsRouteContextConfig {
* @see {@link https://github.com/siimon/prom-client#default-metrics | prom-client} for extra options
*/
export interface IDefaultMetricsConfig
extends DefaultMetricsCollectorConfiguration {
extends DefaultMetricsCollectorConfiguration<'text/plain; version=0.0.4; charset=utf-8'> {
/**
* Enables collection of default prom-client metrics (e.g. node.js vitals like
* cpu, memory, etc.)
Expand Down

0 comments on commit bf31d38

Please sign in to comment.