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 @@ -30,56 +30,56 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
spans: [
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
doc: '{"title":"Rick and Morty"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'insertOne',
'db.mongodb.collection': 'movies',
'db.mongodb.doc': '{"title":"Rick and Morty"}',
},
description: 'insertOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"Back to the Future"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'findOne',
'db.mongodb.collection': 'movies',
'db.mongodb.query': '{"title":"Back to the Future"}',
},
description: 'findOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
filter: '{"title":"Back to the Future"}',
update: '{"$set":{"title":"South Park"}}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'updateOne',
'db.mongodb.collection': 'movies',
'db.mongodb.filter': '{"title":"Back to the Future"}',
'db.mongodb.update': '{"$set":{"title":"South Park"}}',
},
description: 'updateOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'findOne',
'db.mongodb.collection': 'movies',
'db.mongodb.query': '{"title":"South Park"}',
},
description: 'findOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'find',
'db.mongodb.collection': 'movies',
'db.mongodb.query': '{"title":"South Park"}',
},
description: 'find',
op: 'db',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,56 +30,56 @@ conditionalTest({ min: 12 })('MongoDB Test', () => {
spans: [
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
doc: '{"title":"Rick and Morty"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'insertOne',
'db.mongodb.collection': 'movies',
'db.mongodb.doc': '{"title":"Rick and Morty"}',
},
description: 'insertOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"Back to the Future"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'findOne',
'db.mongodb.collection': 'movies',
'db.mongodb.query': '{"title":"Back to the Future"}',
},
description: 'findOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
filter: '{"title":"Back to the Future"}',
update: '{"$set":{"title":"South Park"}}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'updateOne',
'db.mongodb.collection': 'movies',
'db.mongodb.filter': '{"title":"Back to the Future"}',
'db.mongodb.update': '{"$set":{"title":"South Park"}}',
},
description: 'updateOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'findOne',
'db.mongodb.collection': 'movies',
'db.mongodb.query': '{"title":"South Park"}',
},
description: 'findOne',
op: 'db',
},
{
data: {
collectionName: 'movies',
dbName: 'admin',
namespace: 'admin.movies',
query: '{"title":"South Park"}',
'db.system': 'mongodb',
'db.name': 'admin',
'db.operation': 'find',
'db.mongodb.collection': 'movies',
'db.mongodb.query': '{"title":"South Park"}',
},
description: 'find',
op: 'db',
Expand Down
9 changes: 5 additions & 4 deletions packages/tracing-internal/src/node/integrations/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,14 @@ export class Mongo implements LazyLoadedIntegration<MongoModule> {
args: unknown[],
): SpanContext {
const data: { [key: string]: string } = {
collectionName: collection.collectionName,
dbName: collection.dbName,
namespace: collection.namespace,
'db.system': 'mongodb',
'db.name': collection.dbName,
'db.operation': operation,
'db.mongodb.collection': collection.collectionName,
};
const spanContext: SpanContext = {
op: 'db',
// TODO v8: Use `${collection.collectionName}.${operation}`
description: operation,
data,
};
Expand All @@ -259,7 +260,7 @@ export class Mongo implements LazyLoadedIntegration<MongoModule> {
data[signature[1]] = typeof reduce === 'string' ? reduce : reduce.name || '<anonymous>';
} else {
for (let i = 0; i < signature.length; i++) {
data[signature[i]] = JSON.stringify(args[i]);
data[`db.mongodb.${signature[i]}`] = JSON.stringify(args[i]);
}
}
} catch (_oO) {
Expand Down
22 changes: 11 additions & 11 deletions packages/tracing/test/integrations/node/mongo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ describe('patchOperation()', () => {
expect(scope.getSpan).toBeCalled();
expect(parentSpan.startChild).toBeCalledWith({
data: {
collectionName: 'mockedCollectionName',
dbName: 'mockedDbName',
doc: JSON.stringify(doc),
namespace: 'mockedNamespace',
'db.mongodb.collection': 'mockedCollectionName',
'db.name': 'mockedDbName',
'db.operation': 'insertOne',
'db.mongodb.doc': JSON.stringify(doc),
'db.system': 'mongodb',
},
op: 'db',
Expand All @@ -93,10 +93,10 @@ describe('patchOperation()', () => {
expect(scope.getSpan).toBeCalled();
expect(parentSpan.startChild).toBeCalledWith({
data: {
collectionName: 'mockedCollectionName',
dbName: 'mockedDbName',
doc: JSON.stringify(doc),
namespace: 'mockedNamespace',
'db.mongodb.collection': 'mockedCollectionName',
'db.name': 'mockedDbName',
'db.operation': 'insertOne',
'db.mongodb.doc': JSON.stringify(doc),
'db.system': 'mongodb',
},
op: 'db',
Expand All @@ -110,9 +110,9 @@ describe('patchOperation()', () => {
expect(scope.getSpan).toBeCalled();
expect(parentSpan.startChild).toBeCalledWith({
data: {
collectionName: 'mockedCollectionName',
dbName: 'mockedDbName',
namespace: 'mockedNamespace',
'db.mongodb.collection': 'mockedCollectionName',
'db.name': 'mockedDbName',
'db.operation': 'initializeOrderedBulkOp',
'db.system': 'mongodb',
},
op: 'db',
Expand Down