Skip to content

Commit f71a988

Browse files
committed
chore: remove ordered attribute dropping
1 parent 7242c76 commit f71a988

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/opentelemetry-tracing/src/Span.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,10 @@ export class Span implements api.Span, ReadableSpan {
103103

104104
if (
105105
Object.keys(this.attributes).length >=
106-
this._traceParams.numberOfAttributesPerSpan!
106+
this._traceParams.numberOfAttributesPerSpan! &&
107+
!Object.prototype.hasOwnProperty.call(this.attributes, key)
107108
) {
108-
const attributeKeyToDelete = Object.keys(this.attributes).shift();
109-
if (attributeKeyToDelete) {
110-
this._logger.warn(
111-
`Dropping extra attributes : ${attributeKeyToDelete}`
112-
);
113-
delete this.attributes[attributeKeyToDelete];
114-
}
109+
return this;
115110
}
116111
this.attributes[key] = value;
117112
return this;

packages/opentelemetry-tracing/test/Span.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,9 @@ describe('Span', () => {
348348
assert.strictEqual(span.events.length, 100);
349349
assert.strictEqual(Object.keys(span.attributes).length, 100);
350350
assert.strictEqual(span.events[span.events.length - 1].name, 'sent149');
351-
assert.strictEqual(span.attributes['foo0'], undefined);
352-
assert.strictEqual(span.attributes['foo149'], 'bar149');
351+
assert.strictEqual(span.attributes['foo0'], 'bar0');
352+
assert.strictEqual(span.attributes['foo99'], 'bar99');
353+
assert.strictEqual(span.attributes['sent100'], undefined);
353354
});
354355

355356
it('should set an error status', () => {

0 commit comments

Comments
 (0)