Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Do not requeue all responses #2840

Merged
merged 2 commits into from
Oct 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions checks/check_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ class ForwarderStatus(AgentStatus):
NAME = 'Forwarder'

def __init__(self, queue_length=0, queue_size=0, flush_count=0, transactions_received=0,
transactions_flushed=0, too_big_count=0):
transactions_flushed=0, transactions_rejected=0):
AgentStatus.__init__(self)
self.queue_length = queue_length
self.queue_size = queue_size
Expand All @@ -772,7 +772,7 @@ def __init__(self, queue_length=0, queue_size=0, flush_count=0, transactions_rec
self.transactions_flushed = transactions_flushed
self.hidden_username = None
self.hidden_password = None
self.too_big_count = too_big_count
self.transactions_rejected = transactions_rejected

def body_lines(self):
lines = [
Expand All @@ -781,7 +781,7 @@ def body_lines(self):
"Flush Count: %s" % self.flush_count,
"Transactions received: %s" % self.transactions_received,
"Transactions flushed: %s" % self.transactions_flushed,
"Transactions rejected: %s" % self.too_big_count,
"Transactions rejected: %s" % self.transactions_rejected,
""
]

Expand All @@ -796,7 +796,7 @@ def to_dict(self):
'flush_count': self.flush_count,
'queue_length': self.queue_length,
'queue_size': self.queue_size,
'too_big_count': self.too_big_count,
'transactions_rejected': self.transactions_rejected,
'transactions_received': self.transactions_received,
'transactions_flushed': self.transactions_flushed
})
Expand Down
7 changes: 5 additions & 2 deletions ddagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
# Maximum queue size in bytes (when this is reached, old messages are dropped)
MAX_QUEUE_SIZE = 30 * 1024 * 1024 # 30MB

# Some responses should be rejected, rather than replayed. This list will be rejected.
RESPONSES_TO_REJECT = [413, 400]

THROTTLING_DELAY = timedelta(microseconds=1000000 / 2) # 2 msg/second


Expand Down Expand Up @@ -273,8 +276,8 @@ def flush(self):
def on_response(self, response):
if response.error:
log.error("Response: %s" % response)
if response.code == 413:
self._trManager.tr_error_too_big(self)
if response.code in RESPONSES_TO_REJECT:
self._trManager.tr_error_reject_request(self)
else:
self._trManager.tr_error(self)
else:
Expand Down
10 changes: 5 additions & 5 deletions transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, max_wait_for_replay, max_queue_size, throttling_delay,
self._transactions_received = 0
self._transactions_flushed = 0

self._too_big_count = 0
self._transactions_rejected = 0

# Global counter to assign a number to each transaction: we may have an issue
# if this overlaps
Expand Down Expand Up @@ -192,7 +192,7 @@ def flush(self):
flush_count=self._flush_count,
transactions_received=self._transactions_received,
transactions_flushed=self._transactions_flushed,
too_big_count=self._too_big_count).persist()
transactions_rejected=self._transactions_rejected).persist()

def flush_next(self):

Expand Down Expand Up @@ -262,7 +262,7 @@ def tr_error(self, tr):

self._trs_to_flush = new_trs_to_flush

def tr_error_too_big(self, tr):
def tr_error_reject_request(self, tr):
self._running_flushes -= 1
self._finished_flushes += 1
tr.inc_error_count()
Expand All @@ -275,14 +275,14 @@ def tr_error_too_big(self, tr):
self._total_size -= tr.get_size()
self._transactions_flushed += 1
self.print_queue_stats()
self._too_big_count += 1
self._transactions_rejected += 1
ForwarderStatus(
queue_length=self._total_count,
queue_size=self._total_size,
flush_count=self._flush_count,
transactions_received=self._transactions_received,
transactions_flushed=self._transactions_flushed,
too_big_count=self._too_big_count).persist()
transactions_rejected=self._transactions_rejected).persist()

def tr_success(self, tr):
self._running_flushes -= 1
Expand Down
2 changes: 1 addition & 1 deletion win32/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ <h2>Forwarder</h2>
<dt>Queue length</dt> <dd>{{ forwarder['queue_length'] }}</dd>
<dt>Transactions received</dt> <dd>{{ forwarder['transactions_received'] }}</dd>
<dt>Transactions flushed</dt> <dd>{{ forwarder['transactions_flushed'] }}</dd>
<dt>Transactions rejected</dt> <dd>{{ forwarder['too_big_count'] }}</dd>
<dt>Transactions rejected</dt> <dd>{{ forwarder['transactions_rejected'] }}</dd>
</dl>

<!-- Dogstatsd -->
Expand Down