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
117
117
if ( fetchSpan ) {
118
118
fetchSpan . setAttribute ( SEMATTRS_HTTP_URL , location . href ) ;
119
119
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
+ ) ;
123
125
this . _addCustomAttributesOnSpan (
124
126
fetchSpan ,
125
127
this . getConfig ( ) . applyCustomAttributesOnSpan ?. documentFetch
@@ -205,9 +207,11 @@ export class DocumentLoadInstrumentation extends InstrumentationBase<DocumentLoa
205
207
) ;
206
208
if ( span ) {
207
209
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
+ ) ;
211
215
this . _addCustomAttributesOnResourceSpan (
212
216
span ,
213
217
resource ,
Original file line number Diff line number Diff line change @@ -834,6 +834,27 @@ describe('DocumentLoad Instrumentation', () => {
834
834
done ( ) ;
835
835
} ) ;
836
836
} ) ;
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
+ } ) ;
837
858
} ) ;
838
859
} ) ;
839
860
You can’t perform that action at this time.
0 commit comments