mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[misc] track redis pub/sub payload sizes on publish
This commit is contained in:
parent
a9b8e9be3b
commit
56628a16c6
3 changed files with 16 additions and 2 deletions
|
@ -163,10 +163,13 @@ if Settings.continualPubsubTraffic
|
|||
checker = new HealthCheckManager(channel)
|
||||
logger.debug {channel:channel}, "sending pub to keep connection alive"
|
||||
json = JSON.stringify({health_check:true, key: checker.id, date: new Date().toString()})
|
||||
Metrics.summary "redis.publish.#{channel}", json.length
|
||||
pubsubClient.publish channel, json, (err)->
|
||||
if err?
|
||||
logger.err {err, channel}, "error publishing pubsub traffic to redis"
|
||||
clusterClient.publish "cluster-continual-traffic", {keep: "alive"}, callback
|
||||
blob = JSON.stringify({keep: "alive"})
|
||||
Metrics.summary "redis.publish.cluster-continual-traffic", blob.length
|
||||
clusterClient.publish "cluster-continual-traffic", blob, callback
|
||||
|
||||
|
||||
runPubSubTraffic = ->
|
||||
|
|
|
@ -48,6 +48,7 @@ module.exports = ChannelManager =
|
|||
metrics.inc "unsubscribe.#{baseChannel}"
|
||||
|
||||
publish: (rclient, baseChannel, id, data) ->
|
||||
metrics.summary "redis.publish.#{baseChannel}", data.length
|
||||
if id is 'all' or !settings.publishOnIndividualChannels
|
||||
channel = baseChannel
|
||||
else
|
||||
|
|
|
@ -10,7 +10,7 @@ describe 'ChannelManager', ->
|
|||
@other_rclient = {}
|
||||
@ChannelManager = SandboxedModule.require modulePath, requires:
|
||||
"settings-sharelatex": @settings = {}
|
||||
"metrics-sharelatex": @metrics = {inc: sinon.stub()}
|
||||
"metrics-sharelatex": @metrics = {inc: sinon.stub(), summary: sinon.stub()}
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), warn: sinon.stub(), error: sinon.stub() }
|
||||
|
||||
describe "subscribe", ->
|
||||
|
@ -106,3 +106,13 @@ describe 'ChannelManager', ->
|
|||
@rclient.publish.calledWithExactly("applied-ops:1234567890abcdef", "random-message").should.equal true
|
||||
@rclient.publish.calledOnce.should.equal true
|
||||
|
||||
describe "metrics", ->
|
||||
beforeEach ->
|
||||
@rclient.publish = sinon.stub()
|
||||
@ChannelManager.publish @rclient, "applied-ops", "all", "random-message"
|
||||
|
||||
it "should track the payload size", ->
|
||||
@metrics.summary.calledWithExactly(
|
||||
"redis.publish.applied-ops",
|
||||
"random-message".length
|
||||
).should.equal true
|
||||
|
|
Loading…
Reference in a new issue