Skip to content

Commit

Permalink
chore: remove ordered attribute dropping
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed Nov 18, 2020
1 parent 7242c76 commit f71a988
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 3 additions & 8 deletions packages/opentelemetry-tracing/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,10 @@ export class Span implements api.Span, ReadableSpan {

if (
Object.keys(this.attributes).length >=
this._traceParams.numberOfAttributesPerSpan!
this._traceParams.numberOfAttributesPerSpan! &&
!Object.prototype.hasOwnProperty.call(this.attributes, key)
) {
const attributeKeyToDelete = Object.keys(this.attributes).shift();
if (attributeKeyToDelete) {
this._logger.warn(
`Dropping extra attributes : ${attributeKeyToDelete}`
);
delete this.attributes[attributeKeyToDelete];
}
return this;
}
this.attributes[key] = value;
return this;
Expand Down
5 changes: 3 additions & 2 deletions packages/opentelemetry-tracing/test/Span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@ describe('Span', () => {
assert.strictEqual(span.events.length, 100);
assert.strictEqual(Object.keys(span.attributes).length, 100);
assert.strictEqual(span.events[span.events.length - 1].name, 'sent149');
assert.strictEqual(span.attributes['foo0'], undefined);
assert.strictEqual(span.attributes['foo149'], 'bar149');
assert.strictEqual(span.attributes['foo0'], 'bar0');
assert.strictEqual(span.attributes['foo99'], 'bar99');
assert.strictEqual(span.attributes['sent100'], undefined);
});

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

0 comments on commit f71a988

Please sign in to comment.