Skip to content

Commit 2ccd7c6

Browse files
committed
Merge remote-tracking branch 'origin/develop' into nh/vendor-mongodb-instrumentation
2 parents e734f04 + 9d35814 commit 2ccd7c6

93 files changed

Lines changed: 2703 additions & 2534 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.oxlintrc.base.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,12 @@
141141
}
142142
},
143143
{
144-
"files": ["**/integrations/tracing/dataloader/vendored/**/*.ts"],
145-
"rules": {
146-
"typescript/no-explicit-any": "off"
147-
}
148-
},
149-
{
150-
"files": ["**/integrations/tracing/genericPool/vendored/**/*.ts"],
144+
"files": [
145+
"**/integrations/tracing/dataloader/vendored/**/*.ts",
146+
"**/integrations/tracing/genericPool/vendored/**/*.ts",
147+
"**/integrations/fs/vendored/**/*.ts",
148+
"**/integrations/tracing/knex/vendored/**/*.ts"
149+
],
151150
"rules": {
152151
"typescript/no-explicit-any": "off"
153152
}

dev-packages/node-integration-tests/suites/tracing/amqplib/scenario.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ const QUEUE_OPTIONS = {
3232

3333
await channel.close();
3434
await connection.close();
35-
36-
// Stop the process from exiting before the transaction is sent
37-
setInterval(() => {}, 1000);
3835
})();
3936

4037
async function connectToRabbitMQ() {

dev-packages/node-integration-tests/suites/tracing/apollo-graphql/apollo-server.js renamed to dev-packages/node-integration-tests/suites/tracing/apollo-graphql/apollo-server.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const { ApolloServer } = require('@apollo/server');
2-
const gql = require('graphql-tag');
3-
const Sentry = require('@sentry/node');
1+
import { ApolloServer } from '@apollo/server';
2+
import * as Sentry from '@sentry/node';
3+
import gql from 'graphql-tag';
44

5-
module.exports = () => {
5+
export function createApolloServer() {
66
return Sentry.startSpan({ name: 'Test Server Start' }, () => {
77
return new ApolloServer({
88
typeDefs: gql`
@@ -32,4 +32,4 @@ module.exports = () => {
3232
introspection: false,
3333
});
3434
});
35-
};
35+
}

dev-packages/node-integration-tests/suites/tracing/postgresjs/instrument.cjs renamed to dev-packages/node-integration-tests/suites/tracing/apollo-graphql/instrument.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const Sentry = require('@sentry/node');
2-
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
33

44
Sentry.init({
55
dsn: 'https://public@dsn.ingest.sentry.io/1337',

dev-packages/node-integration-tests/suites/tracing/apollo-graphql/scenario-error.js renamed to dev-packages/node-integration-tests/suites/tracing/apollo-graphql/scenario-error.mjs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
const Sentry = require('@sentry/node');
2-
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
3-
4-
Sentry.init({
5-
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6-
release: '1.0',
7-
tracesSampleRate: 1.0,
8-
transport: loggingTransport,
9-
});
10-
11-
// Stop the process from exiting before the transaction is sent
12-
setInterval(() => {}, 1000);
1+
import * as Sentry from '@sentry/node';
2+
import gql from 'graphql-tag';
133

144
async function run() {
15-
const gql = require('graphql-tag');
16-
const server = require('./apollo-server')();
5+
const { createApolloServer } = await import('./apollo-server.mjs');
6+
const server = createApolloServer();
177

188
await Sentry.startSpan(
199
{

dev-packages/node-integration-tests/suites/tracing/apollo-graphql/scenario-mutation.js renamed to dev-packages/node-integration-tests/suites/tracing/apollo-graphql/scenario-mutation.mjs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
const Sentry = require('@sentry/node');
2-
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
3-
4-
Sentry.init({
5-
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6-
release: '1.0',
7-
tracesSampleRate: 1.0,
8-
transport: loggingTransport,
9-
});
10-
11-
// Stop the process from exiting before the transaction is sent
12-
setInterval(() => {}, 1000);
1+
import * as Sentry from '@sentry/node';
2+
import gql from 'graphql-tag';
133

144
async function run() {
15-
const gql = require('graphql-tag');
16-
const server = require('./apollo-server')();
5+
const { createApolloServer } = await import('./apollo-server.mjs');
6+
const server = createApolloServer();
177

188
await Sentry.startSpan(
199
{

dev-packages/node-integration-tests/suites/tracing/apollo-graphql/scenario-query.js renamed to dev-packages/node-integration-tests/suites/tracing/apollo-graphql/scenario-query.mjs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
const Sentry = require('@sentry/node');
2-
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
3-
4-
Sentry.init({
5-
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6-
release: '1.0',
7-
tracesSampleRate: 1.0,
8-
transport: loggingTransport,
9-
});
10-
11-
// Stop the process from exiting before the transaction is sent
12-
setInterval(() => {}, 1000);
1+
import * as Sentry from '@sentry/node';
132

143
async function run() {
15-
const server = require('./apollo-server')();
4+
const { createApolloServer } = await import('./apollo-server.mjs');
5+
const server = createApolloServer();
166

177
await Sentry.startSpan(
188
{

dev-packages/node-integration-tests/suites/tracing/apollo-graphql/test.ts

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import { describe, expect, test } from 'vitest';
2-
import { createRunner } from '../../../utils/runner';
1+
import { afterAll, describe, expect } from 'vitest';
2+
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
33

44
// Server start transaction (Apollo Server v5 no longer runs introspection query on start)
55
const EXPECTED_START_SERVER_TRANSACTION = {
66
transaction: 'Test Server Start',
77
};
88

99
describe('GraphQL/Apollo Tests', () => {
10-
test('should instrument GraphQL queries used from Apollo Server.', async () => {
10+
afterAll(() => {
11+
cleanupChildProcesses();
12+
});
13+
14+
describe('query', () => {
1115
const EXPECTED_TRANSACTION = {
1216
transaction: 'Test Transaction (query)',
1317
spans: expect.arrayContaining([
@@ -24,14 +28,24 @@ describe('GraphQL/Apollo Tests', () => {
2428
]),
2529
};
2630

27-
await createRunner(__dirname, 'scenario-query.js')
28-
.expect({ transaction: EXPECTED_START_SERVER_TRANSACTION })
29-
.expect({ transaction: EXPECTED_TRANSACTION })
30-
.start()
31-
.completed();
31+
createEsmAndCjsTests(
32+
__dirname,
33+
'scenario-query.mjs',
34+
'instrument.mjs',
35+
(createTestRunner, test) => {
36+
test('should instrument GraphQL queries used from Apollo Server.', async () => {
37+
await createTestRunner()
38+
.expect({ transaction: EXPECTED_START_SERVER_TRANSACTION })
39+
.expect({ transaction: EXPECTED_TRANSACTION })
40+
.start()
41+
.completed();
42+
});
43+
},
44+
{ copyPaths: ['apollo-server.mjs'] },
45+
);
3246
});
3347

34-
test('should instrument GraphQL mutations used from Apollo Server.', async () => {
48+
describe('mutation', () => {
3549
const EXPECTED_TRANSACTION = {
3650
transaction: 'Test Transaction (mutation Mutation)',
3751
spans: expect.arrayContaining([
@@ -49,14 +63,24 @@ describe('GraphQL/Apollo Tests', () => {
4963
]),
5064
};
5165

52-
await createRunner(__dirname, 'scenario-mutation.js')
53-
.expect({ transaction: EXPECTED_START_SERVER_TRANSACTION })
54-
.expect({ transaction: EXPECTED_TRANSACTION })
55-
.start()
56-
.completed();
66+
createEsmAndCjsTests(
67+
__dirname,
68+
'scenario-mutation.mjs',
69+
'instrument.mjs',
70+
(createTestRunner, test) => {
71+
test('should instrument GraphQL mutations used from Apollo Server.', async () => {
72+
await createTestRunner()
73+
.expect({ transaction: EXPECTED_START_SERVER_TRANSACTION })
74+
.expect({ transaction: EXPECTED_TRANSACTION })
75+
.start()
76+
.completed();
77+
});
78+
},
79+
{ copyPaths: ['apollo-server.mjs'] },
80+
);
5781
});
5882

59-
test('should handle GraphQL errors.', async () => {
83+
describe('error', () => {
6084
const EXPECTED_TRANSACTION = {
6185
transaction: 'Test Transaction (mutation Mutation)',
6286
spans: expect.arrayContaining([
@@ -74,10 +98,20 @@ describe('GraphQL/Apollo Tests', () => {
7498
]),
7599
};
76100

77-
await createRunner(__dirname, 'scenario-error.js')
78-
.expect({ transaction: EXPECTED_START_SERVER_TRANSACTION })
79-
.expect({ transaction: EXPECTED_TRANSACTION })
80-
.start()
81-
.completed();
101+
createEsmAndCjsTests(
102+
__dirname,
103+
'scenario-error.mjs',
104+
'instrument.mjs',
105+
(createTestRunner, test) => {
106+
test('should handle GraphQL errors.', async () => {
107+
await createTestRunner()
108+
.expect({ transaction: EXPECTED_START_SERVER_TRANSACTION })
109+
.expect({ transaction: EXPECTED_TRANSACTION })
110+
.start()
111+
.completed();
112+
});
113+
},
114+
{ copyPaths: ['apollo-server.mjs'] },
115+
);
82116
});
83117
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
Sentry.init({
5+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6+
release: '1.0',
7+
tracesSampleRate: 1.0,
8+
integrations: [Sentry.graphqlIntegration({ useOperationNameForRootSpan: true })],
9+
transport: loggingTransport,
10+
});

dev-packages/node-integration-tests/suites/tracing/apollo-graphql/useOperationNameForRootSpan/scenario-invalid-root-span.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)