mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-13 23:47:44 +00:00
don't go crazy on emitting stats
This commit is contained in:
parent
df0860dd05
commit
0e342803a1
2 changed files with 7 additions and 4 deletions
|
@ -29,6 +29,8 @@ const (
|
||||||
usernameMentionNotificationTitleFormat = "Mention in \u201c%s\u201d"
|
usernameMentionNotificationTitleFormat = "Mention in \u201c%s\u201d"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var notificationTags = []string{"queue:notifications"}
|
||||||
|
|
||||||
type notificationsWorker struct {
|
type notificationsWorker struct {
|
||||||
context.Context
|
context.Context
|
||||||
|
|
||||||
|
@ -138,7 +140,8 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
defer func() {
|
defer func() {
|
||||||
elapsed := time.Now().Sub(now).Milliseconds()
|
elapsed := time.Now().Sub(now).Milliseconds()
|
||||||
_ = nc.statsd.Histogram("apollo.consumer.runtime", float64(elapsed), []string{"queue:notifications"}, 0.1)
|
_ = nc.statsd.Histogram("apollo.consumer.runtime", float64(elapsed), notificationTags, 0.1)
|
||||||
|
_ = nc.statsd.Incr("apollo.consumer.executions", notificationTags, 0.1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
id := delivery.Payload()
|
id := delivery.Payload()
|
||||||
|
@ -147,7 +150,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
|
||||||
// Measure queue latency
|
// Measure queue latency
|
||||||
ttl := nc.redis.PTTL(ctx, key).Val()
|
ttl := nc.redis.PTTL(ctx, key).Val()
|
||||||
age := (domain.NotificationCheckTimeout - ttl)
|
age := (domain.NotificationCheckTimeout - ttl)
|
||||||
_ = nc.statsd.Histogram("apollo.dequeue.latency", float64(age.Milliseconds()), []string{"queue:notifications"}, 0.1)
|
_ = nc.statsd.Histogram("apollo.dequeue.latency", float64(age.Milliseconds()), notificationTags, 0.1)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := nc.redis.Del(ctx, key).Err(); err != nil {
|
if err := nc.redis.Del(ctx, key).Err(); err != nil {
|
||||||
|
|
|
@ -87,11 +87,11 @@ services:
|
||||||
- key: BUGSNAG_METADATA_QUEUE
|
- key: BUGSNAG_METADATA_QUEUE
|
||||||
value: notifications
|
value: notifications
|
||||||
scaling:
|
scaling:
|
||||||
minInstances: 20
|
minInstances: 30
|
||||||
maxInstances: 50
|
maxInstances: 50
|
||||||
targetCPUPercent: 60
|
targetCPUPercent: 60
|
||||||
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
|
buildCommand: go install github.com/bugsnag/panic-monitor@latest && go build ./cmd/apollo
|
||||||
startCommand: panic-monitor ./apollo worker --queue notifications --consumers 512
|
startCommand: panic-monitor ./apollo worker --queue notifications --consumers 1024
|
||||||
|
|
||||||
# Stuck Notifications Checker
|
# Stuck Notifications Checker
|
||||||
- type: worker
|
- type: worker
|
||||||
|
|
Loading…
Reference in a new issue