Skip to content

Commit 4b14137

Browse files
authored
Improved Logger Naming & Formatting (#82)
* Use appropriate Logger formatting & naming * Warn only once when Host agent not found On boot if the Host agent is not found, the following message will be output only once to reduce log spam (warn level) "Instana Host agent not found. Will retry periodically..." Previously this message was emitted on INFO level every 30 seconds.
1 parent 3810da6 commit 4b14137

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

instana/fsm.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class Fsm(object):
3636
fsm = None
3737
timer = None
3838

39+
warnedPeriodic = False
40+
3941
def __init__(self, agent):
4042
log.info("Stan is on the scene. Starting Instana instrumentation version", instana.__version__)
4143
log.debug("initializing fsm")
@@ -104,7 +106,10 @@ def lookup_agent_host(self, e):
104106
self.fsm.announce()
105107
return True
106108

107-
log.info("Instana Host Agent couldn't be found. Scheduling retry.")
109+
if (self.warnedPeriodic is False):
110+
log.warn("Instana Host Agent couldn't be found. Will retry periodically...")
111+
self.warnedPeriodic = True
112+
108113
self.schedule_retry(self.lookup_agent_host, e, "agent_lookup")
109114
return False
110115

instana/log.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import logging as log
22
import os
33

4-
logger = log.getLogger('instana(' + str(os.getpid()) + ')')
5-
4+
logger = log.getLogger('instana')
65

76
def init(level):
87
ch = log.StreamHandler()
9-
f = log.Formatter('%(asctime)s: %(levelname)s: %(name)s: %(message)s')
8+
f = log.Formatter('%(asctime)s: %(process)d %(levelname)s %(name)s: %(message)s')
109
ch.setFormatter(f)
1110
logger.addHandler(ch)
1211
if "INSTANA_DEV" in os.environ:

0 commit comments

Comments
 (0)