Skip to content

Commit d2dc12f

Browse files
authored
Do not multiwrap pool queries (#880)
* fix: do not multiwrap pool queries * chore: lint * chore: use wrap check from core
1 parent c812917 commit d2dc12f

File tree

1 file changed

+8
-6
lines changed
  • packages/opentelemetry-plugin-mysql/src

1 file changed

+8
-6
lines changed

packages/opentelemetry-plugin-mysql/src/mysql.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { BasePlugin } from '@opentelemetry/core';
17+
import { BasePlugin, isWrapped } from '@opentelemetry/core';
1818
import { CanonicalCode, Span, SpanKind } from '@opentelemetry/api';
1919
import * as mysqlTypes from 'mysql';
2020
import * as shimmer from 'shimmer';
@@ -179,11 +179,13 @@ export class MysqlPlugin extends BasePlugin<typeof mysqlTypes> {
179179
if (arguments[1]) {
180180
// this is the callback passed into a query
181181
// no need to unwrap
182-
shimmer.wrap(
183-
arguments[1],
184-
'query',
185-
thisPlugin._patchQuery(arguments[1])
186-
);
182+
if (!isWrapped(arguments[1].query)) {
183+
shimmer.wrap(
184+
arguments[1],
185+
'query',
186+
thisPlugin._patchQuery(arguments[1])
187+
);
188+
}
187189
}
188190
if (typeof cb === 'function') {
189191
cb(...arguments);

0 commit comments

Comments
 (0)