Skip to content

Commit

Permalink
Hostname lookup from config to debug and on/off setup
Browse files Browse the repository at this point in the history
  • Loading branch information
David Bouchare committed Aug 16, 2019
1 parent c638abf commit 5a14086
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions datadog/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
_backoff_period = 300
_mute = True

# Agent config settings
config_lookup = False

# Resources
from datadog.api.comments import Comment
from datadog.api.dashboard_lists import DashboardList
Expand Down
12 changes: 7 additions & 5 deletions datadog/util/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import types

# datadog
from datadog.api import config_lookup
from datadog.util.compat import url_lib, is_p3k, iteritems
from datadog.util.config import get_config, get_os, CfgNotFound

Expand Down Expand Up @@ -52,12 +53,13 @@ def get_hostname():

# first, try the config
try:
config = get_config()
config_hostname = config.get('hostname')
if config_hostname and is_valid_hostname(config_hostname):
return config_hostname
if config_lookup:
config = get_config()
config_hostname = config.get('hostname')
if config_hostname and is_valid_hostname(config_hostname):
return config_hostname
except CfgNotFound:
log.info("No agent or invalid configuration file found")
log.debug("No agent or invalid configuration file found")

# Try to get GCE instance name
if hostname is None:
Expand Down

0 comments on commit 5a14086

Please sign in to comment.