Skip to content

Commit b72b611

Browse files
committed
test(test-v4-v5): create test for ATTR_DB_OPERATION_BATCH_SIZE
1 parent 38d8487 commit b72b611

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/instrumentation-redis/test/v4-v5/redis.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
ATTR_SERVER_ADDRESS,
5353
ATTR_SERVER_PORT,
5454
ATTR_EXCEPTION_MESSAGE,
55+
ATTR_DB_OPERATION_BATCH_SIZE,
5556
} from '@opentelemetry/semantic-conventions';
5657
import { RedisResponseCustomAttributeFunction } from '../../src/types';
5758
import { hrTimeToMilliseconds, suppressTracing } from '@opentelemetry/core';
@@ -622,6 +623,28 @@ describe('redis v4-v5', () => {
622623
});
623624
});
624625

626+
describe('extra coverage batch size and URL sanitization', () => {
627+
const stableCfg = { semconvStability: SemconvStability.STABLE };
628+
629+
afterEach(() => {
630+
instrumentation.setConfig({});
631+
});
632+
633+
it('should set ATTR_DB_OPERATION_BATCH_SIZE when multi has 3 commands', async () => {
634+
instrumentation.setConfig(stableCfg);
635+
const multi = client.multi();
636+
multi.set('covKey1', 'v1');
637+
multi.get('covKey1');
638+
multi.set('covKey2', 'v2');
639+
await multi.exec();
640+
641+
const spanWithBatch = getTestSpans().find(
642+
s => s.attributes[ATTR_DB_OPERATION_BATCH_SIZE] === 3
643+
);
644+
assert.ok(spanWithBatch, 'No span had batch size 3');
645+
});
646+
});
647+
625648
describe('config', () => {
626649
describe('dbStatementSerializer', () => {
627650
it('custom dbStatementSerializer', async () => {

0 commit comments

Comments
 (0)