Skip to content

Commit 950a63e

Browse files
authored
Add metric logic for expected errors. (#221)
* Add logic for expected error metrics. * Update adpex_perf. * Update apdex logic. * Update expected conditional logic.
1 parent 840d771 commit 950a63e

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

newrelic/core/stats_engine.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,13 @@ def notice_error(self, error=None, attributes={}, expected=None, ignore=None, st
732732
self.__transaction_errors.append(error_details)
733733

734734
# Regardless of whether we record the trace or the event we still
735-
# want to increment the metric Errors/all
736-
self.record_time_metric(TimeMetric(name='Errors/all', scope='',
735+
# want to increment the metric Errors/all unless the error was marked
736+
# as expected
737+
if is_expected:
738+
self.record_time_metric(TimeMetric(name='ErrorsExpected/all', scope='',
739+
duration=0.0, exclusive=None))
740+
else:
741+
self.record_time_metric(TimeMetric(name='Errors/all', scope='',
737742
duration=0.0, exclusive=None))
738743

739744
def _error_event(self, error):

newrelic/core/transaction_node.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,26 +209,33 @@ def time_metrics(self, stats):
209209
# Generate Error metrics
210210

211211
if self.errors:
212-
# Generate overall rollup metric indicating if errors present.
213-
yield TimeMetric(
212+
if False in (error.expected for error in self.errors):
213+
# Generate overall rollup metric indicating if errors present.
214+
yield TimeMetric(
214215
name='Errors/all',
215216
scope='',
216217
duration=0.0,
217218
exclusive=None)
218219

219-
# Generate individual error metric for transaction.
220-
yield TimeMetric(
220+
# Generate individual error metric for transaction.
221+
yield TimeMetric(
221222
name='Errors/%s' % self.path,
222223
scope='',
223224
duration=0.0,
224225
exclusive=None)
225226

226-
# Generate rollup metric for WebTransaction errors.
227-
yield TimeMetric(
227+
# Generate rollup metric for WebTransaction errors.
228+
yield TimeMetric(
228229
name='Errors/all%s' % metric_suffix,
229230
scope='',
230231
duration=0.0,
231232
exclusive=None)
233+
else:
234+
yield TimeMetric(
235+
name='ErrorsExpected/all',
236+
scope='',
237+
duration=0.0,
238+
exclusive=None)
232239

233240
# Now for the children.
234241
for child in self.root.children:
@@ -260,7 +267,7 @@ def apdex_metrics(self, stats):
260267
tolerating = 0
261268
frustrating = 0
262269

263-
if self.errors:
270+
if self.errors and False in (error.expected for error in self.errors):
264271
frustrating = 1
265272
else:
266273
if self.duration <= self.apdex_t:
@@ -397,7 +404,7 @@ def apdex_perf_zone(self):
397404
if self.type != 'WebTransaction':
398405
return None
399406

400-
if self.errors:
407+
if self.errors and False in (error.expected for error in self.errors):
401408
return 'F'
402409
else:
403410
if self.duration <= self.apdex_t:

0 commit comments

Comments
 (0)