Misc cleanups (#32)
diff --git a/src/config/AgentConfig.ts b/src/config/AgentConfig.ts
index a28be12..94d5f26 100644
--- a/src/config/AgentConfig.ts
+++ b/src/config/AgentConfig.ts
@@ -60,6 +60,6 @@
Number.parseInt(process.env.SW_AGENT_MAX_BUFFER_SIZE as string, 10) : 1000,
ignoreSuffix: process.env.SW_IGNORE_SUFFIX ?? '.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg',
traceIgnorePath: process.env.SW_TRACE_IGNORE_PATH || '',
- sql_parameters_max_length: Math.trunc(Math.max(0, Number(process.env.SW_SQL_SQL_PARAMETERS_MAX_LENGTH))) || 512,
+ sql_parameters_max_length: Math.trunc(Math.max(0, Number(process.env.SW_SQL_PARAMETERS_MAX_LENGTH))) || 512,
reIgnoreOperation: RegExp(''), // temporary placeholder so Typescript doesn't throw a fit
};
diff --git a/src/plugins/AxiosPlugin.ts b/src/plugins/AxiosPlugin.ts
index 9612abc..60af986 100644
--- a/src/plugins/AxiosPlugin.ts
+++ b/src/plugins/AxiosPlugin.ts
@@ -23,20 +23,13 @@
import { Component } from '../trace/Component';
import Tag from '../Tag';
import { SpanLayer } from '../proto/language-agent/Tracing_pb';
-import { createLogger } from '../logging';
import PluginInstaller from '../core/PluginInstaller';
-const logger = createLogger(__filename);
-
class AxiosPlugin implements SwPlugin {
readonly module = 'axios';
readonly versions = '*';
install(installer: PluginInstaller): void {
- if (logger.isDebugEnabled()) {
- logger.debug('installing axios plugin');
- }
-
this.interceptClientRequest(installer);
}
diff --git a/src/plugins/HttpPlugin.ts b/src/plugins/HttpPlugin.ts
index e324b00..1d43b94 100644
--- a/src/plugins/HttpPlugin.ts
+++ b/src/plugins/HttpPlugin.ts
@@ -27,8 +27,6 @@
import { SpanLayer } from '../proto/language-agent/Tracing_pb';
import { ContextCarrier } from '../trace/context/ContextCarrier';
-const NativePromise = (async () => null)().constructor; // may be different from globally overridden Promise
-
class HttpPlugin implements SwPlugin {
readonly module = 'http';
readonly versions = '*';
@@ -163,9 +161,8 @@
span.tag(Tag.httpMethod(req.method));
let ret = handler.call(this, req, res, ...reqArgs);
- const type = ret?.constructor;
- if (type !== Promise && type !== NativePromise) {
+ if (!ret || typeof ret.then !== 'function') { // generic Promise check
copyStatusAndStop();
} else {
diff --git a/src/plugins/MySQLPlugin.ts b/src/plugins/MySQLPlugin.ts
index 8e87ab6..8e191fc 100644
--- a/src/plugins/MySQLPlugin.ts
+++ b/src/plugins/MySQLPlugin.ts
@@ -22,21 +22,14 @@
import { Component } from '../trace/Component';
import Tag from '../Tag';
import { SpanLayer } from '../proto/language-agent/Tracing_pb';
-import { createLogger } from '../logging';
import PluginInstaller from '../core/PluginInstaller';
import config from '../config/AgentConfig';
-const logger = createLogger(__filename);
-
class MySQLPlugin implements SwPlugin {
readonly module = 'mysql';
readonly versions = '*';
install(installer: PluginInstaller): void {
- if (logger.isDebugEnabled()) {
- logger.debug('installing mysql plugin');
- }
-
const Connection = installer.require('mysql/lib/Connection');
const _query = Connection.prototype.query;
diff --git a/src/plugins/PgPlugin.ts b/src/plugins/PgPlugin.ts
index e17cf60..e8f4435 100644
--- a/src/plugins/PgPlugin.ts
+++ b/src/plugins/PgPlugin.ts
@@ -22,21 +22,14 @@
import { Component } from '../trace/Component';
import Tag from '../Tag';
import { SpanLayer } from '../proto/language-agent/Tracing_pb';
-import { createLogger } from '../logging';
import PluginInstaller from '../core/PluginInstaller';
import agentConfig from '../config/AgentConfig';
-const logger = createLogger(__filename);
-
class MySQLPlugin implements SwPlugin {
readonly module = 'pg';
readonly versions = '*';
install(installer: PluginInstaller): void {
- if (logger.isDebugEnabled()) {
- logger.debug('installing pg plugin');
- }
-
const Client = installer.require('pg/lib/client');
const _query = Client.prototype.query;
@@ -102,7 +95,7 @@
query = _query.call(this, config, values, callback);
- if (query && typeof query.then === 'function' && typeof query.catch === 'function') // generic Promise check
+ if (query && typeof query.then === 'function') { // generic Promise check
query = query.then(
(res: any) => {
span.resync();
@@ -119,6 +112,7 @@
return Promise.reject(err);
}
);
+ }
} catch (e) {
span.error(e);