File tree Expand file tree Collapse file tree 2 files changed +31
-6
lines changed
plugins/web/opentelemetry-instrumentation-document-load Expand file tree Collapse file tree 2 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -117,9 +117,11 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<DocumentLoa
117117 if ( fetchSpan ) {
118118 fetchSpan . setAttribute ( SEMATTRS_HTTP_URL , location . href ) ;
119119 context . with ( trace . setSpan ( context . active ( ) , fetchSpan ) , ( ) => {
120- if ( ! this . getConfig ( ) . ignoreNetworkEvents ) {
121- addSpanNetworkEvents ( fetchSpan , entries ) ;
122- }
120+ addSpanNetworkEvents (
121+ fetchSpan ,
122+ entries ,
123+ this . getConfig ( ) . ignoreNetworkEvents
124+ ) ;
123125 this . _addCustomAttributesOnSpan (
124126 fetchSpan ,
125127 this . getConfig ( ) . applyCustomAttributesOnSpan ?. documentFetch
@@ -205,9 +207,11 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<DocumentLoa
205207 ) ;
206208 if ( span ) {
207209 span . setAttribute ( SEMATTRS_HTTP_URL , resource . name ) ;
208- if ( ! this . getConfig ( ) . ignoreNetworkEvents ) {
209- addSpanNetworkEvents ( span , resource ) ;
210- }
210+ addSpanNetworkEvents (
211+ span ,
212+ resource ,
213+ this . getConfig ( ) . ignoreNetworkEvents
214+ ) ;
211215 this . _addCustomAttributesOnResourceSpan (
212216 span ,
213217 resource ,
Original file line number Diff line number Diff line change @@ -834,6 +834,27 @@ describe('DocumentLoad Instrumentation', () => {
834834 done ( ) ;
835835 } ) ;
836836 } ) ;
837+
838+ it ( 'should have http.response_content_length attribute even if ignoreNetworkEvents is true' , done => {
839+ plugin = new DocumentLoadInstrumentation ( {
840+ enabled : false ,
841+ ignoreNetworkEvents : true ,
842+ } ) ;
843+ plugin . enable ( ) ;
844+
845+ setTimeout ( ( ) => {
846+ const spans = exporter . getFinishedSpans ( ) ;
847+ const resourceSpan = spans . find (
848+ s => s . name === 'resourceFetch'
849+ ) as ReadableSpan ;
850+ assert . isOk ( resourceSpan , 'resourceFetch span should exist' ) ;
851+ assert . exists (
852+ resourceSpan . attributes [ SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH ] ,
853+ 'http.response_content_length attribute should exist'
854+ ) ;
855+ done ( ) ;
856+ } ) ;
857+ } ) ;
837858 } ) ;
838859} ) ;
839860
You can’t perform that action at this time.
0 commit comments