mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-04-19 02:03:39 +00:00
linting, remove some unnecessary code
This commit is contained in:
parent
6649f77076
commit
5177a384f8
5 changed files with 20 additions and 38 deletions
|
@ -31,13 +31,6 @@ func main() {
|
|||
|
||||
federation := base.CreateFederationClient()
|
||||
|
||||
/* TODO delete
|
||||
err = tracers.InitGlobalTracer("Dendrite - Federation Sender")
|
||||
if err != nil {
|
||||
log.WithError(err).Fatalf("Failed to start tracer")
|
||||
}
|
||||
*/
|
||||
|
||||
_, _, query := base.CreateHTTPRoomserverAPIs()
|
||||
|
||||
federationsender.SetupFederationSenderComponent(
|
||||
|
|
|
@ -18,7 +18,7 @@ type statusCodeResponseWriter struct {
|
|||
statusCode int
|
||||
}
|
||||
|
||||
func NewStatusCodeResponseWriter(w http.ResponseWriter) *statusCodeResponseWriter {
|
||||
func newStatusCodeResponseWriter(w http.ResponseWriter) *statusCodeResponseWriter {
|
||||
return &statusCodeResponseWriter{w, http.StatusOK}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func MakeExternalAPI(tracer opentracing.Tracer, metricsName string, f func(*http
|
|||
ext.HTTPMethod.Set(span, req.Method)
|
||||
|
||||
req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span))
|
||||
rw := NewStatusCodeResponseWriter(w)
|
||||
rw := newStatusCodeResponseWriter(w)
|
||||
|
||||
h.ServeHTTP(w, req)
|
||||
ext.HTTPStatusCode.Set(span, uint16(rw.statusCode))
|
||||
|
@ -91,7 +91,7 @@ func MakeInternalAPI(tracer opentracing.Tracer, metricsName string, f func(*http
|
|||
ext.HTTPUrl.Set(span, req.URL.String())
|
||||
ext.HTTPMethod.Set(span, req.Method)
|
||||
|
||||
// TODO: Do we need to do the NewStatusCodeResponseWriter stuff?
|
||||
// TODO: Do we need to do the newStatusCodeResponseWriter stuff?
|
||||
|
||||
req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span))
|
||||
h.ServeHTTP(w, req)
|
||||
|
|
|
@ -24,43 +24,29 @@ import (
|
|||
jaegermetrics "github.com/uber/jaeger-lib/metrics"
|
||||
)
|
||||
|
||||
// Tracers is a collection of Jaeger OpenTracing tracers. There is one tracer
|
||||
// per Dendrite component, and each is kept track of with a single Tracers
|
||||
// object. Upon shutdown, each tracer is closed by calling the Tracers' Close()
|
||||
// method.
|
||||
type Tracers struct {
|
||||
cfg *config.Dendrite
|
||||
closers []io.Closer
|
||||
}
|
||||
|
||||
// NoopTracers is a Tracers object that will never contain any tracers. Disables tracing.
|
||||
func NoopTracers() *Tracers {
|
||||
return &Tracers{}
|
||||
}
|
||||
|
||||
// NewTracers creates a new Tracers object with the given Dendrite config.
|
||||
func NewTracers(cfg *config.Dendrite) *Tracers {
|
||||
return &Tracers{
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Tracers) InitGlobalTracer(serviceName string) error {
|
||||
if t.cfg == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Set up GlobalTracer
|
||||
closer, err := t.cfg.Tracing.Jaeger.InitGlobalTracer(
|
||||
serviceName,
|
||||
jaegerconfig.Logger(logrusLogger{logrus.StandardLogger()}),
|
||||
jaegerconfig.Metrics(jaegermetrics.NullFactory),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.closers = append(t.closers, closer)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetupTracing configures the opentracing using the supplied configuration.
|
||||
// SetupNewTracer creates a new tracer and adds it to those being kept track of
|
||||
// on the linked Tracers object.
|
||||
func (t *Tracers) SetupNewTracer(serviceName string) opentracing.Tracer {
|
||||
if t.cfg == nil {
|
||||
return opentracing.NoopTracer{}
|
||||
|
@ -81,6 +67,7 @@ func (t *Tracers) SetupNewTracer(serviceName string) opentracing.Tracer {
|
|||
return tracer
|
||||
}
|
||||
|
||||
// Close will close all Jaeger OpenTracing tracers associated with the Tracers object.
|
||||
func (t *Tracers) Close() error {
|
||||
for _, c := range t.closers {
|
||||
c.Close() // nolint: errcheck
|
||||
|
@ -94,10 +81,12 @@ type logrusLogger struct {
|
|||
l *logrus.Logger
|
||||
}
|
||||
|
||||
// Error prints an error message to the logger
|
||||
func (l logrusLogger) Error(msg string) {
|
||||
l.l.Error(msg)
|
||||
}
|
||||
|
||||
// Infof prints an info message with printf formatting to the logger
|
||||
func (l logrusLogger) Infof(msg string, args ...interface{}) {
|
||||
l.l.Infof(msg, args...)
|
||||
}
|
||||
|
|
|
@ -95,17 +95,14 @@ func (r *RoomserverInputAPI) SetupHTTP(servMux *http.ServeMux, tracer opentracin
|
|||
)
|
||||
}
|
||||
|
||||
// InProcessRoomServerInput is a RoomserverInput database linked with a
|
||||
// OpenTracing tracer, providing metrics
|
||||
type InProcessRoomServerInput struct {
|
||||
db RoomserverInputAPI
|
||||
tracer opentracing.Tracer
|
||||
}
|
||||
|
||||
func NewInProcessRoomServerInput(db RoomserverInputAPI, tracer opentracing.Tracer) *InProcessRoomServerInput {
|
||||
return &InProcessRoomServerInput{
|
||||
db: db, tracer: tracer,
|
||||
}
|
||||
}
|
||||
|
||||
// InputRoomEvents is a wrapper providing opentracing metrics data around room events
|
||||
func (r *InProcessRoomServerInput) InputRoomEvents(
|
||||
ctx context.Context,
|
||||
request *api.InputRoomEventsRequest,
|
||||
|
|
|
@ -711,11 +711,14 @@ func (r *RoomserverQueryAPI) SetupHTTP(servMux *http.ServeMux, tracer opentracin
|
|||
)
|
||||
}
|
||||
|
||||
// InProcessRoomServerQueryAPI is a RoomserverQueryAPI database linked with a
|
||||
// OpenTracing tracer, providing metrics
|
||||
type InProcessRoomServerQueryAPI struct {
|
||||
db RoomserverQueryAPI
|
||||
tracer opentracing.Tracer
|
||||
}
|
||||
|
||||
// NewInProcessRoomServerQueryAPI creates a new InProcessRoomServerQueryAPI
|
||||
func NewInProcessRoomServerQueryAPI(db RoomserverQueryAPI, tracer opentracing.Tracer) InProcessRoomServerQueryAPI {
|
||||
return InProcessRoomServerQueryAPI{
|
||||
db: db,
|
||||
|
|
Loading…
Reference in a new issue