Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit a88ac71

Browse files
authored
Merge pull request #44 from helgi/patch-4
Support env var in configuration for the Name in the component
2 parents e0b2f02 + beb0097 commit a88ac71

File tree

1 file changed

+7
-1
lines changed
  • newrelic_python_agent/plugins

1 file changed

+7
-1
lines changed

newrelic_python_agent/plugins/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import time
1212
import urlparse
1313
import six
14+
import os
1415

1516
LOGGER = logging.getLogger(__name__)
1617

@@ -296,7 +297,12 @@ def name(self):
296297
:rtype: str
297298
298299
"""
299-
return self.config.get('name', socket.gethostname().split('.')[0])
300+
value = self.config.get('name', socket.gethostname().split('.')[0])
301+
if isinstance(value, six.string_types) and value[0] == "$":
302+
# strip the $, check if the env var exists, otherwise fallback
303+
value = os.getenv(value[1:], value)
304+
305+
return value
300306

301307
def poll(self):
302308
"""Poll the server returning the results in the expected component

0 commit comments

Comments
 (0)