From 1fcb0f9d22747801a9ec1d136126fe9934e5478a Mon Sep 17 00:00:00 2001 From: Igor Savin Date: Thu, 25 Apr 2024 01:29:11 +0300 Subject: [PATCH 1/3] Switch to CommonLogger interface --- .github/dependabot.yml | 1 + .github/workflows/ci.yml | 2 +- lib/plugins/requestContextProviderPlugin.ts | 8 ++-- package.json | 47 ++++++++++----------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 26f5983..aaf1982 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,5 +18,6 @@ updates: - dependency-name: '@typescript-eslint/parser' - dependency-name: '@types/node' - dependency-name: '@opentelemetry/*' + - dependency-name: '@prisma/instrumentation' labels: - 'skip-release' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed53e30..f8a6b52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x, 21.x] + node-version: [18.x, 20.x, 22.x] steps: - uses: actions/checkout@v4 diff --git a/lib/plugins/requestContextProviderPlugin.ts b/lib/plugins/requestContextProviderPlugin.ts index 5f32142..b6e06f7 100644 --- a/lib/plugins/requestContextProviderPlugin.ts +++ b/lib/plugins/requestContextProviderPlugin.ts @@ -1,4 +1,4 @@ -import { randomUUID } from 'crypto' +import { randomUUID } from 'node:crypto' import { requestContext } from '@fastify/request-context' import type { @@ -6,10 +6,10 @@ import type { FastifyRequest, FastifyInstance, HookHandlerDoneFunction, - FastifyServerOptions, - FastifyBaseLogger, + FastifyServerOptions } from 'fastify' import fp from 'fastify-plugin' +import { CommonLogger } from "@lokalise/node-core"; export const REQUEST_ID_STORE_KEY = 'request_id' @@ -21,7 +21,7 @@ declare module 'fastify' { } export interface BaseRequestContext { - logger: FastifyBaseLogger + logger: CommonLogger reqId: string } diff --git a/package.json b/package.json index addc4a9..6238cc8 100644 --- a/package.json +++ b/package.json @@ -42,17 +42,17 @@ "version": "auto-changelog -p && git add CHANGELOG.md" }, "dependencies": { - "@bugsnag/js": "^7.22.4", + "@bugsnag/js": "^7.22.7", "@lokalise/error-utils": "^1.1.0", "@opentelemetry/api": "1.8.0", - "@opentelemetry/exporter-trace-otlp-grpc": "~0.49.1", - "@opentelemetry/instrumentation": "~0.49.1", - "@opentelemetry/resources": "~1.22.0", - "@opentelemetry/sdk-trace-base": "~1.22.0", - "@opentelemetry/sdk-trace-node": "~1.22.0", - "@opentelemetry/semantic-conventions": "~1.22.0", - "@prisma/instrumentation": "^5.11.0", - "@splitsoftware/splitio": "^10.25.1", + "@opentelemetry/exporter-trace-otlp-grpc": "0.50.0", + "@opentelemetry/instrumentation": "0.50.0", + "@opentelemetry/resources": "1.23.0", + "@opentelemetry/sdk-trace-base": "1.23.0", + "@opentelemetry/sdk-trace-node": "1.23.0", + "@opentelemetry/semantic-conventions": "1.23.0", + "@prisma/instrumentation": "^5.13.0", + "@splitsoftware/splitio": "^10.25.2", "@amplitude/analytics-node": "^1.3.5", "fastify-metrics": "^11.0.0", "fastify-plugin": "^4.5.1", @@ -67,29 +67,28 @@ "zod": "^3.22.4" }, "devDependencies": { - "@fastify/request-context": "^5.0.0", - "@lokalise/node-core": "^9.13.0", + "@fastify/request-context": "^5.1.0", + "@lokalise/node-core": "^9.15.0", "@types/newrelic": "^9.14.3", - "@types/node": "^20.11.5", - "@amplitude/analytics-types": "^2.3.1", - "@typescript-eslint/eslint-plugin": "^7.3.1", - "@typescript-eslint/parser": "^7.3.1", - "@vitest/coverage-v8": "^1.2.1", + "@types/node": "^20.12.7", + "@amplitude/analytics-types": "^2.5.0", + "@typescript-eslint/eslint-plugin": "^7.7.1", + "@typescript-eslint/parser": "^7.7.1", + "@vitest/coverage-v8": "1.5.0", "auto-changelog": "^2.4.0", - "eslint": "^8.56.0", - "eslint-config-prettier": "^9.1.0", + "eslint": "^8.57.0", "eslint-plugin-import": "^2.29.1", - "eslint-plugin-vitest": "^0.3.20", - "fastify": "^4.25.2", + "eslint-plugin-vitest": "0.4.2-beta.5", + "fastify": "^4.26.2", "newrelic": "11.15.0", - "pino": "^8.17.2", + "pino": "^8.21.0", "pino-pretty": "^11.0.0", "prettier": "^3.2.5", "shx": "^0.3.4", "ts-node": "^10.9.1", - "typescript": "^5.4.2", - "vitest": "^1.2.1", - "zod": "^3.22.4" + "typescript": "^5.4.5", + "vitest": "1.5.0", + "zod": "^3.23.4" }, "engines": { "node": ">=18" From d82564644cce567fa3e64d82e884b5cda8bff5c3 Mon Sep 17 00:00:00 2001 From: Igor Savin Date: Thu, 25 Apr 2024 01:31:03 +0300 Subject: [PATCH 2/3] Pin vitest plugin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6238cc8..dda4afa 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "auto-changelog": "^2.4.0", "eslint": "^8.57.0", "eslint-plugin-import": "^2.29.1", - "eslint-plugin-vitest": "0.4.2-beta.5", + "eslint-plugin-vitest": "0.4.1", "fastify": "^4.26.2", "newrelic": "11.15.0", "pino": "^8.21.0", From d687ee22a829bb08641feda315b680db85d8dec8 Mon Sep 17 00:00:00 2001 From: Igor Savin Date: Thu, 25 Apr 2024 01:31:46 +0300 Subject: [PATCH 3/3] Fix linting --- .eslintrc.json | 3 +-- CHANGELOG.md | 4 ++-- lib/plugins/opentelemetry/spanProcessors.ts | 4 ---- lib/plugins/requestContextProviderPlugin.ts | 4 ++-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index f4f41c7..84da2a2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,8 +6,7 @@ "plugin:@typescript-eslint/strict", "plugin:vitest/recommended", "plugin:import/recommended", - "plugin:import/typescript", - "prettier" + "plugin:import/typescript" ], "plugins": ["@typescript-eslint", "vitest", "import"], "parser": "@typescript-eslint/parser", diff --git a/CHANGELOG.md b/CHANGELOG.md index 69e1567..bbfacad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,7 +46,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 27 February 2024 -- * export isZodError function [`#126`](https://github.com/lokalise/fastify-extras/pull/126) +- - export isZodError function [`#126`](https://github.com/lokalise/fastify-extras/pull/126) #### [v16.4.0](https://github.com/lokalise/fastify-extras/compare/v16.3.1...v16.4.0) @@ -153,7 +153,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 20 September 2023 -- * add FastifyReplyWithPayload type [`#82`](https://github.com/lokalise/fastify-extras/pull/82) +- - add FastifyReplyWithPayload type [`#82`](https://github.com/lokalise/fastify-extras/pull/82) - Bump @opentelemetry/exporter-trace-otlp-grpc from 0.41.2 to 0.43.0 [`#80`](https://github.com/lokalise/fastify-extras/pull/80) - Bump newrelic from 11.0.0 to 11.1.0 [`#79`](https://github.com/lokalise/fastify-extras/pull/79) diff --git a/lib/plugins/opentelemetry/spanProcessors.ts b/lib/plugins/opentelemetry/spanProcessors.ts index a040a32..4eba4ef 100644 --- a/lib/plugins/opentelemetry/spanProcessors.ts +++ b/lib/plugins/opentelemetry/spanProcessors.ts @@ -14,18 +14,14 @@ import { REQUEST_ID_STORE_KEY } from '../requestContextProviderPlugin' */ export class LokaliseSimpleSpanProcessor extends SimpleSpanProcessor { onStart(span: Span) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const requestId = requestContext.get(REQUEST_ID_STORE_KEY) - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument span.setAttribute(REQUEST_ID_STORE_KEY, requestId) } } export class LokaliseBatchSpanProcessor extends BatchSpanProcessor { onStart(span: Span) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const requestId = requestContext.get(REQUEST_ID_STORE_KEY) - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument span.setAttribute(REQUEST_ID_STORE_KEY, requestId) } } diff --git a/lib/plugins/requestContextProviderPlugin.ts b/lib/plugins/requestContextProviderPlugin.ts index b6e06f7..6bcb853 100644 --- a/lib/plugins/requestContextProviderPlugin.ts +++ b/lib/plugins/requestContextProviderPlugin.ts @@ -1,15 +1,15 @@ import { randomUUID } from 'node:crypto' import { requestContext } from '@fastify/request-context' +import type { CommonLogger } from '@lokalise/node-core' import type { FastifyReply, FastifyRequest, FastifyInstance, HookHandlerDoneFunction, - FastifyServerOptions + FastifyServerOptions, } from 'fastify' import fp from 'fastify-plugin' -import { CommonLogger } from "@lokalise/node-core"; export const REQUEST_ID_STORE_KEY = 'request_id'