Skip to content

Commit a563b18

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

14 files changed

Lines changed: 1390 additions & 14 deletions

File tree

.oxlintrc.base.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@
156156
"**/integrations/tracing/tedious/vendored/**/*.ts",
157157
"**/integrations/tracing/hapi/vendored/**/*.ts",
158158
"**/integrations/tracing/mongoose/vendored/**/*.ts",
159-
"**/integrations/tracing/amqplib/vendored/**/*.ts"
159+
"**/integrations/tracing/amqplib/vendored/**/*.ts",
160+
"**/integrations/tracing/graphql/vendored/**/*.ts"
160161
],
161162
"rules": {
162163
"typescript/no-explicit-any": "off"

packages/node/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"@opentelemetry/api": "^1.9.1",
6969
"@opentelemetry/core": "^2.6.1",
7070
"@opentelemetry/instrumentation": "^0.214.0",
71-
"@opentelemetry/instrumentation-graphql": "0.62.0",
7271
"@opentelemetry/instrumentation-http": "0.214.0",
7372
"@opentelemetry/sql-common": "^0.41.2",
7473
"@opentelemetry/instrumentation-pg": "0.66.0",

packages/node/src/integrations/tracing/dataloader/vendored/dataloader-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Simplified types inlined from dataloader.
33
*/
44

5-
declare class DataLoader<K, V, C = K> {
5+
declare class DataLoader<K, V, _C = K> {
66
constructor(batchLoadFn: DataLoader.BatchLoadFn<K, V>, options?: any);
77
load(key: K): Promise<V>;
88
loadMany(keys: ArrayLike<K>): Promise<Array<V | Error>>;

packages/node/src/integrations/tracing/graphql.ts renamed to packages/node/src/integrations/tracing/graphql/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { AttributeValue } from '@opentelemetry/api';
22
import { SpanStatusCode } from '@opentelemetry/api';
3-
import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql';
3+
import { GraphQLInstrumentation } from './vendored/instrumentation';
44
import type { IntegrationFn } from '@sentry/core';
55
import { defineIntegration, getRootSpan, spanToJSON } from '@sentry/core';
66
import { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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-graphql
18+
* - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0
19+
*/
20+
/* eslint-disable */
21+
22+
export enum AllowedOperationTypes {
23+
QUERY = 'query',
24+
MUTATION = 'mutation',
25+
SUBSCRIPTION = 'subscription',
26+
}
27+
28+
export enum TokenKind {
29+
SOF = '<SOF>',
30+
EOF = '<EOF>',
31+
BANG = '!',
32+
DOLLAR = '$',
33+
AMP = '&',
34+
PAREN_L = '(',
35+
PAREN_R = ')',
36+
SPREAD = '...',
37+
COLON = ':',
38+
EQUALS = '=',
39+
AT = '@',
40+
BRACKET_L = '[',
41+
BRACKET_R = ']',
42+
BRACE_L = '{',
43+
PIPE = '|',
44+
BRACE_R = '}',
45+
NAME = 'Name',
46+
INT = 'Int',
47+
FLOAT = 'Float',
48+
STRING = 'String',
49+
BLOCK_STRING = 'BlockString',
50+
COMMENT = 'Comment',
51+
}
52+
53+
export enum SpanNames {
54+
EXECUTE = 'graphql.execute',
55+
PARSE = 'graphql.parse',
56+
RESOLVE = 'graphql.resolve',
57+
VALIDATE = 'graphql.validate',
58+
SCHEMA_VALIDATE = 'graphql.validateSchema',
59+
SCHEMA_PARSE = 'graphql.parseSchema',
60+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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-graphql
18+
* - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0
19+
*/
20+
/* eslint-disable */
21+
22+
export enum AttributeNames {
23+
SOURCE = 'graphql.source',
24+
FIELD_NAME = 'graphql.field.name',
25+
FIELD_PATH = 'graphql.field.path',
26+
FIELD_TYPE = 'graphql.field.type',
27+
PARENT_NAME = 'graphql.parent.name',
28+
OPERATION_TYPE = 'graphql.operation.type',
29+
OPERATION_NAME = 'graphql.operation.name',
30+
VARIABLES = 'graphql.variables.',
31+
ERROR_VALIDATION_NAME = 'graphql.validation.error',
32+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/*
2+
* Simplified types inlined from the `graphql` package.
3+
* Only includes members accessed by this instrumentation.
4+
*/
5+
6+
export type PromiseOrValue<T> = T | Promise<T>;
7+
8+
export type Maybe<T> = null | undefined | T;
9+
10+
export interface Location {
11+
start: number;
12+
end: number;
13+
startToken: Token;
14+
source: Source;
15+
[key: string]: any;
16+
}
17+
18+
export interface Token {
19+
kind: string;
20+
start: number;
21+
end: number;
22+
line: number;
23+
column: number;
24+
value: string;
25+
prev: Token | null;
26+
next: Token | null;
27+
[key: string]: any;
28+
}
29+
30+
export interface Source {
31+
body: string;
32+
name: string;
33+
locationOffset: Location;
34+
[key: string]: any;
35+
}
36+
37+
export interface DocumentNode {
38+
kind: string;
39+
definitions: ReadonlyArray<DefinitionNode>;
40+
loc?: Location;
41+
[key: string]: any;
42+
}
43+
44+
export interface DefinitionNode {
45+
kind: string;
46+
loc?: Location;
47+
[key: string]: any;
48+
}
49+
50+
export interface OperationDefinitionNode extends DefinitionNode {
51+
operation: string;
52+
name?: { kind: string; value: string; loc?: Location };
53+
[key: string]: any;
54+
}
55+
56+
export interface ParseOptions {
57+
noLocation?: boolean;
58+
[key: string]: any;
59+
}
60+
61+
export interface ExecutionArgs {
62+
schema: GraphQLSchema;
63+
document: DocumentNode;
64+
rootValue?: any;
65+
contextValue?: any;
66+
variableValues?: Maybe<{ [key: string]: any }>;
67+
operationName?: Maybe<string>;
68+
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
69+
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
70+
[key: string]: any;
71+
}
72+
73+
export interface ExecutionResult {
74+
errors?: ReadonlyArray<GraphQLError>;
75+
data?: Record<string, any> | null;
76+
[key: string]: any;
77+
}
78+
79+
export interface GraphQLError {
80+
message: string;
81+
locations?: ReadonlyArray<{ line: number; column: number }>;
82+
path?: ReadonlyArray<string | number>;
83+
[key: string]: any;
84+
}
85+
86+
export interface GraphQLSchema {
87+
getQueryType(): GraphQLObjectType | undefined | null;
88+
getMutationType(): GraphQLObjectType | undefined | null;
89+
[key: string]: any;
90+
}
91+
92+
export interface GraphQLObjectType {
93+
name: string;
94+
getFields(): { [key: string]: GraphQLField };
95+
[key: string]: any;
96+
}
97+
98+
export interface GraphQLField {
99+
name: string;
100+
type: GraphQLOutputType;
101+
resolve?: GraphQLFieldResolver<any, any>;
102+
[key: string]: any;
103+
}
104+
105+
export type GraphQLOutputType = GraphQLNamedOutputType | GraphQLWrappingType;
106+
107+
interface GraphQLNamedOutputType {
108+
name: string;
109+
[key: string]: any;
110+
}
111+
112+
interface GraphQLWrappingType {
113+
ofType: GraphQLOutputType;
114+
[key: string]: any;
115+
}
116+
117+
export interface GraphQLUnionType {
118+
name: string;
119+
getTypes(): ReadonlyArray<GraphQLObjectType>;
120+
[key: string]: any;
121+
}
122+
123+
export type GraphQLType = GraphQLOutputType | GraphQLUnionType;
124+
125+
export type GraphQLFieldResolver<TSource, TContext, TArgs = any> = (
126+
source: TSource,
127+
args: TArgs,
128+
context: TContext,
129+
info: GraphQLResolveInfo,
130+
) => any;
131+
132+
export type GraphQLTypeResolver<TSource, TContext> = (
133+
value: TSource,
134+
context: TContext,
135+
info: GraphQLResolveInfo,
136+
abstractType: any,
137+
) => any;
138+
139+
export interface GraphQLResolveInfo {
140+
fieldName: string;
141+
fieldNodes: ReadonlyArray<{ kind: string; loc?: Location; [key: string]: any }>;
142+
returnType: { toString(): string; [key: string]: any };
143+
parentType: { name: string; [key: string]: any };
144+
path: any;
145+
[key: string]: any;
146+
}
147+
148+
export type ValidationRule = any;
149+
150+
export interface TypeInfo {
151+
[key: string]: any;
152+
}

0 commit comments

Comments
 (0)