Skip to content

Commit

Permalink
Do not multiwrap pool queries (#880)
Browse files Browse the repository at this point in the history
* fix: do not multiwrap pool queries

* chore: lint

* chore: use wrap check from core
  • Loading branch information
dyladan authored Mar 19, 2020
1 parent c812917 commit d2dc12f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/opentelemetry-plugin-mysql/src/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -179,11 +179,13 @@ export class MysqlPlugin extends BasePlugin<typeof mysqlTypes> {
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 (!isWrapped(arguments[1].query)) {
shimmer.wrap(
arguments[1],
'query',
thisPlugin._patchQuery(arguments[1])
);
}
}
if (typeof cb === 'function') {
cb(...arguments);
Expand Down

0 comments on commit d2dc12f

Please sign in to comment.