Skip to content

Commit

Permalink
add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
nozik committed Aug 19, 2021
1 parent e702dee commit 3b61c55
Showing 1 changed file with 31 additions and 0 deletions.
Expand Up @@ -250,6 +250,37 @@ describe('MongoDBInstrumentation', () => {
});
});

describe('when using enhanced database reporting without db statementSerializer', () => {
const key = 'key';
const value = 'value';
const object = { [key]: value };

beforeEach(() => {
memoryExporter.reset();
create({
enhancedDatabaseReporting: false,
});
});

it('should properly collect db statement (hide attribute values)', done => {
const span = provider.getTracer('default').startSpan('insertRootSpan');
context.with(trace.setSpan(context.active(), span), () => {
collection.insertOne(object).then(() => {
span.end();
const spans = memoryExporter.getFinishedSpans();
const operationName = 'mongodb.insert';
assertSpans(spans, operationName, SpanKind.CLIENT, false, false);
const mongoSpan = spans.find(s => s.name === operationName);
const dbStatement = JSON.parse(
mongoSpan!.attributes[SemanticAttributes.DB_STATEMENT] as string
);
assert.strictEqual(dbStatement[key], '?');
done();
});
});
});
});

describe('when specifying a dbStatementSerializer configuration', () => {
const key = 'key';
const value = 'value';
Expand Down

0 comments on commit 3b61c55

Please sign in to comment.