From f71a9880b39a5349718fddffdf33602903dba5ad Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 18 Nov 2020 10:13:02 -0500 Subject: [PATCH] chore: remove ordered attribute dropping --- packages/opentelemetry-tracing/src/Span.ts | 11 +++-------- packages/opentelemetry-tracing/test/Span.test.ts | 5 +++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index 62d6f35e5f..6c21cf98a6 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -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; diff --git a/packages/opentelemetry-tracing/test/Span.test.ts b/packages/opentelemetry-tracing/test/Span.test.ts index 9bf0fb19fc..1b4819a43d 100644 --- a/packages/opentelemetry-tracing/test/Span.test.ts +++ b/packages/opentelemetry-tracing/test/Span.test.ts @@ -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', () => {