Skip to content

Commit f736537

Browse files
authored
Better App Names (#91)
* Better terminal detection * A better fallback option; remove service_name
1 parent 0a1a0fa commit f736537

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

instana/meter.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,17 @@ def process(self):
151151

152152
def collect_snapshot(self):
153153
try:
154-
if instana.service_name:
155-
appname = instana.service_name
156-
elif "FLASK_APP" in os.environ:
154+
if "FLASK_APP" in os.environ:
157155
appname = os.environ["FLASK_APP"]
158156
elif "DJANGO_SETTINGS_MODULE" in os.environ:
159157
appname = os.environ["DJANGO_SETTINGS_MODULE"].split('.')[0]
160-
elif hasattr(sys, '__interactivehook__') or (hasattr(sys, 'ps1') and hasattr(sys, 'ps2')):
158+
elif os.path.basename(sys.argv[0]) == '' and sys.stdout.isatty():
161159
appname = "Interactive Console"
162160
else:
163-
appname = os.path.basename(sys.argv[0])
161+
if os.path.basename(sys.argv[0]) == '':
162+
appname = os.path.basename(sys.executable)
163+
else:
164+
appname = os.path.basename(sys.argv[0])
164165

165166
s = Snapshot(name=appname, version=platform.version(),
166167
f=platform.python_implementation(),

0 commit comments

Comments
 (0)