summaryrefslogtreecommitdiffstats
path: root/config_binding_service/client.py
diff options
context:
space:
mode:
authorTommy Carpenter <tommy@research.att.com>2018-03-09 10:41:05 -0500
committerTommy Carpenter <tommy@research.att.com>2018-03-11 11:14:57 -0400
commit226719d5b23c7b82940a0e4c5b6922eead419788 (patch)
treef1bb5016e6842a4c2cf78231e6ca53d3c41b8c24 /config_binding_service/client.py
parent914d8ccb42befc04ec5b759dd84b242591bb5e91 (diff)
Implement logging that can get to ELK
This adds more logging into the front end, and also logs to a file so ELK can get them. All public calls to the CBS are logged with the return code. This is not to say logging is completed in the CBS, more may come later and under a more structured format. Change-Id: I63c966876972e06c51276eaf1204b5b9b9e6cea7 Issue-ID: DCAEGEN2-387 Signed-off-by: Tommy Carpenter <tommy@research.att.com>
Diffstat (limited to 'config_binding_service/client.py')
-rw-r--r--config_binding_service/client.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/config_binding_service/client.py b/config_binding_service/client.py
index 2c04684..51ce3b1 100644
--- a/config_binding_service/client.py
+++ b/config_binding_service/client.py
@@ -23,9 +23,10 @@ import copy
import json
import requests
import six
-from config_binding_service import get_consul_uri, get_logger
+from config_binding_service import get_consul_uri
+from config_binding_service.logging import LOGGER
+
-_logger = get_logger(__name__)
CONSUL = get_consul_uri()
template_match_rels = re.compile("\{{2}([^\}\{]*)\}{2}")
@@ -111,23 +112,20 @@ def _get_connection_info_from_consul(service_component_name):
TODO: WARNING: FIXTHIS: CALLINTHENATIONALARMY:
This tries to determine that a service_component_name is a cdap application by inspecting service_component_name and name munging. However, this would force all CDAP applications to have cdap_app in their name. A much better way to do this is to do some kind of catalog_lookup here, OR MAYBE change this API so that the component_type is passed in somehow. THis is a gaping TODO.
"""
- _logger.info("Retrieving connection information for {0}".format(
- service_component_name))
+ LOGGER.info("Retrieving connection information for %s", service_component_name)
res = requests.get(
"{0}/v1/catalog/service/{1}".format(CONSUL, service_component_name))
res.raise_for_status()
services = res.json()
if services == []:
- _logger.info("Warning: config and rels keys were both valid, but there is no component named {0} registered in Consul!".format(
- service_component_name))
+ LOGGER.info("Warning: config and rels keys were both valid, but there is no component named %s registered in Consul!", service_component_name)
return None # later will get filtered out
ip_addr = services[0]["ServiceAddress"]
port = services[0]["ServicePort"]
if "cdap_app" in service_component_name:
redirectish_url = "http://{0}:{1}/application/{2}".format(
ip_addr, port, service_component_name)
- _logger.info("component is a CDAP application; trying the broker redirect on {0}".format(
- redirectish_url))
+ LOGGER.info("component is a CDAP application; trying the broker redirect on %s", redirectish_url)
res = requests.get(redirectish_url)
res.raise_for_status()
details = res.json()