1919import unittest
2020
2121from opencensus .ext .azure import trace_exporter
22- from opencensus .ext .azure .common import Options
2322
2423TEST_FOLDER = os .path .abspath ('.test.exporter' )
2524
@@ -40,17 +39,16 @@ def func(*_args, **_kwargs):
4039
4140class TestAzureExporter (unittest .TestCase ):
4241 def test_ctor (self ):
42+ from opencensus .ext .azure .common import Options
4343 instrumentation_key = Options .prototype .instrumentation_key
4444 Options .prototype .instrumentation_key = None
4545 self .assertRaises (ValueError , lambda : trace_exporter .AzureExporter ())
4646 Options .prototype .instrumentation_key = instrumentation_key
4747
4848 def test_export (self ):
4949 exporter = trace_exporter .AzureExporter (
50- Options (
51- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
52- storage_path = os .path .join (TEST_FOLDER , 'foo' ),
53- ),
50+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
51+ storage_path = os .path .join (TEST_FOLDER , 'foo' ),
5452 )
5553 exporter .transport = MockTransport ()
5654 exporter .export (None )
@@ -59,10 +57,8 @@ def test_export(self):
5957 @mock .patch ('requests.post' , return_value = mock .Mock ())
6058 def test_emit (self , request_mock ):
6159 exporter = trace_exporter .AzureExporter (
62- Options (
63- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
64- storage_path = os .path .join (TEST_FOLDER , 'foo' ),
65- ),
60+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
61+ storage_path = os .path .join (TEST_FOLDER , 'foo' ),
6662 )
6763 exporter .transport = MockTransport ()
6864 exporter .emit ([])
@@ -74,18 +70,15 @@ def test_emit(self, request_mock):
7470 self .assertIsNone (exporter .storage .get ())
7571
7672 def test_span_data_to_envelope (self ):
77- from opencensus .ext .azure .common import Options
7873 from opencensus .trace .span import SpanKind
7974 from opencensus .trace .span_context import SpanContext
8075 from opencensus .trace .span_data import SpanData
8176 from opencensus .trace .trace_options import TraceOptions
8277 from opencensus .trace .tracestate import Tracestate
8378
8479 exporter = trace_exporter .AzureExporter (
85- Options (
86- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
87- storage_path = os .path .join (TEST_FOLDER , 'bar' ),
88- ),
80+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
81+ storage_path = os .path .join (TEST_FOLDER , 'bar' ),
8982 )
9083
9184 # SpanKind.CLIENT HTTP
@@ -368,10 +361,8 @@ def test_span_data_to_envelope(self):
368361
369362 def test_transmission_nothing (self ):
370363 exporter = trace_exporter .AzureExporter (
371- Options (
372- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
373- storage_path = os .path .join (TEST_FOLDER , 'baz' ),
374- ),
364+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
365+ storage_path = os .path .join (TEST_FOLDER , 'baz' ),
375366 )
376367
377368 with mock .patch ('requests.post' ) as post :
@@ -380,10 +371,8 @@ def test_transmission_nothing(self):
380371
381372 def test_transmission_request_exception (self ):
382373 exporter = trace_exporter .AzureExporter (
383- Options (
384- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
385- storage_path = os .path .join (TEST_FOLDER , 'request.exception' ),
386- ),
374+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
375+ storage_path = os .path .join (TEST_FOLDER , 'request.exception' ),
387376 )
388377 exporter .storage .put ([1 , 2 , 3 ])
389378 with mock .patch ('requests.post' , throw (Exception )):
@@ -393,10 +382,8 @@ def test_transmission_request_exception(self):
393382
394383 def test_transmission_lease_failure (self ):
395384 exporter = trace_exporter .AzureExporter (
396- Options (
397- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
398- storage_path = os .path .join (TEST_FOLDER , 'lease.failure' ),
399- ),
385+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
386+ storage_path = os .path .join (TEST_FOLDER , 'lease.failure' ),
400387 )
401388 exporter .storage .put ([1 , 2 , 3 ])
402389 with mock .patch ('opencensus.ext.azure.common.storage.LocalFileBlob.lease' ) as lease : # noqa: E501
@@ -406,10 +393,8 @@ def test_transmission_lease_failure(self):
406393
407394 def test_transmission_response_exception (self ):
408395 exporter = trace_exporter .AzureExporter (
409- Options (
410- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
411- storage_path = os .path .join (TEST_FOLDER , 'response.exception' ),
412- ),
396+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
397+ storage_path = os .path .join (TEST_FOLDER , 'response.exception' ),
413398 )
414399 exporter .storage .put ([1 , 2 , 3 ])
415400 with mock .patch ('requests.post' ) as post :
@@ -421,10 +406,8 @@ def test_transmission_response_exception(self):
421406
422407 def test_transmission_200 (self ):
423408 exporter = trace_exporter .AzureExporter (
424- Options (
425- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
426- storage_path = os .path .join (TEST_FOLDER , '200' ),
427- ),
409+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
410+ storage_path = os .path .join (TEST_FOLDER , '200' ),
428411 )
429412 exporter .storage .put ([1 , 2 , 3 ])
430413 exporter .storage .put ([1 , 2 , 3 ])
@@ -436,10 +419,8 @@ def test_transmission_200(self):
436419
437420 def test_transmission_206 (self ):
438421 exporter = trace_exporter .AzureExporter (
439- Options (
440- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
441- storage_path = os .path .join (TEST_FOLDER , '206' ),
442- ),
422+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
423+ storage_path = os .path .join (TEST_FOLDER , '206' ),
443424 )
444425 exporter .storage .put ([1 , 2 , 3 ])
445426 with mock .patch ('requests.post' ) as post :
@@ -450,10 +431,8 @@ def test_transmission_206(self):
450431
451432 def test_transmission_206_500 (self ):
452433 exporter = trace_exporter .AzureExporter (
453- Options (
454- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
455- storage_path = os .path .join (TEST_FOLDER , '206.500' ),
456- ),
434+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
435+ storage_path = os .path .join (TEST_FOLDER , '206.500' ),
457436 )
458437 exporter .storage .put ([1 , 2 , 3 , 4 , 5 ])
459438 with mock .patch ('requests.post' ) as post :
@@ -479,10 +458,8 @@ def test_transmission_206_500(self):
479458
480459 def test_transmission_206_nothing_to_retry (self ):
481460 exporter = trace_exporter .AzureExporter (
482- Options (
483- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
484- storage_path = os .path .join (TEST_FOLDER , 'nothing.to.retry' ),
485- ),
461+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
462+ storage_path = os .path .join (TEST_FOLDER , 'nothing.to.retry' ),
486463 )
487464 exporter .storage .put ([1 , 2 , 3 ])
488465 with mock .patch ('requests.post' ) as post :
@@ -502,10 +479,8 @@ def test_transmission_206_nothing_to_retry(self):
502479
503480 def test_transmission_206_bogus (self ):
504481 exporter = trace_exporter .AzureExporter (
505- Options (
506- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
507- storage_path = os .path .join (TEST_FOLDER , '206.bogus' ),
508- ),
482+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
483+ storage_path = os .path .join (TEST_FOLDER , '206.bogus' ),
509484 )
510485 exporter .storage .put ([1 , 2 , 3 , 4 , 5 ])
511486 with mock .patch ('requests.post' ) as post :
@@ -525,10 +500,8 @@ def test_transmission_206_bogus(self):
525500
526501 def test_transmission_400 (self ):
527502 exporter = trace_exporter .AzureExporter (
528- Options (
529- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
530- storage_path = os .path .join (TEST_FOLDER , '400' ),
531- ),
503+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
504+ storage_path = os .path .join (TEST_FOLDER , '400' ),
532505 )
533506 exporter .storage .put ([1 , 2 , 3 ])
534507 with mock .patch ('requests.post' ) as post :
@@ -538,10 +511,8 @@ def test_transmission_400(self):
538511
539512 def test_transmission_500 (self ):
540513 exporter = trace_exporter .AzureExporter (
541- Options (
542- instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
543- storage_path = os .path .join (TEST_FOLDER , '500' ),
544- ),
514+ instrumentation_key = '12345678-1234-5678-abcd-12345678abcd' ,
515+ storage_path = os .path .join (TEST_FOLDER , '500' ),
545516 )
546517 exporter .storage .put ([1 , 2 , 3 ])
547518 with mock .patch ('requests.post' ) as post :
0 commit comments