-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): Ensure graphql options are correct when preloading (#13769)
Noticed this by chance, due to the way `generateInstrumentOnce` works, we need to pass in the fully formed config.
- Loading branch information
Showing
3 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { GraphQLInstrumentation } from '@opentelemetry/instrumentation-graphql'; | ||
import { graphqlIntegration, instrumentGraphql } from '../../../src/integrations/tracing/graphql'; | ||
import { INSTRUMENTED } from '../../../src/otel/instrument'; | ||
|
||
jest.mock('@opentelemetry/instrumentation-graphql'); | ||
|
||
describe('GraphQL', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
delete INSTRUMENTED.Graphql; | ||
|
||
(GraphQLInstrumentation as unknown as jest.SpyInstance).mockImplementation(() => { | ||
return { | ||
setTracerProvider: () => undefined, | ||
setMeterProvider: () => undefined, | ||
getConfig: () => ({}), | ||
setConfig: () => ({}), | ||
enable: () => undefined, | ||
}; | ||
}); | ||
}); | ||
|
||
it('defaults are correct for instrumentGraphql', () => { | ||
instrumentGraphql({ ignoreTrivialResolveSpans: false }); | ||
|
||
expect(GraphQLInstrumentation).toHaveBeenCalledTimes(1); | ||
expect(GraphQLInstrumentation).toHaveBeenCalledWith({ | ||
ignoreResolveSpans: true, | ||
ignoreTrivialResolveSpans: false, | ||
useOperationNameForRootSpan: true, | ||
responseHook: expect.any(Function), | ||
}); | ||
}); | ||
|
||
it('defaults are correct for _graphqlIntegration', () => { | ||
graphqlIntegration({ ignoreTrivialResolveSpans: false }).setupOnce!(); | ||
|
||
expect(GraphQLInstrumentation).toHaveBeenCalledTimes(1); | ||
expect(GraphQLInstrumentation).toHaveBeenCalledWith({ | ||
ignoreResolveSpans: true, | ||
ignoreTrivialResolveSpans: false, | ||
useOperationNameForRootSpan: true, | ||
responseHook: expect.any(Function), | ||
}); | ||
}); | ||
}); |