whatap 0.5.15 → 0.5.17
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.
|
@@ -276,7 +276,9 @@ var ConfigDefault = {
|
|
|
276
276
|
"prisma_read_func_name": str("prisma_read_func_name", "read"),
|
|
277
277
|
"prisma_database_url_name": str("prisma_database_url_name", "DATABASE_URL"),
|
|
278
278
|
|
|
279
|
-
"metering_tagcount_enabled": bool("metering_tagcount_enabled", false)
|
|
279
|
+
"metering_tagcount_enabled": bool("metering_tagcount_enabled", false),
|
|
280
|
+
"profile_redis_param_enabled": bool("profile_redis_param_enabled", false),
|
|
281
|
+
|
|
280
282
|
};
|
|
281
283
|
|
|
282
284
|
ConfigDefault._hook_method_ignore_prefix = ConfigDefault.hook_method_ignore_prefixes.split(',');
|
|
@@ -124,10 +124,12 @@ PgSqlObserver.prototype.inject = function (mod, moduleName) {
|
|
|
124
124
|
dbc_step = null;
|
|
125
125
|
|
|
126
126
|
var sql_step = new SqlStepX();
|
|
127
|
-
sql_step.start_time =
|
|
127
|
+
sql_step.start_time = ctx.getElapsedTime();
|
|
128
128
|
ctx.profile.push(sql_step);
|
|
129
129
|
ctx.footprint('PgSql Query Start');
|
|
130
130
|
|
|
131
|
+
ctx.vvv++;
|
|
132
|
+
|
|
131
133
|
let sql = arguments[0];
|
|
132
134
|
let psql = null;
|
|
133
135
|
if (typeof sql === 'string' && sql.length > 0) {
|
|
@@ -176,7 +178,7 @@ PgSqlObserver.prototype.inject = function (mod, moduleName) {
|
|
|
176
178
|
return result.then(res => {
|
|
177
179
|
if(res.command && res.command === 'SELECT'){
|
|
178
180
|
var result_step = new ResultSetStep();
|
|
179
|
-
result_step.start_time =
|
|
181
|
+
result_step.start_time = ctx.getElapsedTime();
|
|
180
182
|
result_step.elapsed = 0;
|
|
181
183
|
result_step.fetch = res.rowCount;
|
|
182
184
|
result_step.sqlhash = psql.sql;
|
|
@@ -194,6 +196,16 @@ PgSqlObserver.prototype.inject = function (mod, moduleName) {
|
|
|
194
196
|
return res;
|
|
195
197
|
}).catch(err => {
|
|
196
198
|
self._handleError(ctx, sql_step, err)
|
|
199
|
+
if (conf.trace_sql_error_stack && conf.trace_sql_error_depth) {
|
|
200
|
+
var traceDepth = conf.trace_sql_error_depth;
|
|
201
|
+
|
|
202
|
+
var errorStack = err.stack.split("\n");
|
|
203
|
+
if (errorStack.length > traceDepth) {
|
|
204
|
+
errorStack = errorStack.slice(0, traceDepth + 1);
|
|
205
|
+
}
|
|
206
|
+
ctx.error_message = errorStack.join("\n");
|
|
207
|
+
sql_step.error = ctx.error = StatError.addError('pgsql -' + err.code, err.message, ctx.service_hash, TextTypes.SQL, null);
|
|
208
|
+
}
|
|
197
209
|
throw err;
|
|
198
210
|
});
|
|
199
211
|
} else {
|
|
@@ -219,7 +231,7 @@ PgSqlObserver.prototype.inject = function (mod, moduleName) {
|
|
|
219
231
|
};
|
|
220
232
|
|
|
221
233
|
PgSqlObserver.prototype._finishQuery = function (ctx, sql_step) {
|
|
222
|
-
sql_step.elapsed =
|
|
234
|
+
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
223
235
|
TraceSQL.isSlowSQL(ctx);
|
|
224
236
|
|
|
225
237
|
MeterSql.add(sql_step.hash, sql_step.elapsed, false);
|
|
@@ -227,28 +239,7 @@ PgSqlObserver.prototype._finishQuery = function (ctx, sql_step) {
|
|
|
227
239
|
};
|
|
228
240
|
|
|
229
241
|
PgSqlObserver.prototype._handleError = function (ctx, sql_step, err) {
|
|
230
|
-
sql_step.elapsed =
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
sql_step.error = StatError.addError("pgsql-" + (err.code || "unknown"), err.message, ctx.service_hash, TextTypes.SQL, sql_step.hash);
|
|
234
|
-
|
|
235
|
-
if (ctx.error.isZero()) {
|
|
236
|
-
ctx.error = sql_step.error;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (conf.trace_sql_error_stack && conf.trace_sql_error_depth) {
|
|
240
|
-
var traceDepth = conf.trace_sql_error_depth;
|
|
241
|
-
var errorStack = err.stack.split("\n");
|
|
242
|
-
|
|
243
|
-
if (errorStack.length > traceDepth) {
|
|
244
|
-
errorStack = errorStack.slice(0, traceDepth + 1);
|
|
245
|
-
}
|
|
246
|
-
ctx.error_message = errorStack.join("\n");
|
|
247
|
-
}
|
|
248
|
-
} catch (e) {
|
|
249
|
-
Logger.printError("WHATAP-309", "Error handling failed", e, false);
|
|
250
|
-
}
|
|
251
|
-
|
|
242
|
+
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
252
243
|
TraceSQL.isSlowSQL(ctx);
|
|
253
244
|
|
|
254
245
|
MeterSql.add(sql_step.hash, sql_step.elapsed, false);
|
|
@@ -330,7 +330,7 @@ PrismaObserver.prototype.hookUseMiddleware = function(prismaInstance) {
|
|
|
330
330
|
};
|
|
331
331
|
|
|
332
332
|
PrismaObserver.prototype._finishQuery = function(ctx, sql_step) {
|
|
333
|
-
sql_step.elapsed =
|
|
333
|
+
sql_step.elapsed = ctx.getElapsedTime() - sql_step.start_time;
|
|
334
334
|
ctx.sql_time = (ctx.sql_time || 0) + sql_step.elapsed;
|
|
335
335
|
|
|
336
336
|
TraceSQL.isSlowSQL(ctx);
|
|
@@ -342,7 +342,7 @@ PrismaObserver.prototype._finishQuery = function(ctx, sql_step) {
|
|
|
342
342
|
};
|
|
343
343
|
|
|
344
344
|
PrismaObserver.prototype._handleError = function(ctx, sql_step, err) {
|
|
345
|
-
sql_step.elapsed =
|
|
345
|
+
sql_step.elapsed = ctx.getElapsedTime()
|
|
346
346
|
ctx.sql_time = (ctx.sql_time || 0) + sql_step.elapsed;
|
|
347
347
|
|
|
348
348
|
TraceSQL.isSlowSQL(ctx);
|
|
@@ -74,11 +74,9 @@ RedisObserver.prototype._injectRedis = function (mod) {
|
|
|
74
74
|
var sql = `${command.toUpperCase()}`;
|
|
75
75
|
var sql_step = new SqlStepX();
|
|
76
76
|
sql_step.start_time = ctx.getElapsedTime();
|
|
77
|
-
sql_step.hash = HashUtil.hashFromString(sql);
|
|
78
77
|
sql_step.dbc = dbc_hash;
|
|
79
78
|
|
|
80
79
|
if(conf.getProperty('profile_redis_param_enabled', false)){
|
|
81
|
-
var params;
|
|
82
80
|
if (arguments[0] && typeof arguments[0] === 'string')
|
|
83
81
|
sql += ' ' + arguments[0];
|
|
84
82
|
else if (arguments[0] && Array.isArray(arguments[0]))
|
|
@@ -91,7 +89,6 @@ RedisObserver.prototype._injectRedis = function (mod) {
|
|
|
91
89
|
var args = Array.isArray(arguments[1]) ? arguments[1] : [arguments[1]];
|
|
92
90
|
sql_step.setTrue(1);
|
|
93
91
|
var crc = {value: 0};
|
|
94
|
-
sql_step.p1 = toParamBytes(args.join(","), crc);
|
|
95
92
|
const result = args.map((arg) => {
|
|
96
93
|
if (typeof arg === 'string') {
|
|
97
94
|
return `'${arg}'`
|
|
@@ -102,7 +99,7 @@ RedisObserver.prototype._injectRedis = function (mod) {
|
|
|
102
99
|
sql_step.pcrc = crc.value;
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
|
-
|
|
102
|
+
sql_step.hash = HashUtil.hashFromString(sql);
|
|
106
103
|
ctx.profile.push(sql_step);
|
|
107
104
|
|
|
108
105
|
DataTextAgent.SQL.add(sql_step.hash, sql);
|
|
@@ -163,10 +160,8 @@ RedisObserver.prototype._injectIORedis = function (mod) {
|
|
|
163
160
|
|
|
164
161
|
try {
|
|
165
162
|
var sql_step = new SqlStepX();
|
|
166
|
-
|
|
167
163
|
var sql = command.name.toUpperCase();
|
|
168
164
|
if(conf.getProperty('profile_redis_param_enabled', false)){
|
|
169
|
-
var params;
|
|
170
165
|
var args = command.args;
|
|
171
166
|
var key = args.shift();
|
|
172
167
|
if (key && typeof key === 'string')
|
|
@@ -175,7 +170,6 @@ RedisObserver.prototype._injectIORedis = function (mod) {
|
|
|
175
170
|
if(args && args.length > 0){
|
|
176
171
|
sql_step.setTrue(1);
|
|
177
172
|
var crc = {value: 0};
|
|
178
|
-
sql_step.p1 = toParamBytes(args.join(","), crc);
|
|
179
173
|
const result = args.map((arg) => {
|
|
180
174
|
if (typeof arg === 'string') {
|
|
181
175
|
return `'${arg}'`
|
package/package.json
CHANGED