Skip to content

Commit 341269b

Browse files
committed
Merge branch 'master' into better-django
2 parents ecbcc8a + 857d08b commit 341269b

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

instana/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
__copyright__ = 'Copyright 2017 Instana Inc.'
2525
__credits__ = ['Pavlo Baron', 'Peter Giacomo Lombardo']
2626
__license__ = 'MIT'
27-
__version__ = '0.7.4'
27+
__version__ = '0.7.5'
2828
__maintainer__ = 'Peter Giacomo Lombardo'
2929
__email__ = '[email protected]'
3030

instana/fsm.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import os
2+
import sys
33
import socket
44
import subprocess
55
import threading as t
@@ -129,13 +129,24 @@ def announce_sensor(self, e):
129129
pid = os.getpid()
130130
cmdline = []
131131

132-
if os.path.isfile("/proc/self/cmdline"):
133-
with open("/proc/self/cmdline") as cmd:
134-
cmdinfo = cmd.read()
135-
cmdline = cmdinfo.split('\x00')
136-
else:
137-
cmdline = [sys.executable]
138-
cmdline += sys.argv
132+
try:
133+
if os.path.isfile("/proc/self/cmdline"):
134+
with open("/proc/self/cmdline") as cmd:
135+
cmdinfo = cmd.read()
136+
cmdline = cmdinfo.split('\x00')
137+
else:
138+
# Python doesn't provide a reliable method to determine what
139+
# the OS process command line may be. Here we are forced to
140+
# rely on ps rather than adding a dependency on something like
141+
# psutil which requires dev packages, gcc etc...
142+
proc = subprocess.Popen(["ps", "-p", str(pid), "-o", "command"],
143+
stdout=subprocess.PIPE)
144+
(out, err) = proc.communicate()
145+
parts = out.split(b'\n')
146+
cmdline = [parts[1].decode("utf-8")]
147+
except Exception as err:
148+
cmdline = sys.argv
149+
log.debug(err)
139150

140151
d = Discovery(pid=pid,
141152
name=cmdline[0],

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22

33
setup(name='instana',
4-
version='0.7.4',
4+
version='0.7.5',
55
download_url='https://github.com/instana/python-sensor',
66
url='https://www.instana.com/',
77
license='MIT',

0 commit comments

Comments
 (0)