Skip to content

Commit 388c916

Browse files
authored
fix oracle db bug (#5868)
* fix oracle db bug
1 parent 6796afd commit 388c916

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

packages/datadog-plugin-oracledb/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class OracledbPlugin extends DatabasePlugin {
1111

1212
start ({ query, connAttrs }) {
1313
const service = this.serviceName({ pluginConfig: this.config, params: connAttrs })
14-
const url = getUrl(connAttrs.connectString)
14+
// Users can pass either connectString or connectionString
15+
const url = getUrl(connAttrs.connectString || connAttrs.connectionString)
1516

1617
this.startSpan(this.operationName(), {
1718
service,

packages/datadog-plugin-oracledb/test/index.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,36 @@ describe('Plugin', () => {
342342
connection.execute(dbQuery)
343343
})
344344
})
345+
346+
describe('with connectionString fallback', () => {
347+
before(async () => {
348+
await agent.load('oracledb', {
349+
service: connAttrs => connAttrs.connectString || connAttrs.connectionString
350+
})
351+
oracledb = require(`../../../versions/oracledb@${version}`).get()
352+
tracer = require('../../dd-trace')
353+
})
354+
355+
after(async () => {
356+
await agent.close({ ritmReset: false })
357+
})
358+
359+
it('should fallback to connectionString when connectString is not available', async () => {
360+
const connection = await oracledb.getConnection({
361+
user: config.user,
362+
password: config.password,
363+
connectionString: config.connectString // Use valid connection string
364+
})
365+
366+
const promise = agent.assertSomeTraces(traces => {
367+
expect(traces[0][0]).to.have.property('service', config.connectString)
368+
})
369+
370+
connection.execute(dbQuery)
371+
await connection.close()
372+
return promise
373+
})
374+
})
345375
})
346376
})
347377
})

0 commit comments

Comments
 (0)