Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update prom-client to v15.1.0 #101

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 2 additions & 3 deletions 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 Expand Up @@ -133,8 +133,7 @@ See for details [docs](docs/api/fastify-metrics.imetricspluginoptions.md)
| [endpoint?](./docs/api/fastify-metrics.imetricspluginoptions.endpoint.md) | string \| null \| [`Fastify.RouteOptions`](https://www.fastify.io/docs/api/latest/Reference/Routes/#routes-options) | `'/metrics'` |
| [name?](./docs/api/fastify-metrics.imetricspluginoptions.name.md) | string | `'metrics'` |
| [routeMetrics?](./docs/api/fastify-metrics.imetricspluginoptions.routemetrics.md) | [IRouteMetricsConfig](./docs/api/fastify-metrics.iroutemetricsconfig.md) | `{ enabled: true }` |
| [promClient?](./docs/api/fastify-metrics.imetricspluginoptions.promclient.md) | `prom-client` instance \| null | `null` |

| [promClient?](./docs/api/fastify-metrics.imetricspluginoptions.promclient.md) | `prom-client` instance \| null | `null` |

#### Route metrics

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
3 changes: 2 additions & 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 All @@ -51,6 +51,7 @@ export interface IMetricsPluginOptions {
defaultMetrics: IDefaultMetricsConfig;
endpoint: string | null | RouteOptions;
name: string;
promClient: typeof client | null;
routeMetrics: IRouteMetricsConfig;
}

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',
SkeLLLa marked this conversation as resolved.
Show resolved Hide resolved
'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'> {
SkeLLLa marked this conversation as resolved.
Show resolved Hide resolved
/**
* Enables collection of default prom-client metrics (e.g. node.js vitals like
* cpu, memory, etc.)
Expand Down
Loading