Skip to content

Commit

Permalink
chore: Updated DatastoreParameters to include collection (#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 committed Feb 23, 2024
1 parent 2c97488 commit b9c73ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/shim/specs/params/datastore.js
Expand Up @@ -16,6 +16,8 @@
* server.
* @property {string} database_name
* The name of the database being queried or operated on.
* @property {string} collection
* The name of the collection or table being queried or operated on.
*/

/**
Expand All @@ -31,6 +33,7 @@ class DatastoreParameters {
this.host = params.host ?? null
this.port_path_or_id = params.port_path_or_id ?? null
this.database_name = params.database_name ?? null
this.collection = params.collection ?? null
}
}

Expand Down
12 changes: 9 additions & 3 deletions test/unit/instrumentation/mysql/getInstanceParameters.test.js
Expand Up @@ -34,7 +34,7 @@ tap.test('getInstanceParameters', (t) => {

t.same(
result,
{ host: null, port_path_or_id: null, database_name: null },
{ host: null, port_path_or_id: null, database_name: null, collection: null },
'should return the default parameters'
)
t.ok(
Expand Down Expand Up @@ -84,7 +84,12 @@ tap.test('getInstanceParameters', (t) => {
}

const result = instrumentation.getInstanceParameters(mockShim, mockQueryable, mockQuery)
t.same(result, { host: 'example.com', port_path_or_id: '1234', database_name: 'test-database' })
t.same(result, {
host: 'example.com',
port_path_or_id: '1234',
database_name: 'test-database',
collection: null
})
t.end()
})

Expand All @@ -100,7 +105,8 @@ tap.test('getInstanceParameters', (t) => {
t.same(result, {
host: 'localhost',
port_path_or_id: '/var/run/mysqld/mysqld.sock',
database_name: 'test-database'
database_name: 'test-database',
collection: null
})
t.end()
})
Expand Down

0 comments on commit b9c73ca

Please sign in to comment.