Add trace logging to RoomserverInternalAPI (#1120)

This is a wrapper around whatever impl we have which then logs
the function name/request/response/error.

Also tweak when we log on kafka streams: only log on the producer
side not the consumer side: we've never had issues with comms and
having 1 message rather than N would be nice.
This commit is contained in:
Kegsay 2020-06-12 12:10:08 +01:00 committed by GitHub
parent 079d8fe8fb
commit 4675e1ddb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 261 additions and 21 deletions

View file

@ -17,9 +17,9 @@ package producers
import (
"encoding/json"
"github.com/matrix-org/dendrite/internal"
"github.com/Shopify/sarama"
"github.com/matrix-org/dendrite/internal"
log "github.com/sirupsen/logrus"
)
// SyncAPIProducer produces events for the sync API server to consume
@ -44,6 +44,11 @@ func (p *SyncAPIProducer) SendData(userID string, roomID string, dataType string
m.Topic = string(p.Topic)
m.Key = sarama.StringEncoder(userID)
m.Value = sarama.ByteEncoder(value)
log.WithFields(log.Fields{
"user_id": userID,
"room_id": roomID,
"data_type": dataType,
}).Infof("Producing to topic '%s'", p.Topic)
_, _, err = p.Producer.SendMessage(&m)
return err