diff --git a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts index f2ae8f48ea..5a962a298f 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts +++ b/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts @@ -117,9 +117,11 @@ 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 +207,11 @@ export class DocumentLoadInstrumentation extends InstrumentationBase { 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(); + }); + }); }); });