@@ -193,9 +193,7 @@ def test_traced_get(self):
193
193
"http://testserver/traced/" ,
194
194
)
195
195
if DJANGO_2_2 :
196
- self .assertEqual (
197
- span .attributes [SpanAttributes .HTTP_ROUTE ], "^traced/"
198
- )
196
+ self .assertEqual (span .attributes [SpanAttributes .HTTP_ROUTE ], "^traced/" )
199
197
self .assertEqual (span .attributes [SpanAttributes .HTTP_SCHEME ], "http" )
200
198
self .assertEqual (span .attributes [SpanAttributes .HTTP_STATUS_CODE ], 200 )
201
199
@@ -239,9 +237,7 @@ def test_traced_post(self):
239
237
"http://testserver/traced/" ,
240
238
)
241
239
if DJANGO_2_2 :
242
- self .assertEqual (
243
- span .attributes [SpanAttributes .HTTP_ROUTE ], "^traced/"
244
- )
240
+ self .assertEqual (span .attributes [SpanAttributes .HTTP_ROUTE ], "^traced/" )
245
241
self .assertEqual (span .attributes [SpanAttributes .HTTP_SCHEME ], "http" )
246
242
self .assertEqual (span .attributes [SpanAttributes .HTTP_STATUS_CODE ], 200 )
247
243
@@ -263,21 +259,15 @@ def test_error(self):
263
259
"http://testserver/error/" ,
264
260
)
265
261
if DJANGO_2_2 :
266
- self .assertEqual (
267
- span .attributes [SpanAttributes .HTTP_ROUTE ], "^error/"
268
- )
262
+ self .assertEqual (span .attributes [SpanAttributes .HTTP_ROUTE ], "^error/" )
269
263
self .assertEqual (span .attributes [SpanAttributes .HTTP_SCHEME ], "http" )
270
264
self .assertEqual (span .attributes [SpanAttributes .HTTP_STATUS_CODE ], 500 )
271
265
272
266
self .assertEqual (len (span .events ), 1 )
273
267
event = span .events [0 ]
274
268
self .assertEqual (event .name , "exception" )
275
- self .assertEqual (
276
- event .attributes [SpanAttributes .EXCEPTION_TYPE ], "ValueError"
277
- )
278
- self .assertEqual (
279
- event .attributes [SpanAttributes .EXCEPTION_MESSAGE ], "error"
280
- )
269
+ self .assertEqual (event .attributes [SpanAttributes .EXCEPTION_TYPE ], "ValueError" )
270
+ self .assertEqual (event .attributes [SpanAttributes .EXCEPTION_MESSAGE ], "error" )
281
271
282
272
def test_exclude_lists (self ):
283
273
client = Client ()
@@ -391,9 +381,8 @@ def response_hook(span, request, response):
391
381
self .assertIsInstance (response_hook_args [1 ], HttpRequest )
392
382
self .assertIsInstance (response_hook_args [2 ], HttpResponse )
393
383
self .assertEqual (response_hook_args [2 ], response )
394
-
395
- def test_request_hook_exception (self ):
396
384
385
+ def test_request_hook_exception (self ):
397
386
class RequestHookException (Exception ):
398
387
pass
399
388
@@ -409,9 +398,8 @@ def request_hook(span, request):
409
398
finished_spans = self .memory_exporter .get_finished_spans ()
410
399
self .assertEqual (len (finished_spans ), 1 )
411
400
self .assertEquals (finished_spans [0 ].status .status_code , StatusCode .ERROR )
412
-
413
- def test_response_hook_exception (self ):
414
401
402
+ def test_response_hook_exception (self ):
415
403
class ResponseHookException (Exception ):
416
404
pass
417
405
@@ -522,16 +510,12 @@ def test_wsgi_metrics(self):
522
510
if isinstance (point , HistogramDataPoint ):
523
511
self .assertEqual (point .count , 3 )
524
512
histrogram_data_point_seen = True
525
- self .assertAlmostEqual (
526
- duration , point .sum , delta = 100
527
- )
513
+ self .assertAlmostEqual (duration , point .sum , delta = 100 )
528
514
if isinstance (point , NumberDataPoint ):
529
515
number_data_point_seen = True
530
516
self .assertEqual (point .value , 0 )
531
517
for attr in point .attributes :
532
- self .assertIn (
533
- attr , _recommended_attrs [metric .name ]
534
- )
518
+ self .assertIn (attr , _recommended_attrs [metric .name ])
535
519
self .assertTrue (histrogram_data_point_seen and number_data_point_seen )
536
520
537
521
def test_wsgi_metrics_unistrument (self ):
@@ -558,9 +542,7 @@ def setUpClass(cls):
558
542
def setUp (self ):
559
543
super ().setUp ()
560
544
setup_test_environment ()
561
- resource = resources .Resource .create (
562
- {"resource-key" : "resource-value" }
563
- )
545
+ resource = resources .Resource .create ({"resource-key" : "resource-value" })
564
546
result = self .create_tracer_provider (resource = resource )
565
547
tracer_provider , exporter = result
566
548
self .exporter = exporter
@@ -585,15 +567,11 @@ def test_tracer_provider_traced(self):
585
567
586
568
span = spans [0 ]
587
569
588
- self .assertEqual (
589
- span .resource .attributes ["resource-key" ], "resource-value"
590
- )
570
+ self .assertEqual (span .resource .attributes ["resource-key" ], "resource-value" )
591
571
592
572
def test_django_with_wsgi_instrumented (self ):
593
573
tracer = self .tracer_provider .get_tracer (__name__ )
594
- with tracer .start_as_current_span (
595
- "test" , kind = SpanKind .SERVER
596
- ) as parent_span :
574
+ with tracer .start_as_current_span ("test" , kind = SpanKind .SERVER ) as parent_span :
597
575
Client ().get ("/span_name/1234/" )
598
576
span_list = self .exporter .get_finished_spans ()
599
577
print (span_list )
@@ -640,12 +618,8 @@ def tearDownClass(cls):
640
618
641
619
def test_http_custom_request_headers_in_span_attributes (self ):
642
620
expected = {
643
- "http.request.header.custom_test_header_1" : (
644
- "test-header-value-1" ,
645
- ),
646
- "http.request.header.custom_test_header_2" : (
647
- "test-header-value-2" ,
648
- ),
621
+ "http.request.header.custom_test_header_1" : ("test-header-value-1" ,),
622
+ "http.request.header.custom_test_header_2" : ("test-header-value-2" ,),
649
623
"http.request.header.regex_test_header_1" : ("Regex Test Value 1" ,),
650
624
"http.request.header.regex_test_header_2" : (
651
625
"RegexTestValue2,RegexTestValue3" ,
@@ -669,9 +643,7 @@ def test_http_custom_request_headers_in_span_attributes(self):
669
643
670
644
def test_http_custom_request_headers_not_in_span_attributes (self ):
671
645
not_expected = {
672
- "http.request.header.custom_test_header_2" : (
673
- "test-header-value-2" ,
674
- ),
646
+ "http.request.header.custom_test_header_2" : ("test-header-value-2" ,),
675
647
}
676
648
Client (HTTP_CUSTOM_TEST_HEADER_1 = "test-header-value-1" ).get ("/traced/" )
677
649
spans = self .exporter .get_finished_spans ()
@@ -685,12 +657,8 @@ def test_http_custom_request_headers_not_in_span_attributes(self):
685
657
686
658
def test_http_custom_response_headers_in_span_attributes (self ):
687
659
expected = {
688
- "http.response.header.custom_test_header_1" : (
689
- "test-header-value-1" ,
690
- ),
691
- "http.response.header.custom_test_header_2" : (
692
- "test-header-value-2" ,
693
- ),
660
+ "http.response.header.custom_test_header_1" : ("test-header-value-1" ,),
661
+ "http.response.header.custom_test_header_2" : ("test-header-value-2" ,),
694
662
"http.response.header.my_custom_regex_header_1" : (
695
663
"my-custom-regex-value-1,my-custom-regex-value-2" ,
696
664
),
@@ -710,9 +678,7 @@ def test_http_custom_response_headers_in_span_attributes(self):
710
678
711
679
def test_http_custom_response_headers_not_in_span_attributes (self ):
712
680
not_expected = {
713
- "http.response.header.custom_test_header_3" : (
714
- "test-header-value-3" ,
715
- ),
681
+ "http.response.header.custom_test_header_3" : ("test-header-value-3" ,),
716
682
}
717
683
Client ().get ("/traced_custom_header/" )
718
684
spans = self .exporter .get_finished_spans ()
0 commit comments