Skip to content

Commit faedc33

Browse files
committed
Remove attached cache attributes.
1 parent a92dd07 commit faedc33

File tree

2 files changed

+0
-85
lines changed

2 files changed

+0
-85
lines changed

plugins/node/instrumentation-dataloader/src/instrumentation.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,6 @@ export class DataloaderInstrumentation extends InstrumentationBase<DataloaderIns
186186
const result = original
187187
.call(this, ...args)
188188
.then(value => {
189-
span.setAttribute('cache.key', [args[0]]);
190-
span.setAttribute('cache.hit', value !== undefined);
191-
span.setAttribute(
192-
'cache.item_size',
193-
value ? JSON.stringify(value).length : 0
194-
);
195-
196189
span.end();
197190
return value;
198191
})
@@ -251,19 +244,6 @@ export class DataloaderInstrumentation extends InstrumentationBase<DataloaderIns
251244
// .loadMany never rejects, as errors from internal .load
252245
// calls are caught by dataloader lib
253246
return original.call(this, ...args).then(value => {
254-
span.setAttribute('cache.key', Array.from(args[0]));
255-
span.setAttribute(
256-
'cache.hit',
257-
value.every((v: unknown) => v !== undefined)
258-
);
259-
span.setAttribute(
260-
'cache.item_size',
261-
value.reduce(
262-
(acc: number, v: unknown) => acc + JSON.stringify(v).length,
263-
0
264-
)
265-
);
266-
267247
span.end();
268248
return value;
269249
});
@@ -301,12 +281,6 @@ export class DataloaderInstrumentation extends InstrumentationBase<DataloaderIns
301281
return original.call(this, ...args);
302282
});
303283

304-
span.setAttribute('cache.key', [args[0]]);
305-
span.setAttribute(
306-
'cache.item_size',
307-
args[1] ? JSON.stringify(args[1]).length : 0
308-
);
309-
310284
span.end();
311285

312286
return ret;
@@ -340,8 +314,6 @@ export class DataloaderInstrumentation extends InstrumentationBase<DataloaderIns
340314
);
341315

342316
const ret = context.with(trace.setSpan(parent, span), () => {
343-
span.setAttribute('cache.key', [args[0]]);
344-
345317
return original.call(this, ...args);
346318
});
347319

plugins/node/instrumentation-dataloader/test/dataloader.test.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -184,38 +184,6 @@ describe('DataloaderInstrumentation', () => {
184184
assert.strictEqual(batchSpan.name, 'dataloader.batch test-name');
185185
}
186186
});
187-
188-
it('correctly sets cache.key, cache.hit and cache.item_size attributes when data is available', async () => {
189-
assert.strictEqual(await dataloader.load('test'), getMd5HashFromIdx(0));
190-
191-
// We should have exactly two spans (one for .load and one for the batch)
192-
assert.strictEqual(memoryExporter.getFinishedSpans().length, 2);
193-
const [_batchSpan, loadSpan] = memoryExporter.getFinishedSpans();
194-
195-
assert.deepStrictEqual(loadSpan.attributes, {
196-
'cache.key': ['test'],
197-
'cache.hit': true,
198-
'cache.item_size': 34,
199-
});
200-
});
201-
202-
it('correctly sets cache.key, cache.hit and cache.item_size attributes when data is not available', async () => {
203-
const namedDataloader = new Dataloader(async keys => {
204-
return keys.map(() => undefined);
205-
});
206-
207-
assert.strictEqual(await namedDataloader.load('unavailable'), undefined);
208-
209-
// We should have exactly two spans (one for .load and one for the batch)
210-
assert.strictEqual(memoryExporter.getFinishedSpans().length, 2);
211-
const [_batchSpan, loadSpan] = memoryExporter.getFinishedSpans();
212-
213-
assert.deepStrictEqual(loadSpan.attributes, {
214-
'cache.key': ['unavailable'],
215-
'cache.hit': false,
216-
'cache.item_size': 0,
217-
});
218-
});
219187
});
220188

221189
describe('loadMany', () => {
@@ -429,18 +397,6 @@ describe('DataloaderInstrumentation', () => {
429397
assert.strictEqual(clearSpan.name, 'dataloader.clear test-name');
430398
}
431399
});
432-
433-
it('correctly sets attributes for clearing', async () => {
434-
dataloader.clear('test');
435-
436-
// We should have exactly one span
437-
assert.strictEqual(memoryExporter.getFinishedSpans().length, 1);
438-
const [clearSpan] = memoryExporter.getFinishedSpans();
439-
440-
assert.deepStrictEqual(clearSpan.attributes, {
441-
'cache.key': ['test'],
442-
});
443-
});
444400
});
445401

446402
describe('clearAll', () => {
@@ -593,19 +549,6 @@ describe('DataloaderInstrumentation', () => {
593549
assert.strictEqual(primeSpan1.name, 'dataloader.prime');
594550
assert.strictEqual(primeSpan2.name, 'dataloader.prime');
595551
});
596-
597-
it('correctly creates attributes for priming', async () => {
598-
dataloader.prime('test', '1');
599-
600-
// We should have exactly one span
601-
assert.strictEqual(memoryExporter.getFinishedSpans().length, 1);
602-
const [primeSpan] = memoryExporter.getFinishedSpans();
603-
604-
assert.deepStrictEqual(primeSpan.attributes, {
605-
'cache.key': ['test'],
606-
'cache.item_size': 3,
607-
});
608-
});
609552
});
610553

611554
it('should not create anything if disabled', async () => {

0 commit comments

Comments
 (0)