Skip to content

Commit 72e1477

Browse files
authored
Centralize boot logic and include singletons (#126)
1 parent b32d81d commit 72e1477

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

instana/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ def load(module):
5454
# User configurable EUM API key for instana.helpers.eum_snippet()
5555
eum_api_key = ''
5656

57-
import instana.singletons #noqa
5857

58+
def boot_agent():
59+
import instana.singletons # noqa
5960

60-
def load_instrumentation():
6161
if "INSTANA_DISABLE_AUTO_INSTR" not in os.environ:
6262
# Import & initialize instrumentation
63-
if sys.version_info >= (3, 4) and sys.version_info < (3, 7):
63+
if (sys.version_info >= (3, 4)) and (sys.version_info < (3, 7)):
6464
from .instrumentation import asynqp # noqa
6565
from .instrumentation import mysqlpython # noqa
6666
from .instrumentation import redis # noqa
@@ -71,9 +71,8 @@ def load_instrumentation():
7171

7272

7373
if "INSTANA_MAGIC" in os.environ:
74-
# If we're being loaded into an already running process, then delay
75-
# instrumentation load.
76-
t = Timer(2.0, load_instrumentation)
74+
# If we're being loaded into an already running process, then delay agent initialization
75+
t = Timer(3.0, boot_agent)
7776
t.start()
7877
else:
79-
load_instrumentation()
78+
boot_agent()

instana/singletons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
from opentracing.scope_managers.asyncio import AsyncioScopeManager
2323
async_tracer = InstanaTracer(AsyncioScopeManager())
2424

25-
# Set ourselves as the tracer.
25+
# Set ourselves as the tracer.
2626
opentracing.tracer = tracer

0 commit comments

Comments
 (0)