mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-28 16:08:27 +00:00
Add config for setting up a jaeger opentracing reporter (#271)
* Add config for setting up a jaeger opentracing reporter * Remove redundant comment
This commit is contained in:
parent
4a0b24c7f4
commit
847621bc5d
10 changed files with 89 additions and 0 deletions
|
@ -91,3 +91,11 @@ listen:
|
||||||
media_api: "localhost:7774"
|
media_api: "localhost:7774"
|
||||||
public_rooms_api: "localhost:7775"
|
public_rooms_api: "localhost:7775"
|
||||||
federation_sender: "localhost:7776"
|
federation_sender: "localhost:7776"
|
||||||
|
|
||||||
|
# The configuration for tracing the dendrite components.
|
||||||
|
tracing:
|
||||||
|
# Config for the jaeger opentracing reporter.
|
||||||
|
# See https://godoc.org/github.com/uber/jaeger-client-go/config#Configuration
|
||||||
|
# for documtation.
|
||||||
|
jaeger:
|
||||||
|
disabled: true
|
||||||
|
|
|
@ -51,6 +51,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteClientAPI")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
||||||
aliasAPI := api.NewRoomserverAliasAPIHTTP(cfg.RoomServerURL(), nil)
|
aliasAPI := api.NewRoomserverAliasAPIHTTP(cfg.RoomServerURL(), nil)
|
||||||
inputAPI := api.NewRoomserverInputAPIHTTP(cfg.RoomServerURL(), nil)
|
inputAPI := api.NewRoomserverInputAPIHTTP(cfg.RoomServerURL(), nil)
|
||||||
|
|
|
@ -50,6 +50,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteFederationAPI")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
federation := gomatrixserverlib.NewFederationClient(
|
federation := gomatrixserverlib.NewFederationClient(
|
||||||
cfg.Matrix.ServerName, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey,
|
cfg.Matrix.ServerName, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey,
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,6 +47,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteFederationSender")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
kafkaConsumer, err := sarama.NewConsumer(cfg.Kafka.Addresses, nil)
|
kafkaConsumer, err := sarama.NewConsumer(cfg.Kafka.Addresses, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
|
|
|
@ -48,6 +48,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteMediaAPI")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
db, err := storage.Open(string(cfg.Database.MediaAPI))
|
db, err := storage.Open(string(cfg.Database.MediaAPI))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Panic("Failed to open database")
|
log.WithError(err).Panic("Failed to open database")
|
||||||
|
|
|
@ -83,6 +83,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteMonolith")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
m := newMonolith(cfg)
|
m := newMonolith(cfg)
|
||||||
m.setupDatabases()
|
m.setupDatabases()
|
||||||
m.setupFederation()
|
m.setupFederation()
|
||||||
|
|
|
@ -47,6 +47,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendritePublicRoomsAPI")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
||||||
|
|
||||||
db, err := storage.NewPublicRoomsServerDatabase(string(cfg.Database.PublicRoomsAPI))
|
db, err := storage.NewPublicRoomsServerDatabase(string(cfg.Database.PublicRoomsAPI))
|
||||||
|
|
|
@ -49,6 +49,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteRoomServer")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
db, err := storage.Open(string(cfg.Database.RoomServer))
|
db, err := storage.Open(string(cfg.Database.RoomServer))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -51,6 +51,12 @@ func main() {
|
||||||
log.Fatalf("Invalid config file: %s", err)
|
log.Fatalf("Invalid config file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closer, err := cfg.SetupTracing("DendriteSyncAPI")
|
||||||
|
if err != nil {
|
||||||
|
log.WithError(err).Fatalf("Failed to start tracer")
|
||||||
|
}
|
||||||
|
defer closer.Close() // nolint: errcheck
|
||||||
|
|
||||||
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
queryAPI := api.NewRoomserverQueryAPIHTTP(cfg.RoomServerURL(), nil)
|
||||||
|
|
||||||
db, err := storage.NewSyncServerDatabase(string(cfg.Database.SyncAPI))
|
db, err := storage.NewSyncServerDatabase(string(cfg.Database.SyncAPI))
|
||||||
|
|
|
@ -19,14 +19,19 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"golang.org/x/crypto/ed25519"
|
"golang.org/x/crypto/ed25519"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
||||||
|
jaegerconfig "github.com/uber/jaeger-client-go/config"
|
||||||
|
jaegermetrics "github.com/uber/jaeger-lib/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version is the current version of the config format.
|
// Version is the current version of the config format.
|
||||||
|
@ -156,6 +161,12 @@ type Dendrite struct {
|
||||||
FederationSender Address `yaml:"federation_sender"`
|
FederationSender Address `yaml:"federation_sender"`
|
||||||
PublicRoomsAPI Address `yaml:"public_rooms_api"`
|
PublicRoomsAPI Address `yaml:"public_rooms_api"`
|
||||||
} `yaml:"listen"`
|
} `yaml:"listen"`
|
||||||
|
|
||||||
|
// The config for tracing the dendrite servers.
|
||||||
|
Tracing struct {
|
||||||
|
// The config for the jaeger opentracing reporter.
|
||||||
|
Jaeger jaegerconfig.Configuration `yaml:"jaeger"`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Path on the filesystem.
|
// A Path on the filesystem.
|
||||||
|
@ -429,3 +440,25 @@ func (config *Dendrite) RoomServerURL() string {
|
||||||
// internet for an internal API.
|
// internet for an internal API.
|
||||||
return "http://" + string(config.Listen.RoomServer)
|
return "http://" + string(config.Listen.RoomServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetupTracing configures the opentracing using the supplied configuration.
|
||||||
|
func (config *Dendrite) SetupTracing(serviceName string) (closer io.Closer, err error) {
|
||||||
|
return config.Tracing.Jaeger.InitGlobalTracer(
|
||||||
|
serviceName,
|
||||||
|
jaegerconfig.Logger(logrusLogger{logrus.StandardLogger()}),
|
||||||
|
jaegerconfig.Metrics(jaegermetrics.NullFactory),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// logrusLogger is a small wrapper that implements jaeger.Logger using logrus.
|
||||||
|
type logrusLogger struct {
|
||||||
|
l *logrus.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l logrusLogger) Error(msg string) {
|
||||||
|
l.l.Error(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l logrusLogger) Infof(msg string, args ...interface{}) {
|
||||||
|
l.l.Infof(msg, args...)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue