Просмотр исходного кода

[misc] apply review feedback: adjust metric names

Co-Authored-By: Brian Gough <brian.gough@overleaf.com>

(cherry-picked from commit 67674b83efb452ece05cdc39525ee3a5eeb8a4d7)
Jakob Ackermann 6 лет назад
Родитель
Сommit
0b2cccf1e0

+ 6 - 6
services/real-time/app/coffee/WebsocketController.coffee

@@ -17,7 +17,7 @@ module.exports = WebsocketController =
 
 	joinProject: (client, user, project_id, callback = (error, project, privilegeLevel, protocolVersion) ->) ->
 		if client.disconnected
-			metrics.inc('disconnected_join_project')
+			metrics.inc('editor.join-project.disconnected', 1, {status: 'immediately'})
 			return callback()
 
 		user_id = user?._id
@@ -26,7 +26,7 @@ module.exports = WebsocketController =
 		WebApiManager.joinProject project_id, user, (error, project, privilegeLevel, isRestrictedUser) ->
 			return callback(error) if error?
 			if client.disconnected
-				metrics.inc('disconnected_join_project')
+				metrics.inc('editor.join-project.disconnected', 1, {status: 'after-web-api-call'})
 				return callback()
 
 			if !privilegeLevel or privilegeLevel == ""
@@ -85,7 +85,7 @@ module.exports = WebsocketController =
 
 	joinDoc: (client, doc_id, fromVersion = -1, options, callback = (error, doclines, version, ops, ranges) ->) ->
 		if client.disconnected
-				metrics.inc('disconnected_join_doc')
+				metrics.inc('editor.join-doc.disconnected', 1, {status: 'immediately'})
 				return callback()
 
 		metrics.inc "editor.join-doc"
@@ -101,14 +101,14 @@ module.exports = WebsocketController =
 				RoomManager.joinDoc client, doc_id, (error) ->
 					return callback(error) if error?
 					if client.disconnected
-						metrics.inc('disconnected_join_doc')
+						metrics.inc('editor.join-doc.disconnected', 1, {status: 'after-joining-room'})
 						# the client will not read the response anyways
 						return callback()
 
 					DocumentUpdaterManager.getDocument project_id, doc_id, fromVersion, (error, lines, version, ranges, ops) ->
 						return callback(error) if error?
 						if client.disconnected
-							metrics.inc('disconnected_join_doc')
+							metrics.inc('editor.join-doc.disconnected', 1, {status: 'after-doc-updater-call'})
 							# the client will not read the response anyways
 							return callback()
 
@@ -255,7 +255,7 @@ module.exports = WebsocketController =
 						setTimeout () ->
 							if client.disconnected
 								# skip the message broadcast, the client has moved on
-								return metrics.inc('disconnected_otUpdateError')
+								return metrics.inc('editor.doc-update.disconnected', 1, {status:'at-otUpdateError'})
 							client.emit "otUpdateError", message.error, message
 							client.disconnect()
 						, 100

+ 12 - 12
services/real-time/test/unit/coffee/WebsocketControllerTests.coffee

@@ -160,8 +160,8 @@ describe 'WebsocketController', ->
 			it "should call the callback with no details", ->
 				expect(@callback.args[0]).to.deep.equal []
 
-			it "should increment the disconnected_join_project metric", ->
-				expect(@metrics.inc.calledWith("disconnected_join_project")).to.equal(true)
+			it "should increment the editor.join-project.disconnected metric with a status", ->
+				expect(@metrics.inc.calledWith('editor.join-project.disconnected', 1, {status: 'immediately'})).to.equal(true)
 
 		describe "when the client disconnects while WebApiManager.joinProject is running", ->
 			beforeEach ->
@@ -174,8 +174,8 @@ describe 'WebsocketController', ->
 			it "should call the callback with no details", ->
 				expect(@callback.args[0]).to.deep.equal []
 
-			it "should increment the disconnected_join_project metric", ->
-				expect(@metrics.inc.calledWith("disconnected_join_project")).to.equal(true)
+			it "should increment the editor.join-project.disconnected metric with a status", ->
+				expect(@metrics.inc.calledWith('editor.join-project.disconnected', 1, {status: 'after-web-api-call'})).to.equal(true)
 
 	describe "leaveProject", ->
 		beforeEach ->
@@ -422,8 +422,8 @@ describe 'WebsocketController', ->
 			it "should call the callback with no details", ->
 				expect(@callback.args[0]).to.deep.equal([])
 
-			it "should increment the disconnected_join_doc metric", ->
-				expect(@metrics.inc.calledWith("disconnected_join_doc")).to.equal(true)
+			it "should increment the editor.join-doc.disconnected metric with a status", ->
+				expect(@metrics.inc.calledWith('editor.join-doc.disconnected', 1, {status: 'immediately'})).to.equal(true)
 
 			it "should not get the document", ->
 				expect(@DocumentUpdaterManager.getDocument.called).to.equal(false)
@@ -439,8 +439,8 @@ describe 'WebsocketController', ->
 			it "should call the callback with no details", ->
 				expect(@callback.args[0]).to.deep.equal([])
 
-			it "should increment the disconnected_join_doc metric", ->
-				expect(@metrics.inc.calledWith("disconnected_join_doc")).to.equal(true)
+			it "should increment the editor.join-doc.disconnected metric with a status", ->
+				expect(@metrics.inc.calledWith('editor.join-doc.disconnected', 1, {status: 'after-joining-room'})).to.equal(true)
 
 			it "should not get the document", ->
 				expect(@DocumentUpdaterManager.getDocument.called).to.equal(false)
@@ -456,8 +456,8 @@ describe 'WebsocketController', ->
 			it "should call the callback with no details", ->
 				expect(@callback.args[0]).to.deep.equal []
 
-			it "should increment the disconnected_join_doc metric", ->
-				expect(@metrics.inc.calledWith("disconnected_join_doc")).to.equal(true)
+			it "should increment the editor.join-doc.disconnected metric with a status", ->
+				expect(@metrics.inc.calledWith('editor.join-doc.disconnected', 1, {status: 'after-doc-updater-call'})).to.equal(true)
 
 	describe "leaveDoc", ->
 		beforeEach ->
@@ -847,8 +847,8 @@ describe 'WebsocketController', ->
 				it "should not disconnect the client", ->
 					@client.disconnect.called.should.equal false
 
-				it "should increment the disconnected_otUpdateError metric", ->
-					expect(@metrics.inc.calledWith("disconnected_otUpdateError")).to.equal(true)
+				it "should increment the editor.doc-update.disconnected metric with a status", ->
+					expect(@metrics.inc.calledWith('editor.doc-update.disconnected', 1, {status:'at-otUpdateError'})).to.equal(true)
 
 	describe "_assertClientCanApplyUpdate", ->
 		beforeEach ->