Logging fixes
This commit is contained in:
@@ -59,7 +59,7 @@ class Connection(object):
|
|||||||
tracer.info("curl -X%s 'http://localhost:9200%s' -d '%s'", method, path, _pretty_json(body) if body else '')
|
tracer.info("curl -X%s 'http://localhost:9200%s' -d '%s'", method, path, _pretty_json(body) if body else '')
|
||||||
|
|
||||||
if tracer.isEnabledFor(logging.DEBUG):
|
if tracer.isEnabledFor(logging.DEBUG):
|
||||||
tracer.debug('# [%s] (%.3fs)\n#%s', status_code, duration, _pretty_json(response).replace('\n', '\n#') if response else '')
|
tracer.debug('#[%s] (%.3fs)\n#%s', status_code, duration, _pretty_json(response).replace('\n', '\n#') if response else '')
|
||||||
|
|
||||||
def log_request_fail(self, method, full_url, duration, status_code=None, exception=None):
|
def log_request_fail(self, method, full_url, duration, status_code=None, exception=None):
|
||||||
""" Log an unsuccessful API call. """
|
""" Log an unsuccessful API call. """
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
|
import logging
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Queue import PriorityQueue, Empty
|
from Queue import PriorityQueue, Empty
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from queue import PriorityQueue, Empty
|
from queue import PriorityQueue, Empty
|
||||||
|
|
||||||
|
logger = logging.getLogger('elasticsearch')
|
||||||
|
|
||||||
class ConnectionSelector(object):
|
class ConnectionSelector(object):
|
||||||
"""
|
"""
|
||||||
Simple class used to select a connection from a list of currently live
|
Simple class used to select a connection from a list of currently live
|
||||||
@@ -133,6 +136,10 @@ class ConnectionPool(object):
|
|||||||
self.dead_count[connection] = dead_count
|
self.dead_count[connection] = dead_count
|
||||||
timeout = self.dead_timeout * 2 ** min(dead_count - 1, self.timeout_cutoff)
|
timeout = self.dead_timeout * 2 ** min(dead_count - 1, self.timeout_cutoff)
|
||||||
self.dead.put((now + timeout, connection))
|
self.dead.put((now + timeout, connection))
|
||||||
|
logger.warning(
|
||||||
|
'Connection %r has failed for %i times in a row, putting on %i second timeout.',
|
||||||
|
connection, dead_count, timeout
|
||||||
|
)
|
||||||
|
|
||||||
def mark_live(self, connection):
|
def mark_live(self, connection):
|
||||||
"""
|
"""
|
||||||
@@ -175,6 +182,7 @@ class ConnectionPool(object):
|
|||||||
|
|
||||||
# either we were forced or the connection is elligible to be retried
|
# either we were forced or the connection is elligible to be retried
|
||||||
self.connections.append(connection)
|
self.connections.append(connection)
|
||||||
|
logger.info('Resurrecting connection %r (force=%s).', connection, force)
|
||||||
|
|
||||||
def get_connection(self):
|
def get_connection(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user