mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-02 23:23:38 +00:00
add missing argument to metrics.inc
also track retries rather than attempts (which is always 1 for a successful request)
This commit is contained in:
parent
3caa0e7c05
commit
7036803acf
2 changed files with 13 additions and 13 deletions
|
@ -21,11 +21,11 @@ updateMetric = (method, error, response) ->
|
|||
error.code
|
||||
else if response?
|
||||
response.statusCode
|
||||
Metrics.inc method, {status: status}
|
||||
if error?.attempts > 0
|
||||
Metrics.inc "#{method}-attempts", {status: 'error'}
|
||||
if response?.attempts > 0
|
||||
Metrics.inc "#{method}-attempts", {status: 'success'}
|
||||
Metrics.inc method, 1, {status: status}
|
||||
if error?.attempts > 1
|
||||
Metrics.inc "#{method}-retries", 1, {status: 'error'}
|
||||
if response?.attempts > 1
|
||||
Metrics.inc "#{method}-retries", 1, {status: 'success'}
|
||||
|
||||
module.exports = PersistenceManager =
|
||||
getDoc: (project_id, doc_id, _callback = (error, lines, version, ranges, pathname, projectHistoryId, projectHistoryType) ->) ->
|
||||
|
|
|
@ -73,7 +73,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("getDoc", {status: 200}).should.equal true
|
||||
@Metrics.inc.calledWith("getDoc", 1, {status: 200}).should.equal true
|
||||
|
||||
describe "when request returns an error", ->
|
||||
beforeEach ->
|
||||
|
@ -89,7 +89,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("getDoc", {status: "EOOPS"}).should.equal true
|
||||
@Metrics.inc.calledWith("getDoc", 1, {status: "EOOPS"}).should.equal true
|
||||
|
||||
describe "when the request returns 404", ->
|
||||
beforeEach ->
|
||||
|
@ -103,7 +103,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("getDoc", {status: 404}).should.equal true
|
||||
@Metrics.inc.calledWith("getDoc", 1, {status: 404}).should.equal true
|
||||
|
||||
describe "when the request returns an error status code", ->
|
||||
beforeEach ->
|
||||
|
@ -117,7 +117,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("getDoc", {status: 500}).should.equal true
|
||||
@Metrics.inc.calledWith("getDoc", 1, {status: 500}).should.equal true
|
||||
|
||||
describe "when request returns an doc without lines", ->
|
||||
beforeEach ->
|
||||
|
@ -179,7 +179,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("setDoc", {status: 200}).should.equal true
|
||||
@Metrics.inc.calledWith("setDoc", 1, {status: 200}).should.equal true
|
||||
|
||||
describe "when request returns an error", ->
|
||||
beforeEach ->
|
||||
|
@ -195,7 +195,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("setDoc", {status: "EOOPS"}).should.equal true
|
||||
@Metrics.inc.calledWith("setDoc", 1, {status: "EOOPS"}).should.equal true
|
||||
|
||||
describe "when the request returns 404", ->
|
||||
beforeEach ->
|
||||
|
@ -209,7 +209,7 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("setDoc", {status: 404}).should.equal true
|
||||
@Metrics.inc.calledWith("setDoc", 1, {status: 404}).should.equal true
|
||||
|
||||
describe "when the request returns an error status code", ->
|
||||
beforeEach ->
|
||||
|
@ -223,4 +223,4 @@ describe "PersistenceManager", ->
|
|||
@Metrics.Timer::done.called.should.equal true
|
||||
|
||||
it "should increment the metric", ->
|
||||
@Metrics.inc.calledWith("setDoc", {status: 500}).should.equal true
|
||||
@Metrics.inc.calledWith("setDoc", 1, {status: 500}).should.equal true
|
||||
|
|
Loading…
Reference in a new issue