Skip to content

Commit

Permalink
Created Healthcheck Adapter
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 3, 2024
1 parent 0c933b0 commit c769b44
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 23 deletions.
8 changes: 4 additions & 4 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ by default uses only in-memory database.`,
}
agent := startAgent(cp, aOpts, logger, agentMetricsFactory)
telset := telemetery.Setting{
Logger: svc.Logger,
Tracer: tracer,
Metrics: queryMetricsFactory,
HC: svc.HC(),
Logger: svc.Logger,
Tracer: tracer,
Metrics: queryMetricsFactory,
ReportStatus: telemetery.HCAdapter(svc.HC()),
}
// query
querySrv := startQuery(
Expand Down
6 changes: 3 additions & 3 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func (s *server) Start(_ context.Context, host component.Host) error {
return fmt.Errorf("could not initialize a tracer: %w", err)
}
telset := telemetery.Setting{
Logger: s.logger,
Tracer: s.jtracer,
HC: healthcheck.New(),
Logger: s.logger,
Tracer: s.jtracer,
ReportStatus: telemetery.HCAdapter(healthcheck.New()),
}
// TODO contextcheck linter complains about next line that context is not passed. It is not wrong.
//nolint
Expand Down
10 changes: 5 additions & 5 deletions cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (
// Server runs HTTP, Mux and a grpc server
type Server struct {
logger *zap.Logger
healthCheck *healthcheck.HealthCheck
hcFunc func(*telemetery.StatusEvent)
querySvc *querysvc.QueryService
queryOptions *QueryOptions

Expand Down Expand Up @@ -99,7 +99,7 @@ func NewServer(querySvc *querysvc.QueryService,

return &Server{
logger: telset.Logger,
healthCheck: telset.HC,
hcFunc: telset.ReportStatus,
querySvc: querySvc,
queryOptions: options,
tracer: telset.Tracer,
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.healthCheck.Set(healthcheck.Unavailable)
s.hcFunc(&telemetery.StatusEvent{status: healthcheck.Unavailable})

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / spm

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / crossdock

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for osx

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for system/390

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for arm

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for linux

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / docker-images

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1, all-in-one, false)

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for powerpc

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for osx-m1

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for windows

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / all-in-one (v2, jaeger, true)

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 317 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent
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.healthCheck.Set(healthcheck.Unavailable)
s.hcFunc(&telemetery.StatusEvent{status: healthcheck.Unavailable})

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / spm

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / crossdock

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for osx

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for system/390

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for arm

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for linux

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / docker-images

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1, all-in-one, false)

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for powerpc

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for osx-m1

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for windows

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / all-in-one (v2, jaeger, true)

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 331 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent
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.healthCheck.Set(healthcheck.Unavailable)
s.hcFunc(&telemetery.StatusEvent{status: healthcheck.Unavailable})

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / spm

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / crossdock

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for osx

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for system/390

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for arm

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for linux

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / docker-images

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / all-in-one (v1, all-in-one, false)

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for powerpc

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for osx-m1

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / build binaries for windows

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / all-in-one (v2, jaeger, true)

unknown field status in struct literal of type telemetery.StatusEvent

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent) (typecheck)

Check failure on line 347 in cmd/query/app/server.go

View workflow job for this annotation

GitHub Actions / lint

unknown field status in struct literal of type telemetery.StatusEvent) (typecheck)
s.bgFinished.Done()
}()
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/query/app/token_propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func runQueryService(t *testing.T, esURL string) *Server {

querySvc := querysvc.NewQueryService(spanReader, nil, querysvc.QueryServiceOptions{})
telset := telemetery.Setting{
Logger: flagsSvc.Logger,
Tracer: jtracer.NoOp(),
HC: flagsSvc.HC(),
Logger: flagsSvc.Logger,
Tracer: jtracer.NoOp(),
ReportStatus: telemetery.HCAdapter(flagsSvc.HC()),
}
server, err := NewServer(querySvc, nil,
&QueryOptions{
Expand Down
6 changes: 3 additions & 3 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func main() {
*queryServiceOptions)
tm := tenancy.NewManager(&queryOpts.Tenancy)
telset := telemetery.Setting{
Logger: logger,
Tracer: jt,
HC: svc.HC(),
Logger: logger,
Tracer: jt,
ReportStatus: telemetery.HCAdapter(svc.HC()),
}
server, err := app.NewServer(queryService, metricsQueryService, queryOpts, tm, telset)
if err != nil {
Expand Down
24 changes: 19 additions & 5 deletions pkg/telemetery/settings.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
// Copyright (c) 2024 The Jaeger Authors.
// SPDX-License-Identifier: Apache-2.0

package telemetery

import (
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/healthcheck"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"go.uber.org/zap"
)

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

type StatusEvent struct {
status healthcheck.Status
}

func HCAdapter(hc *healthcheck.HealthCheck) func(*StatusEvent) {
return func(event *StatusEvent) {
hc.Set(event.status)
}
}

0 comments on commit c769b44

Please sign in to comment.