Skip to content

Commit fa83ec3

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 bc8a5ff commit fa83ec3

3 files changed

Lines changed: 22 additions & 6 deletions

File tree

‎dev-packages/e2e-tests/test-applications/nuxt-5/tests/cache.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ test.describe('Cache Instrumentation', () => {
4747
if (cacheMissSpan) {
4848
expect(cacheMissSpan.attributes).toMatchObject({
4949
'sentry.op': { type: 'string', value: 'cache.get' },
50+
'cache.operation': { type: 'string', value: 'get' },
5051
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
5152
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: false },
5253
'db.operation.name': { type: 'string', value: 'getItem' },
@@ -64,6 +65,7 @@ test.describe('Cache Instrumentation', () => {
6465
if (cacheHitSpan) {
6566
expect(cacheHitSpan.attributes).toMatchObject({
6667
'sentry.op': { type: 'string', value: 'cache.get' },
68+
'cache.operation': { type: 'string', value: 'get' },
6769
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
6870
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
6971
'db.operation.name': { type: 'string', value: 'getItem' },
@@ -81,6 +83,7 @@ test.describe('Cache Instrumentation', () => {
8183
if (cacheSetSpan) {
8284
expect(cacheSetSpan.attributes).toMatchObject({
8385
'sentry.op': { type: 'string', value: 'cache.put' },
86+
'cache.operation': { type: 'string', value: 'put' },
8487
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
8588
'db.operation.name': { type: 'string', value: 'setItem' },
8689
'db.collection.name': { type: 'string', value: expect.stringMatching(/^(cache)?$/) },

‎dev-packages/e2e-tests/test-applications/nuxt-5/tests/storage-aliases.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,38 @@ test.describe('Storage Instrumentation - Aliases', () => {
3838
expect(setSpan).toBeDefined();
3939
expect(setSpan?.attributes).toMatchObject({
4040
'sentry.op': { type: 'string', value: 'cache.put' },
41+
'cache.operation': { type: 'string', value: 'put' },
4142
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
4243
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:user') },
4344
'db.operation.name': { type: 'string', value: 'setItem' },
4445
'db.collection.name': { type: 'string', value: 'test-storage' },
4546
'db.system.name': { type: 'string', value: 'memory' },
4647
});
47-
expect(setSpan?.name).toBe(prefixKey('alias:user'));
48+
expect(setSpan?.name).toBe('cache.put');
4849

4950
// Test get (alias for getItem)
5051
expect(findSpansByMethod('getItem').length).toBeGreaterThanOrEqual(1);
5152
const getSpan = findByKey('getItem', prefixKey('alias:user'));
5253
expect(getSpan).toBeDefined();
5354
expect(getSpan?.attributes).toMatchObject({
5455
'sentry.op': { type: 'string', value: 'cache.get' },
56+
'cache.operation': { type: 'string', value: 'get' },
5557
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
5658
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:user') },
5759
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
5860
'db.operation.name': { type: 'string', value: 'getItem' },
5961
'db.collection.name': { type: 'string', value: 'test-storage' },
6062
'db.system.name': { type: 'string', value: 'memory' },
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.nuxt' },
7174
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:user') },
7275
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
@@ -82,25 +85,27 @@ test.describe('Storage Instrumentation - Aliases', () => {
8285
expect(delSpan).toBeDefined();
8386
expect(delSpan?.attributes).toMatchObject({
8487
'sentry.op': { type: 'string', value: 'cache.remove' },
88+
'cache.operation': { type: 'string', value: 'remove' },
8589
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
8690
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:temp1') },
8791
'db.operation.name': { type: 'string', value: 'removeItem' },
8892
'db.collection.name': { type: 'string', value: 'test-storage' },
8993
'db.system.name': { type: 'string', value: 'memory' },
9094
});
91-
expect(delSpan?.name).toBe(prefixKey('alias:temp1'));
95+
expect(delSpan?.name).toBe('cache.remove');
9296

9397
const removeSpan = findByKey('removeItem', prefixKey('alias:temp2'));
9498
expect(removeSpan).toBeDefined();
9599
expect(removeSpan?.attributes).toMatchObject({
96100
'sentry.op': { type: 'string', value: 'cache.remove' },
101+
'cache.operation': { type: 'string', value: 'remove' },
97102
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
98103
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('alias:temp2') },
99104
'db.operation.name': { type: 'string', value: 'removeItem' },
100105
'db.collection.name': { type: 'string', value: 'test-storage' },
101106
'db.system.name': { type: 'string', value: 'memory' },
102107
});
103-
expect(removeSpan?.name).toBe(prefixKey('alias:temp2'));
108+
expect(removeSpan?.name).toBe('cache.remove');
104109

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

‎dev-packages/e2e-tests/test-applications/nuxt-5/tests/storage.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ test.describe('Storage Instrumentation', () => {
3838
expect(setItemSpan).toBeDefined();
3939
expect(setItemSpan?.attributes).toMatchObject({
4040
'sentry.op': { type: 'string', value: 'cache.put' },
41+
'cache.operation': { type: 'string', value: 'put' },
4142
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
4243
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('user:123') },
4344
'db.operation.name': { type: 'string', value: 'setItem' },
4445
'db.collection.name': { type: 'string', value: 'test-storage' },
4546
'db.system.name': { type: 'string', value: 'memory' },
4647
});
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);
@@ -54,6 +55,7 @@ test.describe('Storage Instrumentation', () => {
5455
expect(setItemRawSpan).toBeDefined();
5556
expect(setItemRawSpan?.attributes).toMatchObject({
5657
'sentry.op': { type: 'string', value: 'cache.put' },
58+
'cache.operation': { type: 'string', value: 'put' },
5759
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
5860
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('raw:data') },
5961
'db.operation.name': { type: 'string', value: 'setItemRaw' },
@@ -67,6 +69,7 @@ test.describe('Storage Instrumentation', () => {
6769
expect(hasItemSpan).toBeDefined();
6870
expect(hasItemSpan?.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.nuxt' },
7174
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('user:123') },
7275
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
@@ -81,21 +84,23 @@ test.describe('Storage Instrumentation', () => {
8184
expect(getItemSpan).toBeDefined();
8285
expect(getItemSpan?.attributes).toMatchObject({
8386
'sentry.op': { type: 'string', value: 'cache.get' },
87+
'cache.operation': { type: 'string', value: 'get' },
8488
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
8589
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('user:123') },
8690
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
8791
'db.operation.name': { type: 'string', value: 'getItem' },
8892
'db.collection.name': { type: 'string', value: 'test-storage' },
8993
'db.system.name': { type: 'string', value: 'memory' },
9094
});
91-
expect(getItemSpan?.name).toBe(prefixKey('user:123'));
95+
expect(getItemSpan?.name).toBe('cache.get');
9296

9397
// Test getItemRaw spans - should have cache hit attribute
9498
expect(findSpansByMethod('getItemRaw').length).toBeGreaterThanOrEqual(1);
9599
const getItemRawSpan = findSpanByCacheKey('getItemRaw', prefixKey('raw:data'));
96100
expect(getItemRawSpan).toBeDefined();
97101
expect(getItemRawSpan?.attributes).toMatchObject({
98102
'sentry.op': { type: 'string', value: 'cache.get' },
103+
'cache.operation': { type: 'string', value: 'get' },
99104
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
100105
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('raw:data') },
101106
[SEMANTIC_ATTRIBUTE_CACHE_HIT]: { type: 'boolean', value: true },
@@ -109,6 +114,7 @@ test.describe('Storage Instrumentation', () => {
109114
expect(getKeysSpans.length).toBeGreaterThanOrEqual(1);
110115
expect(getKeysSpans[0]?.attributes).toMatchObject({
111116
'sentry.op': { type: 'string', value: 'cache.get' },
117+
'cache.operation': { type: 'string', value: 'get' },
112118
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
113119
'db.operation.name': { type: 'string', value: 'getKeys' },
114120
'db.collection.name': { type: 'string', value: 'test-storage' },
@@ -121,6 +127,7 @@ test.describe('Storage Instrumentation', () => {
121127
expect(removeItemSpan).toBeDefined();
122128
expect(removeItemSpan?.attributes).toMatchObject({
123129
'sentry.op': { type: 'string', value: 'cache.remove' },
130+
'cache.operation': { type: 'string', value: 'remove' },
124131
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
125132
[SEMANTIC_ATTRIBUTE_CACHE_KEY]: { type: 'string', value: prefixKey('batch:1') },
126133
'db.operation.name': { type: 'string', value: 'removeItem' },
@@ -133,6 +140,7 @@ test.describe('Storage Instrumentation', () => {
133140
expect(clearSpans.length).toBeGreaterThanOrEqual(1);
134141
expect(clearSpans[0]?.attributes).toMatchObject({
135142
'sentry.op': { type: 'string', value: 'cache.remove' },
143+
'cache.operation': { type: 'string', value: 'remove' },
136144
'sentry.origin': { type: 'string', value: 'auto.cache.nuxt' },
137145
'db.operation.name': { type: 'string', value: 'clear' },
138146
'db.collection.name': { type: 'string', value: 'test-storage' },

0 commit comments

Comments
 (0)