Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Telemetery struct for V1 Components Initialization #5695

Merged
merged 35 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
51487a4
Draft Changes to Query using telset
Wise-Wizard Jul 2, 2024
59aa43a
Changed all-in-one code
Wise-Wizard Jul 2, 2024
59111ab
Update pkg/telemetery/settings.go
Wise-Wizard Jul 3, 2024
5ba546b
Made sugessted Changes
Wise-Wizard Jul 3, 2024
1894931
Merge branch 'main' into OTEL/Telemetery
Wise-Wizard Jul 3, 2024
1cfca71
Fix error
Wise-Wizard Jul 3, 2024
5a63b73
Update pkg/telemetery/settings.go
Wise-Wizard Jul 3, 2024
bba59f8
Merge branch 'main' into OTEL/Telemetery
Wise-Wizard Jul 3, 2024
18fdc2d
Refactored telset init in all-in-one
Wise-Wizard Jul 3, 2024
0c933b0
Merge branch 'main' into OTEL/Telemetery
Wise-Wizard Jul 3, 2024
c769b44
Created Healthcheck Adapter
Wise-Wizard Jul 3, 2024
e132adb
Updated ReportStatus to use OTEL's StatusEvent
Wise-Wizard Jul 4, 2024
69876c7
Prototype Impl of Tracer
Wise-Wizard Jul 4, 2024
3ec9594
Added suggested Changes
Wise-Wizard Jul 4, 2024
0002dc6
Changed V2 to accept OTEL's Telset
Wise-Wizard Jul 4, 2024
32d921c
Refactored to accept trace.TracerProvider
Wise-Wizard Jul 5, 2024
57602b5
Merge branch 'main' into OTEL/Telemetery
Wise-Wizard Jul 5, 2024
e5fa271
Temporary fix to failing CI
Wise-Wizard Jul 5, 2024
2396ca5
Made suggested changes
Wise-Wizard Jul 5, 2024
2abe801
Reduced number of ReportStatus calls
Wise-Wizard Jul 5, 2024
ca9950c
Update cmd/query/app/server.go
Wise-Wizard Jul 5, 2024
44638d9
Merge branch 'main' into OTEL/Telemetery
Wise-Wizard Jul 5, 2024
a297feb
Cleaned up COde
Wise-Wizard Jul 5, 2024
6680ea3
Pass telset to struct
Wise-Wizard Jul 5, 2024
bc958c2
Made suggested changes
Wise-Wizard Jul 5, 2024
8654a32
Worked on Test
Wise-Wizard Jul 5, 2024
db18701
Cleaned up Test File
Wise-Wizard Jul 6, 2024
45a1ba3
Fix Linter Errors
Wise-Wizard Jul 6, 2024
65ecbd3
Fix goleak
Wise-Wizard Jul 6, 2024
74403ee
Added Tests
Wise-Wizard Jul 7, 2024
3d9ba04
Ran make lint
Wise-Wizard Jul 7, 2024
160663e
Update cmd/jaeger/internal/extension/jaegerquery/server.go
Wise-Wizard Jul 9, 2024
3de30a1
Merge branch 'main' into OTEL/Telemetery
Wise-Wizard Jul 9, 2024
70d4b10
Fixed Error
Wise-Wizard Jul 9, 2024
25f8d10
Fix nil pointer error
Wise-Wizard Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@
"github.com/jaegertracing/jaeger/cmd/internal/flags"
"github.com/jaegertracing/jaeger/cmd/internal/printconfig"
"github.com/jaegertracing/jaeger/cmd/internal/status"
queryApp "github.com/jaegertracing/jaeger/cmd/query/app"

Check failure on line 41 in cmd/all-in-one/main.go

View workflow job for this annotation

GitHub Actions / lint

could not import github.com/jaegertracing/jaeger/cmd/query/app (-: # github.com/jaegertracing/jaeger/cmd/query/app
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/pkg/version"
metricsPlugin "github.com/jaegertracing/jaeger/plugin/metrics"
Expand Down Expand Up @@ -193,12 +194,17 @@
logger.Fatal("Could not create collector proxy", zap.Error(err))
}
agent := startAgent(cp, aOpts, logger, agentMetricsFactory)

telset := telemetery.Setting{
Logger: svc.Logger,
Tracer: tracer,
Metrics: queryMetricsFactory,
ReportStatus: telemetery.HCAdapter(svc.HC()),
}
// query
querySrv := startQuery(
svc, qOpts, qOpts.BuildQueryServiceOptions(storageFactory, logger),
spanReader, dependencyReader, metricsQueryService,
queryMetricsFactory, tm, tracer,
tm, telset,
)

svc.RunAndThen(func() {
Expand Down Expand Up @@ -273,13 +279,13 @@
spanReader spanstore.Reader,
depReader dependencystore.Reader,
metricsQueryService querysvc.MetricsQueryService,
metricsFactory metrics.Factory,
tm *tenancy.Manager,
jt *jtracer.JTracer,
telset telemetery.Setting,
) *queryApp.Server {
spanReader = storageMetrics.NewReadMetricsDecorator(spanReader, metricsFactory)
spanReader = storageMetrics.NewReadMetricsDecorator(spanReader, telset.Metrics)
qs := querysvc.NewQueryService(spanReader, depReader, *queryOpts)
server, err := queryApp.NewServer(svc.Logger, svc.HC(), qs, metricsQueryService, qOpts, tm, jt)

server, err := queryApp.NewServer(qs, metricsQueryService, qOpts, tm, telset)
if err != nil {
svc.Logger.Fatal("Could not create jaeger-query", zap.Error(err))
}
Expand Down
11 changes: 7 additions & 4 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/pkg/healthcheck"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/plugin/metrics/disabled"
"github.com/jaegertracing/jaeger/ports"
Expand Down Expand Up @@ -79,18 +80,20 @@ func (s *server) Start(_ context.Context, host component.Host) error {
if err != nil {
Wise-Wizard marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("could not initialize a tracer: %w", err)
}
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

telset := telemetery.Setting{
Logger: s.logger,
Tracer: s.jtracer,
ReportStatus: telemetery.HCAdapter(healthcheck.New()),
Wise-Wizard marked this conversation as resolved.
Show resolved Hide resolved
}
// TODO contextcheck linter complains about next line that context is not passed. It is not wrong.
//nolint
s.server, err = queryApp.NewServer(
s.logger,
// TODO propagate healthcheck updates up to the collector's runtime
healthcheck.New(),
qs,
metricsQueryService,
s.makeQueryOptions(),
tm,
s.jtracer,
telset,
)
if err != nil {
return fmt.Errorf("could not create jaeger-query: %w", err)
Expand Down
26 changes: 16 additions & 10 deletions cmd/query/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/netutils"
"github.com/jaegertracing/jaeger/pkg/recoveryhandler"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
Expand All @@ -50,7 +51,7 @@
// 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 All @@ -67,7 +68,12 @@
}

// NewServer creates and initializes Server
func NewServer(logger *zap.Logger, healthCheck *healthcheck.HealthCheck, querySvc *querysvc.QueryService, metricsQuerySvc querysvc.MetricsQueryService, options *QueryOptions, tm *tenancy.Manager, tracer *jtracer.JTracer) (*Server, error) {
func NewServer(querySvc *querysvc.QueryService,
metricsQuerySvc querysvc.MetricsQueryService,
options *QueryOptions,
tm *tenancy.Manager,
telset telemetery.Setting,
) (*Server, error) {
_, httpPort, err := net.SplitHostPort(options.HTTPHostPort)
if err != nil {
return nil, fmt.Errorf("invalid HTTP server host:port: %w", err)
Expand All @@ -81,22 +87,22 @@
return nil, errors.New("server with TLS enabled can not use same host ports for gRPC and HTTP. Use dedicated HTTP and gRPC host ports instead")
}

grpcServer, err := createGRPCServer(querySvc, metricsQuerySvc, options, tm, logger, tracer)
grpcServer, err := createGRPCServer(querySvc, metricsQuerySvc, options, tm, telset.Logger, telset.Tracer)
if err != nil {
return nil, err
}

httpServer, err := createHTTPServer(querySvc, metricsQuerySvc, options, tm, tracer, logger)
httpServer, err := createHTTPServer(querySvc, metricsQuerySvc, options, tm, telset.Tracer, telset.Logger)
if err != nil {
return nil, err
}

return &Server{
logger: logger,
Wise-Wizard marked this conversation as resolved.
Show resolved Hide resolved
healthCheck: healthCheck,
logger: telset.Logger,
hcFunc: telset.ReportStatus,
querySvc: querySvc,
queryOptions: options,
tracer: tracer,
tracer: telset.Tracer,
grpcServer: grpcServer,
httpServer: httpServer,
separatePorts: grpcPort != httpPort,
Expand Down Expand Up @@ -308,7 +314,7 @@
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 @@ -322,7 +328,7 @@
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 @@ -338,7 +344,7 @@
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()
Wise-Wizard marked this conversation as resolved.
Show resolved Hide resolved
}()
}
Expand Down
10 changes: 8 additions & 2 deletions cmd/query/app/token_propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/plugin/storage/es"
"github.com/jaegertracing/jaeger/ports"
Expand Down Expand Up @@ -91,7 +92,12 @@ func runQueryService(t *testing.T, esURL string) *Server {
require.NoError(t, err)

querySvc := querysvc.NewQueryService(spanReader, nil, querysvc.QueryServiceOptions{})
server, err := NewServer(flagsSvc.Logger, flagsSvc.HC(), querySvc, nil,
telset := telemetery.Setting{
Logger: flagsSvc.Logger,
Tracer: jtracer.NoOp(),
ReportStatus: telemetery.HCAdapter(flagsSvc.HC()),
}
server, err := NewServer(querySvc, nil,
&QueryOptions{
GRPCHostPort: ":0",
HTTPHostPort: ":0",
Expand All @@ -100,7 +106,7 @@ func runQueryService(t *testing.T, esURL string) *Server {
},
},
tenancy.NewManager(&tenancy.Options{}),
jtracer.NoOp(),
telset,
)
require.NoError(t, err)
require.NoError(t, server.Start())
Expand Down
8 changes: 7 additions & 1 deletion cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
"github.com/jaegertracing/jaeger/cmd/internal/flags"
"github.com/jaegertracing/jaeger/cmd/internal/printconfig"
"github.com/jaegertracing/jaeger/cmd/internal/status"
"github.com/jaegertracing/jaeger/cmd/query/app"

Check failure on line 34 in cmd/query/main.go

View workflow job for this annotation

GitHub Actions / lint

could not import github.com/jaegertracing/jaeger/cmd/query/app (-: # github.com/jaegertracing/jaeger/cmd/query/app
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"github.com/jaegertracing/jaeger/pkg/bearertoken"
"github.com/jaegertracing/jaeger/pkg/config"
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/pkg/metrics"
"github.com/jaegertracing/jaeger/pkg/telemetery"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/pkg/version"
metricsPlugin "github.com/jaegertracing/jaeger/plugin/metrics"
Expand Down Expand Up @@ -113,7 +114,12 @@
dependencyReader,
*queryServiceOptions)
tm := tenancy.NewManager(&queryOpts.Tenancy)
server, err := app.NewServer(svc.Logger, svc.HC(), queryService, metricsQueryService, queryOpts, tm, jt)
telset := telemetery.Setting{
Logger: logger,
Tracer: jt,
ReportStatus: telemetery.HCAdapter(svc.HC()),
}
server, err := app.NewServer(queryService, metricsQueryService, queryOpts, tm, telset)
if err != nil {
logger.Fatal("Failed to create server", zap.Error(err))
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/telemetery/settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +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"
)

type Setting struct {
Logger *zap.Logger
Tracer *jtracer.JTracer
Metrics metrics.Factory
ReportStatus func(*StatusEvent)
Wise-Wizard marked this conversation as resolved.
Show resolved Hide resolved
}

type StatusEvent struct {
status healthcheck.Status
}

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