33import opentracing
44
55from .agent import StandardAgent , AWSLambdaAgent
6+ from .log import logger
67from .tracer import InstanaTracer
78from .recorder import StandardRecorder , AWSLambdaRecorder
89
1819 span_recorder = StandardRecorder ()
1920
2021
21- # Retrieve the globally configured agent
2222def get_agent ():
23+ """
24+ Retrieve the globally configured agent
25+ @return: The Instana Agent singleton
26+ """
2327 global agent
2428 return agent
2529
2630
27- # Set the global agent for the Instana package. This is used for the
28- # test suite only currently.
2931def set_agent (new_agent ):
32+ """
33+ Set the global agent for the Instana package. This is used for the
34+ test suite only currently.
35+
36+ @param new_agent: agent to replace current singleton
37+ @return: None
38+ """
3039 global agent
3140 agent = new_agent
3241
@@ -36,8 +45,11 @@ def set_agent(new_agent):
3645tracer = InstanaTracer (recorder = span_recorder )
3746
3847if sys .version_info >= (3 , 4 ):
39- from opentracing .scope_managers .asyncio import AsyncioScopeManager
40- async_tracer = InstanaTracer (scope_manager = AsyncioScopeManager (), recorder = span_recorder )
48+ try :
49+ from opentracing .scope_managers .asyncio import AsyncioScopeManager
50+ async_tracer = InstanaTracer (scope_manager = AsyncioScopeManager (), recorder = span_recorder )
51+ except Exception :
52+ logger .debug ("Error setting up async_tracer:" , exc_info = True )
4153
4254
4355# Mock the tornado tracer until tornado is detected and instrumented first
@@ -54,14 +66,21 @@ def setup_tornado_tracer():
5466opentracing .tracer = tracer
5567
5668
57- # Retrieve the globally configured tracer
5869def get_tracer ():
70+ """
71+ Retrieve the globally configured tracer
72+ @return: Tracer
73+ """
5974 global tracer
6075 return tracer
6176
6277
63- # Set the global tracer for the Instana package. This is used for the
64- # test suite only currently.
6578def set_tracer (new_tracer ):
79+ """
80+ Set the global tracer for the Instana package. This is used for the
81+ test suite only currently.
82+ @param new_tracer: The new tracer to replace the singleton
83+ @return: None
84+ """
6685 global tracer
6786 tracer = new_tracer
0 commit comments