Skip to content

Commit

Permalink
add changes
Browse files Browse the repository at this point in the history
Signed-off-by: FlamingSaint <raghuramkannan400@gmail.com>
  • Loading branch information
FlamingSaint committed Jul 14, 2024
1 parent 78ca11f commit ed90e30
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.
23 changes: 15 additions & 8 deletions cmd/jaeger/internal/extension/jaegerquery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
queryApp "github.com/jaegertracing/jaeger/cmd/query/app"
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
"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/storage"
"github.com/jaegertracing/jaeger/storage/metricsstore"
)

Expand Down Expand Up @@ -68,8 +71,7 @@ func (s *server) Start(_ context.Context, host component.Host) error {
}
qs := querysvc.NewQueryService(spanReader, depReader, opts)

var mqs querysvc.MetricsQueryService
mqs, err = s.addMetricStorage(&opts, host)
mqs, err := s.createMetricStorage(host)
if err != nil {
return err

Check warning on line 76 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L76

Added line #L76 was not covered by tests
}
Expand Down Expand Up @@ -129,21 +131,26 @@ func (s *server) addArchiveStorage(opts *querysvc.QueryServiceOptions, host comp
return nil
}

func (s *server) addMetricStorage(opts *querysvc.QueryServiceOptions, host component.Host) (metricsstore.Reader, error) {
func (s *server) createMetricStorage(host component.Host) (metricsstore.Reader, error) {
if s.config.MetricStorage == "" {
s.telset.Logger.Info("Metric storage not configured")
return nil, nil
return disabled.NewMetricsReader()
}

mf, err := jaegerstorage.GetMetricsFactory(s.config.MetricStorage, host)
if err != nil {
return nil, fmt.Errorf("cannot find metrics storage factory: %w", err)

Check warning on line 142 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L140-L142

Added lines #L140 - L142 were not covered by tests
}

metricsReader, ok := opts.InitMetricStorage(mf, s.telset.Logger)
if !ok {
s.telset.Logger.Info("Metric storage not initialized")
return nil, nil
// metricsReader, ok := opts.InitMetricStorage(mf, s.telset.Logger)
metricsReader, err := mf.CreateMetricsReader()
if errors.Is(err, storage.ErrMetricStorageNotConfigured) || errors.Is(err, storage.ErrMetricStorageNotSupported) {
s.telset.Logger.Info("Metric storage not created", zap.String("reason", err.Error()))
return disabled.NewMetricsReader()

Check warning on line 149 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L146-L149

Added lines #L146 - L149 were not covered by tests
}
if err != nil {
s.telset.Logger.Error("Cannot init metric storage reader", zap.Error(err))
return disabled.NewMetricsReader()

Check warning on line 153 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L151-L153

Added lines #L151 - L153 were not covered by tests
}
return metricsReader, nil

Check warning on line 155 in cmd/jaeger/internal/extension/jaegerquery/server.go

View check run for this annotation

Codecov / codecov/patch

cmd/jaeger/internal/extension/jaegerquery/server.go#L155

Added line #L155 was not covered by tests
}
Expand Down
22 changes: 0 additions & 22 deletions cmd/query/app/querysvc/query_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/jaegertracing/jaeger/model/adjuster"
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/metricsstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

Expand All @@ -39,7 +38,6 @@ const (
type QueryServiceOptions struct {
ArchiveSpanReader spanstore.Reader
ArchiveSpanWriter spanstore.Writer
MetricsReader metricsstore.Reader
Adjuster adjuster.Adjuster
}

Expand Down Expand Up @@ -169,26 +167,6 @@ func (opts *QueryServiceOptions) InitArchiveStorage(storageFactory storage.Facto
return true
}

// InitMetricStorage tries to initialize metric storage reader if storage factory supports them.
func (opts *QueryServiceOptions) InitMetricStorage(metricsFactory storage.MetricsFactory, logger *zap.Logger) (metricsstore.Reader, bool) {
// metricsFactory = metricsFactory.(storage.MetricsFactory)
// if !ok {
// logger.Info("Metric storage not supported by the factory")
// return false
// }
reader, err := metricsFactory.CreateMetricsReader()
if errors.Is(err, storage.ErrMetricStorageNotConfigured) || errors.Is(err, storage.ErrMetricStorageNotSupported) {
logger.Info("Metric storage not created", zap.String("reason", err.Error()))
return nil, false
}
if err != nil {
logger.Error("Cannot init metric storage reader", zap.Error(err))
return nil, false
}
opts.MetricsReader = reader
return reader, true
}

// hasArchiveStorage returns true if archive storage reader/writer are initialized.
func (opts *QueryServiceOptions) hasArchiveStorage() bool {
return opts.ArchiveSpanReader != nil && opts.ArchiveSpanWriter != nil
Expand Down
4 changes: 2 additions & 2 deletions docker-compose/monitor/docker-compose-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ services:
image: jaegertracing/jaeger:${JAEGER_IMAGE_TAG:-latest}
volumes:
- "./jaeger-ui.json:/etc/jaeger/jaeger-ui.json" # Do we need this for v2 ? Seems to be running without this.
- "./jaeger-v2-config.yml:/etc/jaeger/jaeger-v2-config.yml"
command: ["--config", "/etc/jaeger/jaeger-v2-config.yml"]
- "./jaeger-v2-config.yml:/etc/jaeger/config.yml"
command: ["--config", "/etc/jaeger/config.yml"]
# TODO: Need to pass this through config
# environment:
# - METRICS_STORAGE_TYPE=prometheus
Expand Down

0 comments on commit ed90e30

Please sign in to comment.