Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
doc: '{"title":"Rick and Morty"}',
'db.system': 'mongodb',
},
description: 'insertOne',
op: 'db',
Expand All @@ -44,6 +45,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"Back to the Future"}',
'db.system': 'mongodb',
},
description: 'findOne',
op: 'db',
Expand All @@ -55,6 +57,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
namespace: 'admin.movies',
filter: '{"title":"Back to the Future"}',
update: '{"$set":{"title":"South Park"}}',
'db.system': 'mongodb',
},
description: 'updateOne',
op: 'db',
Expand All @@ -65,6 +68,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
},
description: 'findOne',
op: 'db',
Expand All @@ -75,6 +79,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
},
description: 'find',
op: 'db',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ test('should auto-instrument `mysql` package.', async () => {
{
description: 'SELECT 1 + 1 AS solution',
op: 'db',
data: {
'db.system': 'mysql',
},
},

{
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'mysql',
},
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,23 @@ test('should auto-instrument `pg` package.', async () => {
{
description: 'SELECT * FROM foo where bar ilike "baz%"',
op: 'db',
data: {
'db.system': 'postgresql',
},
},
{
description: 'SELECT * FROM bazz',
op: 'db',
data: {
'db.system': 'postgresql',
},
},
{
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'postgresql',
},
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ conditionalTest({ min: 12 })('Prisma ORM Integration', () => {
assertSentryTransaction(envelope[2], {
transaction: 'Test Transaction',
spans: [
{ description: 'User create', op: 'db.sql.prisma' },
{ description: 'User findMany', op: 'db.sql.prisma' },
{ description: 'User deleteMany', op: 'db.sql.prisma' },
{ description: 'User create', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
{ description: 'User findMany', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
{ description: 'User deleteMany', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
],
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
doc: '{"title":"Rick and Morty"}',
'db.system': 'mongodb',
},
description: 'insertOne',
op: 'db',
Expand All @@ -44,6 +45,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"Back to the Future"}',
'db.system': 'mongodb',
},
description: 'findOne',
op: 'db',
Expand All @@ -55,6 +57,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
namespace: 'admin.movies',
filter: '{"title":"Back to the Future"}',
update: '{"$set":{"title":"South Park"}}',
'db.system': 'mongodb',
},
description: 'updateOne',
op: 'db',
Expand All @@ -65,6 +68,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
},
description: 'findOne',
op: 'db',
Expand All @@ -75,6 +79,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
},
description: 'find',
op: 'db',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ test('should auto-instrument `mysql` package.', async () => {
{
description: 'SELECT 1 + 1 AS solution',
op: 'db',
data: {
'db.system': 'mysql',
},
},

{
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'mysql',
},
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,23 @@ test('should auto-instrument `pg` package.', async () => {
{
description: 'SELECT * FROM foo where bar ilike "baz%"',
op: 'db',
data: {
'db.system': 'postgresql',
},
},
{
description: 'SELECT * FROM bazz',
op: 'db',
data: {
'db.system': 'postgresql',
},
},
{
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'postgresql',
},
},
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ conditionalTest({ min: 12 })('Prisma ORM Integration', () => {
assertSentryTransaction(envelope[2], {
transaction: 'Test Transaction',
spans: [
{ description: 'User create', op: 'db.sql.prisma' },
{ description: 'User findMany', op: 'db.sql.prisma' },
{ description: 'User deleteMany', op: 'db.sql.prisma' },
{ description: 'User create', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
{ description: 'User findMany', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
{ description: 'User deleteMany', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
],
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing-internal/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function _autoloadDatabaseIntegrations(): void {
const integration = dynamicRequire(module, './node/integrations/mongo') as {
Mongo: IntegrationClass<Integration>;
};
return new integration.Mongo({ mongoose: true });
return new integration.Mongo();
},
mysql() {
const integration = dynamicRequire(module, './node/integrations/mysql') as {
Expand Down
1 change: 1 addition & 0 deletions packages/tracing-internal/src/node/integrations/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export class Mongo implements LazyLoadedIntegration<MongoModule> {
collectionName: collection.collectionName,
dbName: collection.dbName,
namespace: collection.namespace,
'db.system': 'mongodb',
};
const spanContext: SpanContext = {
op: 'db',
Expand Down
3 changes: 3 additions & 0 deletions packages/tracing-internal/src/node/integrations/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export class Mysql implements LazyLoadedIntegration<MysqlConnection> {
const span = parentSpan?.startChild({
description: typeof options === 'string' ? options : (options as { sql: string }).sql,
op: 'db',
data: {
'db.system': 'mysql',
},
});

if (typeof callback === 'function') {
Expand Down
3 changes: 3 additions & 0 deletions packages/tracing-internal/src/node/integrations/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export class Postgres implements LazyLoadedIntegration<PGModule> {
const span = parentSpan?.startChild({
description: typeof config === 'string' ? config : (config as { text: string }).text,
op: 'db',
data: {
'db.system': 'postgresql',
},
});

if (typeof callback === 'function') {
Expand Down
5 changes: 4 additions & 1 deletion packages/tracing-internal/src/node/integrations/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export class Prisma implements Integration {
this._client.$use((params, next: (params: PrismaMiddlewareParams) => Promise<unknown>) => {
const action = params.action;
const model = params.model;
return trace({ name: model ? `${model} ${action}` : action, op: 'db.sql.prisma' }, () => next(params));
return trace(
{ name: model ? `${model} ${action}` : action, op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
() => next(params),
);
});
}
}
3 changes: 3 additions & 0 deletions packages/tracing/test/integrations/node/mongo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('patchOperation()', () => {
dbName: 'mockedDbName',
doc: JSON.stringify(doc),
namespace: 'mockedNamespace',
'db.system': 'mongodb',
},
op: 'db',
description: 'insertOne',
Expand All @@ -96,6 +97,7 @@ describe('patchOperation()', () => {
dbName: 'mockedDbName',
doc: JSON.stringify(doc),
namespace: 'mockedNamespace',
'db.system': 'mongodb',
},
op: 'db',
description: 'insertOne',
Expand All @@ -111,6 +113,7 @@ describe('patchOperation()', () => {
collectionName: 'mockedCollectionName',
dbName: 'mockedDbName',
namespace: 'mockedNamespace',
'db.system': 'mongodb',
},
op: 'db',
description: 'initializeOrderedBulkOp',
Expand Down
9 changes: 9 additions & 0 deletions packages/tracing/test/integrations/node/postgres.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ describe('setupOnce', () => {
expect(parentSpan.startChild).toBeCalledWith({
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'postgresql',
},
});
expect(childSpan.finish).toBeCalled();
done();
Expand All @@ -84,6 +87,9 @@ describe('setupOnce', () => {
expect(parentSpan.startChild).toBeCalledWith({
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'postgresql',
},
});
expect(childSpan.finish).toBeCalled();
done();
Expand All @@ -96,6 +102,9 @@ describe('setupOnce', () => {
expect(parentSpan.startChild).toBeCalledWith({
description: 'SELECT NOW()',
op: 'db',
data: {
'db.system': 'postgresql',
},
});
expect(childSpan.finish).toBeCalled();
});
Expand Down
5 changes: 4 additions & 1 deletion packages/tracing/test/integrations/node/prisma.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ describe('setupOnce', function () {
it('should add middleware with $use method correctly', done => {
void Client.user.create()?.then(() => {
expect(mockTrace).toHaveBeenCalledTimes(1);
expect(mockTrace).toHaveBeenLastCalledWith({ name: 'user create', op: 'db.sql.prisma' }, expect.any(Function));
expect(mockTrace).toHaveBeenLastCalledWith(
{ name: 'user create', op: 'db.sql.prisma', data: { 'db.system': 'prisma' } },
expect.any(Function),
);
done();
});
});
Expand Down