Skip to content

Commit

Permalink
refactor(runtime): Use a constant for the deprecated installation path
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Géczi <[email protected]>
  • Loading branch information
Ferenc- committed Oct 26, 2023
1 parent d42a7fa commit 5212cf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion instana/collector/helpers/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from .base import BaseHelper

PATH_OF_DEPRECATED_INSTALLATION_VIA_HOST_AGENT = '/tmp/.instana/python'

class RuntimeHelper(BaseHelper):
""" Helper class to collect snapshot and metrics for this Python runtime """
Expand Down Expand Up @@ -181,7 +182,7 @@ def _collect_runtime_snapshot(self, plugin_data):

if 'AUTOWRAPT_BOOTSTRAP' in os.environ:
snapshot_payload['m'] = 'Autowrapt'
elif '/tmp/.instana/python' in sys.path:
elif PATH_OF_DEPRECATED_INSTALLATION_VIA_HOST_AGENT in sys.path:
snapshot_payload['m'] = 'AutoTrace'
else:
snapshot_payload['m'] = 'Manual'
Expand Down
8 changes: 4 additions & 4 deletions tests/platforms/test_host_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from instana.tracer import InstanaTracer
from instana.recorder import StanRecorder
from instana.agent.host import HostAgent
from instana.collector.helpers.runtime import PATH_OF_DEPRECATED_INSTALLATION_VIA_HOST_AGENT
from instana.collector.host import HostCollector
from instana.singletons import get_agent, set_agent, get_tracer, set_tracer
from instana.version import VERSION


class TestHostCollector(unittest.TestCase):
def __init__(self, methodName='runTest'):
super(TestHostCollector, self).__init__(methodName)
Expand Down Expand Up @@ -47,8 +47,8 @@ def tearDown(self):

set_agent(self.original_agent)
set_tracer(self.original_tracer)
if '/tmp/.instana/python' in sys.path:
sys.path.remove('/tmp/.instana/python')
if PATH_OF_DEPRECATED_INSTALLATION_VIA_HOST_AGENT in sys.path:
sys.path.remove(PATH_OF_DEPRECATED_INSTALLATION_VIA_HOST_AGENT)

def create_agent_and_setup_tracer(self):
self.agent = HostAgent()
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_prepare_payload_with_autowrapt(self, mock_should_send_snapshot_data):
def test_prepare_payload_with_autotrace(self, mock_should_send_snapshot_data):
mock_should_send_snapshot_data.return_value = True

sys.path.append('/tmp/.instana/python')
sys.path.append(PATH_OF_DEPRECATED_INSTALLATION_VIA_HOST_AGENT)

self.create_agent_and_setup_tracer()

Expand Down

0 comments on commit 5212cf0

Please sign in to comment.