Skip to content

Commit

Permalink
Updated ReportStatus to use OTEL's StatusEvent
Browse files Browse the repository at this point in the history
Signed-off-by: Wise-Wizard <[email protected]>
  • Loading branch information
Wise-Wizard committed Jul 4, 2024
1 parent c769b44 commit e132adb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
12 changes: 6 additions & 6 deletions cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/gorilla/handlers"
"github.com/soheilhy/cmux"
"go.opentelemetry.io/collector/component"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"google.golang.org/grpc"
Expand All @@ -38,7 +39,6 @@ import (
"github.com/jaegertracing/jaeger/cmd/query/app/internal/api_v3"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/pkg/bearertoken"
"github.com/jaegertracing/jaeger/pkg/healthcheck"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/netutils"
"github.com/jaegertracing/jaeger/pkg/recoveryhandler"
Expand All @@ -51,7 +51,7 @@ import (
// Server runs HTTP, Mux and a grpc server
type Server struct {
logger *zap.Logger
hcFunc func(*telemetery.StatusEvent)
hcFunc func(*component.StatusEvent)
querySvc *querysvc.QueryService
queryOptions *QueryOptions

Expand Down Expand Up @@ -314,7 +314,7 @@ func (s *Server) Start() error {
s.logger.Error("Could not start HTTP server", zap.Error(err))
}
s.logger.Info("HTTP server stopped", zap.Int("port", httpPort), zap.String("addr", s.queryOptions.HTTPHostPort))
s.hcFunc(&telemetery.StatusEvent{status: healthcheck.Unavailable})
s.hcFunc(component.NewStatusEvent(component.StatusStopping))
s.bgFinished.Done()
}()

Expand All @@ -328,7 +328,7 @@ func (s *Server) Start() error {
s.logger.Error("Could not start GRPC server", zap.Error(err))
}
s.logger.Info("GRPC server stopped", zap.Int("port", grpcPort), zap.String("addr", s.queryOptions.GRPCHostPort))
s.hcFunc(&telemetery.StatusEvent{status: healthcheck.Unavailable})
s.hcFunc(component.NewStatusEvent(component.StatusStopping))
s.bgFinished.Done()
}()

Expand All @@ -344,7 +344,7 @@ func (s *Server) Start() error {
s.logger.Error("Could not start multiplexed server", zap.Error(err))
}
s.logger.Info("CMUX server stopped", zap.Int("port", tcpPort), zap.String("addr", s.queryOptions.HTTPHostPort))
s.hcFunc(&telemetery.StatusEvent{status: healthcheck.Unavailable})
s.hcFunc(component.NewStatusEvent(component.StatusStopping))
s.bgFinished.Done()
}()
}
Expand All @@ -371,7 +371,7 @@ func (s *Server) Close() error {
s.logger.Info("Closing CMux server")
s.cmuxServer.Close()
}

s.hcFunc(component.NewStatusEvent(component.StatusStopped))
s.bgFinished.Wait()
s.logger.Info("Server stopped")
return errors.Join(errs...)
Expand Down
26 changes: 18 additions & 8 deletions pkg/telemetery/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,31 @@ import (
"github.com/jaegertracing/jaeger/pkg/healthcheck"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"go.opentelemetry.io/collector/component"
)

type Setting struct {
Logger *zap.Logger
Tracer *jtracer.JTracer
Metrics metrics.Factory
ReportStatus func(*StatusEvent)
ReportStatus func(*component.StatusEvent)
}

type StatusEvent struct {
status healthcheck.Status
}

func HCAdapter(hc *healthcheck.HealthCheck) func(*StatusEvent) {
return func(event *StatusEvent) {
hc.Set(event.status)
func HCAdapter(hc *healthcheck.HealthCheck) func(*component.StatusEvent) {
return func(event *component.StatusEvent) {
var hcStatus healthcheck.Status
switch event.Status() {
case component.StatusOK:
hcStatus = healthcheck.Ready
case component.StatusStarting,
component.StatusRecoverableError,
component.StatusPermanentError,
component.StatusNone,
component.StatusStopping:
hcStatus = healthcheck.Unavailable
case component.StatusFatalError, component.StatusStopped:
hcStatus = healthcheck.Broken
}
hc.Set(hcStatus)
}
}

0 comments on commit e132adb

Please sign in to comment.