From e25ea3ea664c62eab60bb1c291d9f93b878d08bf Mon Sep 17 00:00:00 2001 From: Howard Yoo <32691630+howardyoo@users.noreply.github.com> Date: Tue, 10 Jun 2025 10:32:54 -0500 Subject: [PATCH 1/3] Update instrumentation.ts A fix to make sure the span events creation will not affect the attribute creation (e.g. http.response_content_length). --- .../src/instrumentation.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts index f2ae8f48ea..ac5eb74d97 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts @@ -117,9 +117,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { - if (!this.getConfig().ignoreNetworkEvents) { - addSpanNetworkEvents(fetchSpan, entries); - } + addSpanNetworkEvents(fetchSpan, entries, this.getConfig().ignoreNetworkEvents); this._addCustomAttributesOnSpan( fetchSpan, this.getConfig().applyCustomAttributesOnSpan?.documentFetch @@ -205,9 +203,7 @@ export class DocumentLoadInstrumentation extends InstrumentationBase Date: Wed, 11 Jun 2025 20:22:16 +0000 Subject: [PATCH 2/3] fixed formatting issue via lint:fix --- .../src/instrumentation.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts index ac5eb74d97..5a962a298f 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts @@ -117,7 +117,11 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { - addSpanNetworkEvents(fetchSpan, entries, this.getConfig().ignoreNetworkEvents); + addSpanNetworkEvents( + fetchSpan, + entries, + this.getConfig().ignoreNetworkEvents + ); this._addCustomAttributesOnSpan( fetchSpan, this.getConfig().applyCustomAttributesOnSpan?.documentFetch @@ -203,7 +207,11 @@ export class DocumentLoadInstrumentation extends InstrumentationBase Date: Wed, 11 Jun 2025 21:01:20 +0000 Subject: [PATCH 3/3] added test --- .../test/documentLoad.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/web/opentelemetry-instrumentation-document-load/test/documentLoad.test.ts b/plugins/web/opentelemetry-instrumentation-document-load/test/documentLoad.test.ts index fc6fa0f7a0..0e4e65d963 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/test/documentLoad.test.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/test/documentLoad.test.ts @@ -834,6 +834,27 @@ describe('DocumentLoad Instrumentation', () => { done(); }); }); + + it('should have http.response_content_length attribute even if ignoreNetworkEvents is true', done => { + plugin = new DocumentLoadInstrumentation({ + enabled: false, + ignoreNetworkEvents: true, + }); + plugin.enable(); + + setTimeout(() => { + const spans = exporter.getFinishedSpans(); + const resourceSpan = spans.find( + s => s.name === 'resourceFetch' + ) as ReadableSpan; + assert.isOk(resourceSpan, 'resourceFetch span should exist'); + assert.exists( + resourceSpan.attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH], + 'http.response_content_length attribute should exist' + ); + done(); + }); + }); }); });