From 181c4a7e45f7a821a5a5431a04288b4221dbdfcd Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 19 Mar 2020 16:27:11 -0400 Subject: [PATCH 1/3] fix: do not multiwrap pool queries --- packages/opentelemetry-plugin-mysql/src/mysql.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/opentelemetry-plugin-mysql/src/mysql.ts b/packages/opentelemetry-plugin-mysql/src/mysql.ts index 35985fdfd1..e5fc58fffd 100644 --- a/packages/opentelemetry-plugin-mysql/src/mysql.ts +++ b/packages/opentelemetry-plugin-mysql/src/mysql.ts @@ -179,11 +179,9 @@ export class MysqlPlugin extends BasePlugin { if (arguments[1]) { // this is the callback passed into a query // no need to unwrap - shimmer.wrap( - arguments[1], - 'query', - thisPlugin._patchQuery(arguments[1]) - ); + if (!arguments[1].query.__wrapped) { + shimmer.wrap(arguments[1], 'query', thisPlugin._patchQuery(arguments[1])); + } } if (typeof cb === 'function') { cb(...arguments); From 7442c35b88607bb81156f11b616610a19afcce07 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 19 Mar 2020 16:44:44 -0400 Subject: [PATCH 2/3] chore: lint --- packages/opentelemetry-plugin-mysql/src/mysql.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/opentelemetry-plugin-mysql/src/mysql.ts b/packages/opentelemetry-plugin-mysql/src/mysql.ts index e5fc58fffd..7f6fcfbe43 100644 --- a/packages/opentelemetry-plugin-mysql/src/mysql.ts +++ b/packages/opentelemetry-plugin-mysql/src/mysql.ts @@ -180,7 +180,11 @@ export class MysqlPlugin extends BasePlugin { // this is the callback passed into a query // no need to unwrap if (!arguments[1].query.__wrapped) { - shimmer.wrap(arguments[1], 'query', thisPlugin._patchQuery(arguments[1])); + shimmer.wrap( + arguments[1], + 'query', + thisPlugin._patchQuery(arguments[1]) + ); } } if (typeof cb === 'function') { From fcd18a88b20365ee4a5e6b95a256a7c2d5b46b10 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 19 Mar 2020 16:58:45 -0400 Subject: [PATCH 3/3] chore: use wrap check from core --- packages/opentelemetry-plugin-mysql/src/mysql.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-plugin-mysql/src/mysql.ts b/packages/opentelemetry-plugin-mysql/src/mysql.ts index 7f6fcfbe43..a134d2fcec 100644 --- a/packages/opentelemetry-plugin-mysql/src/mysql.ts +++ b/packages/opentelemetry-plugin-mysql/src/mysql.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { BasePlugin } from '@opentelemetry/core'; +import { BasePlugin, isWrapped } from '@opentelemetry/core'; import { CanonicalCode, Span, SpanKind } from '@opentelemetry/api'; import * as mysqlTypes from 'mysql'; import * as shimmer from 'shimmer'; @@ -179,7 +179,7 @@ export class MysqlPlugin extends BasePlugin { if (arguments[1]) { // this is the callback passed into a query // no need to unwrap - if (!arguments[1].query.__wrapped) { + if (!isWrapped(arguments[1].query)) { shimmer.wrap( arguments[1], 'query',