Skip to content

Commit

Permalink
cr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nozik committed Aug 30, 2021
1 parent c93e767 commit fbb5bdc
Showing 1 changed file with 15 additions and 16 deletions.
Expand Up @@ -410,24 +410,23 @@ export class MongoDBInstrumentation extends InstrumentationBase<

// capture parameters within the query as well if enhancedDatabaseReporting is enabled.
const commandObj = command.query ?? command.q ?? command;
const dbStatementSerializer: DbStatementSerializer =
this._config.dbStatementSerializer ||
const dbStatementSerializer =
typeof this._config.dbStatementSerializer === 'function' ?
this._config.dbStatementSerializer :
this._defaultDbStatementSerializer.bind(this);

if (typeof dbStatementSerializer === 'function') {
safeExecuteInTheMiddle(
() => {
const query = dbStatementSerializer(commandObj);
span.setAttribute(SemanticAttributes.DB_STATEMENT, query);
},
err => {
if (err) {
this._diag.error('Error running dbStatementSerializer hook', err);
}
},
true
);
}
safeExecuteInTheMiddle(
() => {
const query = dbStatementSerializer(commandObj);
span.setAttribute(SemanticAttributes.DB_STATEMENT, query);
},
err => {
if (err) {
this._diag.error('Error running dbStatementSerializer hook', err);
}
},
true
);
}

private _defaultDbStatementSerializer(commandObj: Record<string, unknown>) {
Expand Down

0 comments on commit fbb5bdc

Please sign in to comment.