Skip to content

Commit bd9f4cc

Browse files
committed
fix(node): Ensure graphql options are correct when preloading
Noticed this by chance, due to the way `generateInstrumentOnce` works, we need to pass in the fully formed config.
1 parent 48b3a78 commit bd9f4cc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/node/src/integrations/tracing/graphql.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const INTEGRATION_NAME = 'Graphql';
4040
export const instrumentGraphql = generateInstrumentOnce<GraphqlOptions>(
4141
INTEGRATION_NAME,
4242
(_options: GraphqlOptions = {}) => {
43+
// We set default values here, which are used in the case that this is preloaded
44+
// In that case, no options are passed in, and we want to use the defaults
4345
const options = {
4446
ignoreResolveSpans: true,
4547
ignoreTrivialResolveSpans: true,
@@ -85,10 +87,20 @@ export const instrumentGraphql = generateInstrumentOnce<GraphqlOptions>(
8587
},
8688
);
8789

88-
const _graphqlIntegration = ((options: GraphqlOptions = {}) => {
90+
const _graphqlIntegration = ((_options: GraphqlOptions = {}) => {
8991
return {
9092
name: INTEGRATION_NAME,
9193
setupOnce() {
94+
// We set defaults here, too, because otherwise we'd update the instrumentation config
95+
// to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`
96+
// when being called the second time
97+
const options = {
98+
ignoreResolveSpans: true,
99+
ignoreTrivialResolveSpans: true,
100+
useOperationNameForRootSpan: true,
101+
..._options,
102+
};
103+
92104
instrumentGraphql(options);
93105
},
94106
};

0 commit comments

Comments
 (0)