@platformatic/sql-mapper 2.0.0-alpha.4 → 2.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/connection-info.js +8 -3
- package/lib/telemetry.js +2 -6
- package/package.json +3 -3
package/lib/connection-info.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// (with the exception of SQLite)
|
|
4
4
|
const getConnectionInfo = async (db, connectionString) => {
|
|
5
5
|
let database, host, port, user
|
|
6
|
+
let dbSystem = 'unknown'
|
|
6
7
|
if (db.isPg) {
|
|
7
8
|
const driver = await db._pool.getConnection()
|
|
8
9
|
const connectionParameters = driver.connection.client.connectionParameters
|
|
@@ -10,6 +11,7 @@ const getConnectionInfo = async (db, connectionString) => {
|
|
|
10
11
|
port = connectionParameters.port
|
|
11
12
|
database = connectionParameters.database
|
|
12
13
|
user = connectionParameters.user
|
|
14
|
+
dbSystem = 'postgresql'
|
|
13
15
|
driver.release()
|
|
14
16
|
} else if (db.isMySql || db.isMariaDB || db.isMySql8) {
|
|
15
17
|
const driver = await db._pool.getConnection()
|
|
@@ -18,8 +20,10 @@ const getConnectionInfo = async (db, connectionString) => {
|
|
|
18
20
|
host = connectionParameters.host
|
|
19
21
|
port = connectionParameters.port
|
|
20
22
|
user = connectionParameters.user
|
|
23
|
+
dbSystem = 'mysql'
|
|
21
24
|
driver.release()
|
|
22
25
|
} else if (db.isSQLite) {
|
|
26
|
+
dbSystem = 'sqlite'
|
|
23
27
|
database = connectionString?.split('sqlite://')[1]
|
|
24
28
|
}
|
|
25
29
|
|
|
@@ -28,9 +32,10 @@ const getConnectionInfo = async (db, connectionString) => {
|
|
|
28
32
|
host,
|
|
29
33
|
port,
|
|
30
34
|
user,
|
|
31
|
-
isPg: db.isPg,
|
|
32
|
-
isMySql: db.isMySql,
|
|
33
|
-
isSQLite: db.isSQLite,
|
|
35
|
+
isPg: !!db.isPg,
|
|
36
|
+
isMySql: !!db.isMySql,
|
|
37
|
+
isSQLite: !!db.isSQLite,
|
|
38
|
+
dbSystem,
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
|
package/lib/telemetry.js
CHANGED
|
@@ -6,19 +6,15 @@ function wrapQuery (app, db, request) {
|
|
|
6
6
|
const query = arguments[0]
|
|
7
7
|
const connectionInfo = db.connectionInfo
|
|
8
8
|
|
|
9
|
-
let namePrefix
|
|
9
|
+
let namePrefix
|
|
10
10
|
if (connectionInfo.isPg) {
|
|
11
11
|
namePrefix = 'pg.query:'
|
|
12
|
-
dbSystem = 'postgresql'
|
|
13
12
|
} else if (connectionInfo.isMySql) {
|
|
14
13
|
namePrefix = 'mysql.query:'
|
|
15
|
-
dbSystem = 'mysql'
|
|
16
14
|
} else if (connectionInfo.isSQLite) {
|
|
17
15
|
namePrefix = 'sqlite.query:'
|
|
18
|
-
dbSystem = 'sqlite'
|
|
19
16
|
} else {
|
|
20
17
|
namePrefix = 'db.query:'
|
|
21
|
-
dbSystem = 'unknown'
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
const format = {
|
|
@@ -33,7 +29,7 @@ function wrapQuery (app, db, request) {
|
|
|
33
29
|
|
|
34
30
|
const ctx = request.span?.context
|
|
35
31
|
|
|
36
|
-
const { database, host, port, user } = connectionInfo
|
|
32
|
+
const { database, host, port, user, dbSystem } = connectionInfo
|
|
37
33
|
const telemetryAttributes = {
|
|
38
34
|
'db.statement': queryText,
|
|
39
35
|
'db.system': dbSystem,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-mapper",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"description": "A data mapper utility for SQL databases",
|
|
5
5
|
"main": "mapper.js",
|
|
6
6
|
"types": "mapper.d.ts",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"camelcase": "^6.3.0",
|
|
36
36
|
"fastify-plugin": "^4.5.1",
|
|
37
37
|
"inflected": "^2.1.0",
|
|
38
|
-
"@platformatic/telemetry": "2.0.0-alpha.
|
|
39
|
-
"@platformatic/utils": "2.0.0-alpha.
|
|
38
|
+
"@platformatic/telemetry": "2.0.0-alpha.5",
|
|
39
|
+
"@platformatic/utils": "2.0.0-alpha.5"
|
|
40
40
|
},
|
|
41
41
|
"tsd": {
|
|
42
42
|
"directory": "test/types"
|