Skip to content

Commit 48ca94d

Browse files
s1gr1dclaude
andcommitted
test(e2e): Expect low-cardinality cache span names
Storage span names are `cache.{operation}` under span streaming since #23830. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 9035426 commit 48ca94d

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎dev-packages/e2e-tests/test-applications/nitro-3/tests/storage-aliases.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,36 @@ test.describe('Storage Instrumentation - Aliases', () => {
4040
expect(setSpan).toBeDefined();
4141
expect(setSpan?.attributes).toMatchObject({
4242
'sentry.op': { type: 'string', value: 'cache.put' },
43+
'cache.operation': { type: 'string', value: 'put' },
4344
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
4445
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:user') },
4546
'db.operation.name': { type: 'string', value: 'setItem' },
4647
'db.system.name': { type: 'string', value: expect.any(String) },
4748
});
48-
expect(setSpan?.name).toBe(prefixKey('alias:user'));
49+
expect(setSpan?.name).toBe('cache.put');
4950

5051
// Test get (alias for getItem)
5152
expect(findSpansByMethod('getItem').length).toBeGreaterThanOrEqual(1);
5253
const getSpan = findByKey('getItem', prefixKey('alias:user'));
5354
expect(getSpan).toBeDefined();
5455
expect(getSpan?.attributes).toMatchObject({
5556
'sentry.op': { type: 'string', value: 'cache.get' },
57+
'cache.operation': { type: 'string', value: 'get' },
5658
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
5759
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:user') },
5860
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
5961
'db.operation.name': { type: 'string', value: 'getItem' },
6062
'db.system.name': { type: 'string', value: expect.any(String) },
6163
});
62-
expect(getSpan?.name).toBe(prefixKey('alias:user'));
64+
expect(getSpan?.name).toBe('cache.get');
6365

6466
// Test has (alias for hasItem)
6567
expect(findSpansByMethod('hasItem').length).toBeGreaterThanOrEqual(1);
6668
const hasSpan = findByKey('hasItem', prefixKey('alias:user'));
6769
expect(hasSpan).toBeDefined();
6870
expect(hasSpan?.attributes).toMatchObject({
6971
'sentry.op': { type: 'string', value: 'cache.get' },
72+
'cache.operation': { type: 'string', value: 'get' },
7073
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
7174
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:user') },
7275
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
@@ -81,23 +84,25 @@ test.describe('Storage Instrumentation - Aliases', () => {
8184
expect(delSpan).toBeDefined();
8285
expect(delSpan?.attributes).toMatchObject({
8386
'sentry.op': { type: 'string', value: 'cache.remove' },
87+
'cache.operation': { type: 'string', value: 'remove' },
8488
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
8589
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:temp1') },
8690
'db.operation.name': { type: 'string', value: 'removeItem' },
8791
'db.system.name': { type: 'string', value: expect.any(String) },
8892
});
89-
expect(delSpan?.name).toBe(prefixKey('alias:temp1'));
93+
expect(delSpan?.name).toBe('cache.remove');
9094

9195
const removeSpan = findByKey('removeItem', prefixKey('alias:temp2'));
9296
expect(removeSpan).toBeDefined();
9397
expect(removeSpan?.attributes).toMatchObject({
9498
'sentry.op': { type: 'string', value: 'cache.remove' },
99+
'cache.operation': { type: 'string', value: 'remove' },
95100
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
96101
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:temp2') },
97102
'db.operation.name': { type: 'string', value: 'removeItem' },
98103
'db.system.name': { type: 'string', value: expect.any(String) },
99104
});
100-
expect(removeSpan?.name).toBe(prefixKey('alias:temp2'));
105+
expect(removeSpan?.name).toBe('cache.remove');
101106

102107
// Verify all spans have OK status
103108
expect(allStorageSpans.length).toBeGreaterThan(0);

‎dev-packages/e2e-tests/test-applications/nitro-3/tests/storage.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,21 @@ test.describe('Storage Instrumentation', () => {
4040
expect(setItemSpan).toBeDefined();
4141
expect(setItemSpan?.attributes).toMatchObject({
4242
'sentry.op': { type: 'string', value: 'cache.put' },
43+
'cache.operation': { type: 'string', value: 'put' },
4344
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
4445
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('user:123') },
4546
'db.operation.name': { type: 'string', value: 'setItem' },
4647
'db.system.name': { type: 'string', value: expect.any(String) },
4748
});
48-
expect(setItemSpan?.name).toBe(prefixKey('user:123'));
49+
expect(setItemSpan?.name).toBe('cache.put');
4950

5051
// Test setItemRaw spans
5152
expect(findSpansByMethod('setItemRaw').length).toBeGreaterThanOrEqual(1);
5253
const setItemRawSpan = findSpanByCacheKey('setItemRaw', prefixKey('raw:data'));
5354
expect(setItemRawSpan).toBeDefined();
5455
expect(setItemRawSpan?.attributes).toMatchObject({
5556
'sentry.op': { type: 'string', value: 'cache.put' },
57+
'cache.operation': { type: 'string', value: 'put' },
5658
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
5759
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('raw:data') },
5860
'db.operation.name': { type: 'string', value: 'setItemRaw' },
@@ -65,6 +67,7 @@ test.describe('Storage Instrumentation', () => {
6567
expect(hasItemSpan).toBeDefined();
6668
expect(hasItemSpan?.attributes).toMatchObject({
6769
'sentry.op': { type: 'string', value: 'cache.get' },
70+
'cache.operation': { type: 'string', value: 'get' },
6871
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
6972
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('user:123') },
7073
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
@@ -78,20 +81,22 @@ test.describe('Storage Instrumentation', () => {
7881
expect(getItemSpan).toBeDefined();
7982
expect(getItemSpan?.attributes).toMatchObject({
8083
'sentry.op': { type: 'string', value: 'cache.get' },
84+
'cache.operation': { type: 'string', value: 'get' },
8185
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
8286
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('user:123') },
8387
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
8488
'db.operation.name': { type: 'string', value: 'getItem' },
8589
'db.system.name': { type: 'string', value: expect.any(String) },
8690
});
87-
expect(getItemSpan?.name).toBe(prefixKey('user:123'));
91+
expect(getItemSpan?.name).toBe('cache.get');
8892

8993
// Test getItemRaw spans - should have cache hit attribute
9094
expect(findSpansByMethod('getItemRaw').length).toBeGreaterThanOrEqual(1);
9195
const getItemRawSpan = findSpanByCacheKey('getItemRaw', prefixKey('raw:data'));
9296
expect(getItemRawSpan).toBeDefined();
9397
expect(getItemRawSpan?.attributes).toMatchObject({
9498
'sentry.op': { type: 'string', value: 'cache.get' },
99+
'cache.operation': { type: 'string', value: 'get' },
95100
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
96101
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('raw:data') },
97102
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
@@ -104,6 +109,7 @@ test.describe('Storage Instrumentation', () => {
104109
expect(getKeysSpans.length).toBeGreaterThanOrEqual(1);
105110
expect(getKeysSpans[0]?.attributes).toMatchObject({
106111
'sentry.op': { type: 'string', value: 'cache.get' },
112+
'cache.operation': { type: 'string', value: 'get' },
107113
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
108114
'db.operation.name': { type: 'string', value: 'getKeys' },
109115
'db.system.name': { type: 'string', value: expect.any(String) },
@@ -115,6 +121,7 @@ test.describe('Storage Instrumentation', () => {
115121
expect(removeItemSpan).toBeDefined();
116122
expect(removeItemSpan?.attributes).toMatchObject({
117123
'sentry.op': { type: 'string', value: 'cache.remove' },
124+
'cache.operation': { type: 'string', value: 'remove' },
118125
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
119126
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('batch:1') },
120127
'db.operation.name': { type: 'string', value: 'removeItem' },
@@ -126,6 +133,7 @@ test.describe('Storage Instrumentation', () => {
126133
expect(clearSpans.length).toBeGreaterThanOrEqual(1);
127134
expect(clearSpans[0]?.attributes).toMatchObject({
128135
'sentry.op': { type: 'string', value: 'cache.remove' },
136+
'cache.operation': { type: 'string', value: 'remove' },
129137
'sentry.origin': { type: 'string', value: 'auto.cache.nitro' },
130138
'db.operation.name': { type: 'string', value: 'clear' },
131139
'db.system.name': { type: 'string', value: expect.any(String) },

0 commit comments

Comments
 (0)