Skip to content

Commit cba6016

Browse files
authored
feat(node): Vendor in @fastify/otel (#16328)
Resolves: #16309 I tried to make as few modifications as possible for easier updates from the original implementation in the future. - Converted `require`s and `module.export`s to `import`s and `exports` - Created a local `eslint` configuration - Hard-coded `name` and `version` to the vendored version instead of reading from `package.json`
1 parent 2054753 commit cba6016

File tree

6 files changed

+534
-13
lines changed

6 files changed

+534
-13
lines changed

packages/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"access": "public"
6666
},
6767
"dependencies": {
68-
"@fastify/otel": "https://codeload.github.com/getsentry/fastify-otel/tar.gz/ae3088d65e286bdc94ac5d722573537d6a6671bb",
6968
"@opentelemetry/api": "^1.9.0",
7069
"@opentelemetry/context-async-hooks": "^1.30.1",
7170
"@opentelemetry/core": "^1.30.1",
@@ -98,7 +97,8 @@
9897
"@prisma/instrumentation": "6.7.0",
9998
"@sentry/core": "9.20.0",
10099
"@sentry/opentelemetry": "9.20.0",
101-
"import-in-the-middle": "^1.13.1"
100+
"import-in-the-middle": "^1.13.1",
101+
"minimatch": "^9.0.0"
102102
},
103103
"devDependencies": {
104104
"@types/node": "^18.19.1"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
},
5+
parserOptions: {
6+
sourceType: 'module',
7+
ecmaVersion: 2020,
8+
},
9+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
2+
/// <reference types="node" />
3+
4+
import type { InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
5+
import { InstrumentationBase } from '@opentelemetry/instrumentation';
6+
import type { FastifyPluginCallback } from 'fastify';
7+
import type { FastifyOtelInstrumentationOpts, FastifyOtelOptions, FastifyOtelRequestContext } from './types';
8+
9+
declare module 'fastify' {
10+
interface FastifyRequest {
11+
opentelemetry(): FastifyOtelRequestContext;
12+
}
13+
}
14+
15+
declare class FastifyOtelInstrumentation<
16+
Config extends FastifyOtelInstrumentationOpts = FastifyOtelInstrumentationOpts,
17+
> extends InstrumentationBase<Config> {
18+
servername: string;
19+
constructor(config?: FastifyOtelInstrumentationOpts);
20+
init(): InstrumentationNodeModuleDefinition[];
21+
plugin(): FastifyPluginCallback<FastifyOtelOptions>;
22+
}
23+
24+
declare namespace exported {
25+
export type { FastifyOtelInstrumentationOpts };
26+
export { FastifyOtelInstrumentation };
27+
}
28+
29+
export = exported;

0 commit comments

Comments
 (0)