Skip to content

Commit f53c493

Browse files
nicohrubecclaude
andauthored
ref(node): Vendor hapi instrumentation (#21057)
Vendors `@opentelemetry/instrumentation-hapi` (v0.64.0) into the SDK with no logic changes. Types from `@hapi/hapi` are inlined as simplified interfaces to avoid requiring the package as a dependency. Closes #20166 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cb6da8e commit f53c493

10 files changed

Lines changed: 721 additions & 12 deletions

File tree

.oxlintrc.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
"**/nestjs/src/integrations/vendored/**/*.ts",
155155
"**/integrations/tracing/kafka/vendored/**/*.ts",
156156
"**/integrations/tracing/tedious/vendored/**/*.ts",
157+
"**/integrations/tracing/hapi/vendored/**/*.ts",
157158
"**/integrations/tracing/mongoose/vendored/**/*.ts",
158159
"**/integrations/tracing/amqplib/vendored/**/*.ts"
159160
],

packages/node/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"@opentelemetry/core": "^2.6.1",
7070
"@opentelemetry/instrumentation": "^0.214.0",
7171
"@opentelemetry/instrumentation-graphql": "0.62.0",
72-
"@opentelemetry/instrumentation-hapi": "0.60.0",
7372
"@opentelemetry/instrumentation-http": "0.214.0",
7473
"@opentelemetry/sql-common": "^0.41.2",
7574
"@opentelemetry/instrumentation-pg": "0.66.0",

packages/node/src/integrations/tracing/hapi/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HapiInstrumentation } from '@opentelemetry/instrumentation-hapi';
1+
import { HapiInstrumentation } from './vendored/instrumentation';
22
import type { IntegrationFn, Span } from '@sentry/core';
33
import {
44
captureException,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* NOTICE from the Sentry authors:
17+
* - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-hapi
18+
* - Upstream version: @opentelemetry/instrumentation-hapi@0.64.0
19+
*/
20+
/* eslint-disable */
21+
22+
export enum AttributeNames {
23+
HAPI_TYPE = 'hapi.type',
24+
PLUGIN_NAME = 'hapi.plugin.name',
25+
EXT_TYPE = 'server.ext.type',
26+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Simplified type definitions vendored from @types/hapi__hapi.
3+
* Only includes the types actually accessed by the instrumentation.
4+
*/
5+
/* eslint-disable */
6+
7+
export type ServerOptions = Record<string, any>;
8+
9+
export declare function server(options?: ServerOptions): Server;
10+
export declare function Server(options?: ServerOptions): Server;
11+
12+
export type ServerRequestExtType =
13+
| 'onPreAuth'
14+
| 'onCredentials'
15+
| 'onPostAuth'
16+
| 'onPreHandler'
17+
| 'onPostHandler'
18+
| 'onPreResponse'
19+
| 'onRequest';
20+
21+
export namespace Lifecycle {
22+
export type Method = (request: any, h: any, err?: Error) => ReturnValue;
23+
export type ReturnValue = any;
24+
export type FailAction = 'error' | 'log' | 'ignore' | Method;
25+
}
26+
27+
export interface ServerRoute<T = any> {
28+
path: string;
29+
method: string;
30+
handler?: Lifecycle.Method | T;
31+
options?: ((server: Server) => ServerRouteOptions) | ServerRouteOptions;
32+
[key: string]: any;
33+
}
34+
35+
interface ServerRouteOptions {
36+
handler?: Lifecycle.Method | any;
37+
[key: string]: any;
38+
}
39+
40+
export interface Server {
41+
route: (...args: any[]) => any;
42+
ext: (...args: any[]) => any;
43+
register: (...args: any[]) => any;
44+
[key: string]: any;
45+
}
46+
47+
export interface Plugin<T, _V = void> {
48+
register: (server: Server, options: T) => void | Promise<void>;
49+
name?: string;
50+
pkg?: { name: string; [key: string]: any };
51+
[key: string]: any;
52+
}
53+
54+
export interface PluginNameVersion {
55+
name: string;
56+
[key: string]: any;
57+
}
58+
59+
export interface PluginPackage {
60+
pkg: { name: string; [key: string]: any };
61+
[key: string]: any;
62+
}
63+
64+
export interface ServerRegisterPluginObject<T> {
65+
plugin: Plugin<T, void> | { plugin: Plugin<T, void>; [key: string]: any };
66+
[key: string]: any;
67+
}
68+
69+
export interface ServerRegisterOptions {
70+
[key: string]: any;
71+
}
72+
73+
export interface ServerExtEventsObject {
74+
type: string;
75+
[key: string]: any;
76+
}
77+
78+
export interface ServerExtEventsRequestObject {
79+
type: ServerRequestExtType;
80+
method: Lifecycle.Method;
81+
[key: string]: any;
82+
}
83+
84+
export interface ServerExtOptions {
85+
[key: string]: any;
86+
}

0 commit comments

Comments
 (0)