-
Notifications
You must be signed in to change notification settings - Fork 323
/
Copy pathstorage.js
75 lines (70 loc) · 1.73 KB
/
storage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function configWithFallback ({ tracerService, pluginConfig }) {
return pluginConfig.service || tracerService
}
const redisNaming = {
opName: () => 'redis.command',
serviceName: configWithFallback
}
const mySQLNaming = {
opName: () => 'mysql.query',
serviceName: withFunction
}
function withFunction ({ tracerService, pluginConfig, params }) {
if (typeof pluginConfig.service === 'function') {
return pluginConfig.service(params)
}
return configWithFallback({ tracerService, pluginConfig })
}
const storage = {
client: {
aerospike: {
opName: () => 'aerospike.command',
serviceName: configWithFallback
},
'cassandra-driver': {
opName: () => 'cassandra.query',
serviceName: configWithFallback
},
couchbase: {
opName: () => 'couchbase.query',
serviceName: configWithFallback
},
elasticsearch: {
opName: () => 'elasticsearch.query',
serviceName: configWithFallback
},
ioredis: redisNaming,
mariadb: {
opName: () => 'mariadb.query',
serviceName: withFunction
},
memcached: {
opName: () => 'memcached.command',
serviceName: configWithFallback
},
'mongodb-core': {
opName: () => 'mongodb.query',
serviceName: configWithFallback
},
mysql: mySQLNaming,
mysql2: mySQLNaming,
opensearch: {
opName: () => 'opensearch.query',
serviceName: configWithFallback
},
oracledb: {
opName: () => 'oracle.query',
serviceName: withFunction
},
pg: {
opName: () => 'postgresql.query',
serviceName: withFunction
},
redis: redisNaming,
tedious: {
opName: () => 'mssql.query',
serviceName: configWithFallback
}
}
}
module.exports = storage