From 35fc20c9b231d1bdb979bf464d8fe3cf72221af0 Mon Sep 17 00:00:00 2001 From: Aryan Goyal <137564277+ary82@users.noreply.github.com> Date: Wed, 15 Jan 2025 02:08:29 +0530 Subject: [PATCH 1/2] refactor: move sampling strategy interfaces to internal/sampling/strategy Signed-off-by: Aryan Goyal <137564277+ary82@users.noreply.github.com> --- cmd/collector/app/collector.go | 10 +++++----- cmd/collector/app/server/grpc.go | 4 ++-- cmd/collector/app/server/http.go | 4 ++-- .../internal/extension/remotesampling/extension.go | 4 ++-- .../processors/adaptivesampling/processor.go | 4 ++-- internal/sampling/grpc/grpc_handler.go | 6 +++--- internal/sampling/http/cfgmgr.go | 4 ++-- .../sampling/strategy}/empty_test.go | 2 +- .../sampling/strategy}/factory.go | 2 +- .../sampling/strategy}/interface.go | 2 +- .../strategyprovider/adaptive/aggregator.go | 4 ++-- .../sampling/strategyprovider/adaptive/factory.go | 8 ++++---- .../strategyprovider/adaptive/factory_test.go | 2 +- plugin/sampling/strategyprovider/factory.go | 14 +++++++------- plugin/sampling/strategyprovider/factory_test.go | 2 +- plugin/sampling/strategyprovider/static/factory.go | 4 ++-- .../strategyprovider/static/factory_test.go | 2 +- .../sampling/strategyprovider/static/provider.go | 2 +- 18 files changed, 40 insertions(+), 40 deletions(-) rename {cmd/collector/app/sampling/samplingstrategy => internal/sampling/strategy}/empty_test.go (89%) rename {cmd/collector/app/sampling/samplingstrategy => internal/sampling/strategy}/factory.go (97%) rename {cmd/collector/app/sampling/samplingstrategy => internal/sampling/strategy}/interface.go (98%) diff --git a/cmd/collector/app/collector.go b/cmd/collector/app/collector.go index f7e783e06aa..d052c7c5b2f 100644 --- a/cmd/collector/app/collector.go +++ b/cmd/collector/app/collector.go @@ -16,9 +16,9 @@ import ( "github.com/jaegertracing/jaeger/cmd/collector/app/flags" "github.com/jaegertracing/jaeger/cmd/collector/app/handler" "github.com/jaegertracing/jaeger/cmd/collector/app/processor" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/cmd/collector/app/server" "github.com/jaegertracing/jaeger/internal/safeexpvar" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -38,8 +38,8 @@ type Collector struct { logger *zap.Logger metricsFactory metrics.Factory traceWriter tracestore.Writer - samplingProvider samplingstrategy.Provider - samplingAggregator samplingstrategy.Aggregator + samplingProvider strategy.Provider + samplingAggregator strategy.Aggregator hCheck *healthcheck.HealthCheck spanProcessor processor.SpanProcessor spanHandlers *SpanHandlers @@ -58,8 +58,8 @@ type CollectorParams struct { Logger *zap.Logger MetricsFactory metrics.Factory TraceWriter tracestore.Writer - SamplingProvider samplingstrategy.Provider - SamplingAggregator samplingstrategy.Aggregator + SamplingProvider strategy.Provider + SamplingAggregator strategy.Aggregator HealthCheck *healthcheck.HealthCheck TenancyMgr *tenancy.Manager } diff --git a/cmd/collector/app/server/grpc.go b/cmd/collector/app/server/grpc.go index 8e10e78bf6d..18e5a82063e 100644 --- a/cmd/collector/app/server/grpc.go +++ b/cmd/collector/app/server/grpc.go @@ -17,8 +17,8 @@ import ( "google.golang.org/grpc/reflection" "github.com/jaegertracing/jaeger/cmd/collector/app/handler" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" samplinggrpc "github.com/jaegertracing/jaeger/internal/sampling/grpc" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/telemetry" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) @@ -27,7 +27,7 @@ import ( type GRPCServerParams struct { configgrpc.ServerConfig Handler *handler.GRPCHandler - SamplingProvider samplingstrategy.Provider + SamplingProvider strategy.Provider Logger *zap.Logger OnError func(error) diff --git a/cmd/collector/app/server/http.go b/cmd/collector/app/server/http.go index bb12c6740ba..c5cfb88b331 100644 --- a/cmd/collector/app/server/http.go +++ b/cmd/collector/app/server/http.go @@ -14,8 +14,8 @@ import ( "go.uber.org/zap/zapcore" "github.com/jaegertracing/jaeger/cmd/collector/app/handler" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" samplinghttp "github.com/jaegertracing/jaeger/internal/sampling/http" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/pkg/httpmetrics" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -27,7 +27,7 @@ import ( type HTTPServerParams struct { confighttp.ServerConfig Handler handler.JaegerBatchesHandler - SamplingProvider samplingstrategy.Provider + SamplingProvider strategy.Provider MetricsFactory metrics.Factory HealthCheck *healthcheck.HealthCheck Logger *zap.Logger diff --git a/cmd/jaeger/internal/extension/remotesampling/extension.go b/cmd/jaeger/internal/extension/remotesampling/extension.go index b4d62d9d5a9..1b437f44208 100644 --- a/cmd/jaeger/internal/extension/remotesampling/extension.go +++ b/cmd/jaeger/internal/extension/remotesampling/extension.go @@ -19,12 +19,12 @@ import ( "google.golang.org/grpc/health" "google.golang.org/grpc/health/grpc_health_v1" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage" "github.com/jaegertracing/jaeger/internal/leaderelection" "github.com/jaegertracing/jaeger/internal/metrics/otelmetrics" samplinggrpc "github.com/jaegertracing/jaeger/internal/sampling/grpc" samplinghttp "github.com/jaegertracing/jaeger/internal/sampling/http" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/adaptive" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/static" @@ -47,7 +47,7 @@ type rsExtension struct { telemetry component.TelemetrySettings httpServer *http.Server grpcServer *grpc.Server - strategyProvider samplingstrategy.Provider // TODO we should rename this to Provider, not "store" + strategyProvider strategy.Provider // TODO we should rename this to Provider, not "store" adaptiveStore samplingstore.Store distLock *leaderelection.DistributedElectionParticipant shutdownWG sync.WaitGroup diff --git a/cmd/jaeger/internal/processors/adaptivesampling/processor.go b/cmd/jaeger/internal/processors/adaptivesampling/processor.go index 6a42151b1da..011370578ff 100644 --- a/cmd/jaeger/internal/processors/adaptivesampling/processor.go +++ b/cmd/jaeger/internal/processors/adaptivesampling/processor.go @@ -10,16 +10,16 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/pdata/ptrace" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/remotesampling" "github.com/jaegertracing/jaeger/internal/metrics/otelmetrics" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/adaptive" "github.com/jaegertracing/jaeger/storage_v2/v1adapter" ) type traceProcessor struct { config *Config - aggregator samplingstrategy.Aggregator + aggregator strategy.Aggregator telset component.TelemetrySettings } diff --git a/internal/sampling/grpc/grpc_handler.go b/internal/sampling/grpc/grpc_handler.go index be6cc64260f..b0920f71aec 100644 --- a/internal/sampling/grpc/grpc_handler.go +++ b/internal/sampling/grpc/grpc_handler.go @@ -6,17 +6,17 @@ package grpc import ( "context" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) // Handler is sampling strategy handler for gRPC. type Handler struct { - samplingProvider samplingstrategy.Provider + samplingProvider strategy.Provider } // NewHandler creates a handler that controls sampling strategies for services. -func NewHandler(provider samplingstrategy.Provider) Handler { +func NewHandler(provider strategy.Provider) Handler { return Handler{ samplingProvider: provider, } diff --git a/internal/sampling/http/cfgmgr.go b/internal/sampling/http/cfgmgr.go index 7231185cfc1..bfd1c0e2871 100644 --- a/internal/sampling/http/cfgmgr.go +++ b/internal/sampling/http/cfgmgr.go @@ -6,13 +6,13 @@ package http import ( "context" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) // ConfigManager implements ClientConfigManager. type ConfigManager struct { - SamplingProvider samplingstrategy.Provider + SamplingProvider strategy.Provider } // GetSamplingStrategy implements ClientConfigManager.GetSamplingStrategy. diff --git a/cmd/collector/app/sampling/samplingstrategy/empty_test.go b/internal/sampling/strategy/empty_test.go similarity index 89% rename from cmd/collector/app/sampling/samplingstrategy/empty_test.go rename to internal/sampling/strategy/empty_test.go index 846e203d61c..39bcc20b0c6 100644 --- a/cmd/collector/app/sampling/samplingstrategy/empty_test.go +++ b/internal/sampling/strategy/empty_test.go @@ -1,7 +1,7 @@ // Copyright (c) 2019 The Jaeger Authors. // SPDX-License-Identifier: Apache-2.0 -package samplingstrategy +package strategy import ( "testing" diff --git a/cmd/collector/app/sampling/samplingstrategy/factory.go b/internal/sampling/strategy/factory.go similarity index 97% rename from cmd/collector/app/sampling/samplingstrategy/factory.go rename to internal/sampling/strategy/factory.go index 243d08595ec..5d720312442 100644 --- a/cmd/collector/app/sampling/samplingstrategy/factory.go +++ b/internal/sampling/strategy/factory.go @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Jaeger Authors. // SPDX-License-Identifier: Apache-2.0 -package samplingstrategy +package strategy import ( "go.uber.org/zap" diff --git a/cmd/collector/app/sampling/samplingstrategy/interface.go b/internal/sampling/strategy/interface.go similarity index 98% rename from cmd/collector/app/sampling/samplingstrategy/interface.go rename to internal/sampling/strategy/interface.go index e47688a7319..9553c7f60c8 100644 --- a/cmd/collector/app/sampling/samplingstrategy/interface.go +++ b/internal/sampling/strategy/interface.go @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Jaeger Authors. // SPDX-License-Identifier: Apache-2.0 -package samplingstrategy +package strategy import ( "context" diff --git a/plugin/sampling/strategyprovider/adaptive/aggregator.go b/plugin/sampling/strategyprovider/adaptive/aggregator.go index 078a8bcb3f4..3cd0a2841fb 100644 --- a/plugin/sampling/strategyprovider/adaptive/aggregator.go +++ b/plugin/sampling/strategyprovider/adaptive/aggregator.go @@ -9,8 +9,8 @@ import ( "go.uber.org/zap" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/internal/leaderelection" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" span_model "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/hostname" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -43,7 +43,7 @@ type aggregator struct { // NewAggregator creates a throughput aggregator that simply emits metrics // about the number of operations seen over the aggregationInterval. -func NewAggregator(options Options, logger *zap.Logger, metricsFactory metrics.Factory, participant leaderelection.ElectionParticipant, store samplingstore.Store) (samplingstrategy.Aggregator, error) { +func NewAggregator(options Options, logger *zap.Logger, metricsFactory metrics.Factory, participant leaderelection.ElectionParticipant, store samplingstore.Store) (strategy.Aggregator, error) { hostId, err := hostname.AsIdentifier() if err != nil { return nil, err diff --git a/plugin/sampling/strategyprovider/adaptive/factory.go b/plugin/sampling/strategyprovider/adaptive/factory.go index 3b42c0249b4..9e59dd3f398 100644 --- a/plugin/sampling/strategyprovider/adaptive/factory.go +++ b/plugin/sampling/strategyprovider/adaptive/factory.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/viper" "go.uber.org/zap" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/internal/leaderelection" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/distributedlock" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" @@ -20,8 +20,8 @@ import ( ) var ( - _ plugin.Configurable = (*Factory)(nil) - _ samplingstrategy.Factory = (*Factory)(nil) + _ plugin.Configurable = (*Factory)(nil) + _ strategy.Factory = (*Factory)(nil) ) // Factory implements samplingstrategy.Factory for an adaptive strategy store. @@ -81,7 +81,7 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, ssFactory storage.S } // CreateStrategyProvider implements samplingstrategy.Factory -func (f *Factory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { +func (f *Factory) CreateStrategyProvider() (strategy.Provider, strategy.Aggregator, error) { s := NewProvider(*f.options, f.logger, f.participant, f.store) a, err := NewAggregator(*f.options, f.logger, f.metricsFactory, f.participant, f.store) if err != nil { diff --git a/plugin/sampling/strategyprovider/adaptive/factory_test.go b/plugin/sampling/strategyprovider/adaptive/factory_test.go index b008cc5fabb..89d8791168e 100644 --- a/plugin/sampling/strategyprovider/adaptive/factory_test.go +++ b/plugin/sampling/strategyprovider/adaptive/factory_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/distributedlock" lmocks "github.com/jaegertracing/jaeger/pkg/distributedlock/mocks" diff --git a/plugin/sampling/strategyprovider/factory.go b/plugin/sampling/strategyprovider/factory.go index 81c7104c3df..2d15554d955 100644 --- a/plugin/sampling/strategyprovider/factory.go +++ b/plugin/sampling/strategyprovider/factory.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/viper" "go.uber.org/zap" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/adaptive" @@ -31,15 +31,15 @@ const ( var AllSamplingTypes = []string{samplingTypeFile, samplingTypeAdaptive} var ( - _ plugin.Configurable = (*Factory)(nil) - _ samplingstrategy.Factory = (*Factory)(nil) + _ plugin.Configurable = (*Factory)(nil) + _ strategy.Factory = (*Factory)(nil) ) // Factory implements samplingstrategy.Factory interface as a meta-factory for strategy storage components. type Factory struct { FactoryConfig - factories map[Kind]samplingstrategy.Factory + factories map[Kind]strategy.Factory } // NewFactory creates the meta-factory. @@ -48,7 +48,7 @@ func NewFactory(config FactoryConfig) (*Factory, error) { uniqueTypes := map[Kind]struct{}{ f.StrategyStoreType: {}, } - f.factories = make(map[Kind]samplingstrategy.Factory) + f.factories = make(map[Kind]strategy.Factory) for t := range uniqueTypes { ff, err := f.getFactoryOfType(t) if err != nil { @@ -59,7 +59,7 @@ func NewFactory(config FactoryConfig) (*Factory, error) { return f, nil } -func (*Factory) getFactoryOfType(factoryType Kind) (samplingstrategy.Factory, error) { +func (*Factory) getFactoryOfType(factoryType Kind) (strategy.Factory, error) { switch factoryType { case samplingTypeFile: return static.NewFactory(), nil @@ -99,7 +99,7 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, ssFactory storage.S } // CreateStrategyProvider implements samplingstrategy.Factory -func (f *Factory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { +func (f *Factory) CreateStrategyProvider() (strategy.Provider, strategy.Aggregator, error) { factory, ok := f.factories[f.StrategyStoreType] if !ok { return nil, nil, fmt.Errorf("no %s strategy store registered", f.StrategyStoreType) diff --git a/plugin/sampling/strategyprovider/factory_test.go b/plugin/sampling/strategyprovider/factory_test.go index 3cfa513cdcd..9629fcc2cf0 100644 --- a/plugin/sampling/strategyprovider/factory_test.go +++ b/plugin/sampling/strategyprovider/factory_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/distributedlock" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" diff --git a/plugin/sampling/strategyprovider/static/factory.go b/plugin/sampling/strategyprovider/static/factory.go index e19935649b9..4170c49d96f 100644 --- a/plugin/sampling/strategyprovider/static/factory.go +++ b/plugin/sampling/strategyprovider/static/factory.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/viper" "go.uber.org/zap" - "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage" @@ -48,7 +48,7 @@ func (f *Factory) Initialize(_ metrics.Factory, _ storage.SamplingStoreFactory, } // CreateStrategyProvider implements samplingstrategy.Factory -func (f *Factory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { +func (f *Factory) CreateStrategyProvider() (ss.Provider, ss.Aggregator, error) { s, err := NewProvider(*f.options, f.logger) if err != nil { return nil, nil, err diff --git a/plugin/sampling/strategyprovider/static/factory_test.go b/plugin/sampling/strategyprovider/static/factory_test.go index 8c7dd04834d..19045839968 100644 --- a/plugin/sampling/strategyprovider/static/factory_test.go +++ b/plugin/sampling/strategyprovider/static/factory_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" diff --git a/plugin/sampling/strategyprovider/static/provider.go b/plugin/sampling/strategyprovider/static/provider.go index 2ffd2a170f2..0143f2b4235 100644 --- a/plugin/sampling/strategyprovider/static/provider.go +++ b/plugin/sampling/strategyprovider/static/provider.go @@ -18,7 +18,7 @@ import ( "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/samplingstrategy" + ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) From 1028607b7b71a3deb687ec7cd5bf8882229557b3 Mon Sep 17 00:00:00 2001 From: Aryan Goyal <137564277+ary82@users.noreply.github.com> Date: Wed, 15 Jan 2025 21:22:47 +0530 Subject: [PATCH 2/2] refactor: rename internal/sampling/strategy to internal/sampling/samplingstrategy Signed-off-by: Aryan Goyal <137564277+ary82@users.noreply.github.com> --- cmd/collector/app/collector.go | 10 +++++----- cmd/collector/app/server/grpc.go | 4 ++-- cmd/collector/app/server/http.go | 4 ++-- .../internal/extension/remotesampling/extension.go | 4 ++-- .../processors/adaptivesampling/processor.go | 4 ++-- internal/sampling/grpc/grpc_handler.go | 6 +++--- internal/sampling/http/cfgmgr.go | 4 ++-- .../{strategy => samplingstrategy}/empty_test.go | 2 +- .../{strategy => samplingstrategy}/factory.go | 2 +- .../{strategy => samplingstrategy}/interface.go | 2 +- .../strategyprovider/adaptive/aggregator.go | 4 ++-- .../sampling/strategyprovider/adaptive/factory.go | 8 ++++---- .../strategyprovider/adaptive/factory_test.go | 6 +++--- plugin/sampling/strategyprovider/factory.go | 14 +++++++------- plugin/sampling/strategyprovider/factory_test.go | 8 ++++---- plugin/sampling/strategyprovider/static/factory.go | 4 ++-- .../strategyprovider/static/factory_test.go | 6 +++--- .../sampling/strategyprovider/static/provider.go | 4 ++-- 18 files changed, 48 insertions(+), 48 deletions(-) rename internal/sampling/{strategy => samplingstrategy}/empty_test.go (89%) rename internal/sampling/{strategy => samplingstrategy}/factory.go (97%) rename internal/sampling/{strategy => samplingstrategy}/interface.go (98%) diff --git a/cmd/collector/app/collector.go b/cmd/collector/app/collector.go index d052c7c5b2f..599f81a9d99 100644 --- a/cmd/collector/app/collector.go +++ b/cmd/collector/app/collector.go @@ -18,7 +18,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/collector/app/processor" "github.com/jaegertracing/jaeger/cmd/collector/app/server" "github.com/jaegertracing/jaeger/internal/safeexpvar" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -38,8 +38,8 @@ type Collector struct { logger *zap.Logger metricsFactory metrics.Factory traceWriter tracestore.Writer - samplingProvider strategy.Provider - samplingAggregator strategy.Aggregator + samplingProvider samplingstrategy.Provider + samplingAggregator samplingstrategy.Aggregator hCheck *healthcheck.HealthCheck spanProcessor processor.SpanProcessor spanHandlers *SpanHandlers @@ -58,8 +58,8 @@ type CollectorParams struct { Logger *zap.Logger MetricsFactory metrics.Factory TraceWriter tracestore.Writer - SamplingProvider strategy.Provider - SamplingAggregator strategy.Aggregator + SamplingProvider samplingstrategy.Provider + SamplingAggregator samplingstrategy.Aggregator HealthCheck *healthcheck.HealthCheck TenancyMgr *tenancy.Manager } diff --git a/cmd/collector/app/server/grpc.go b/cmd/collector/app/server/grpc.go index 18e5a82063e..1234ba021e9 100644 --- a/cmd/collector/app/server/grpc.go +++ b/cmd/collector/app/server/grpc.go @@ -18,7 +18,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/collector/app/handler" samplinggrpc "github.com/jaegertracing/jaeger/internal/sampling/grpc" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/telemetry" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) @@ -27,7 +27,7 @@ import ( type GRPCServerParams struct { configgrpc.ServerConfig Handler *handler.GRPCHandler - SamplingProvider strategy.Provider + SamplingProvider samplingstrategy.Provider Logger *zap.Logger OnError func(error) diff --git a/cmd/collector/app/server/http.go b/cmd/collector/app/server/http.go index c5cfb88b331..38be2fa69a8 100644 --- a/cmd/collector/app/server/http.go +++ b/cmd/collector/app/server/http.go @@ -15,7 +15,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/collector/app/handler" samplinghttp "github.com/jaegertracing/jaeger/internal/sampling/http" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/healthcheck" "github.com/jaegertracing/jaeger/pkg/httpmetrics" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -27,7 +27,7 @@ import ( type HTTPServerParams struct { confighttp.ServerConfig Handler handler.JaegerBatchesHandler - SamplingProvider strategy.Provider + SamplingProvider samplingstrategy.Provider MetricsFactory metrics.Factory HealthCheck *healthcheck.HealthCheck Logger *zap.Logger diff --git a/cmd/jaeger/internal/extension/remotesampling/extension.go b/cmd/jaeger/internal/extension/remotesampling/extension.go index 1b437f44208..151211750f3 100644 --- a/cmd/jaeger/internal/extension/remotesampling/extension.go +++ b/cmd/jaeger/internal/extension/remotesampling/extension.go @@ -24,7 +24,7 @@ import ( "github.com/jaegertracing/jaeger/internal/metrics/otelmetrics" samplinggrpc "github.com/jaegertracing/jaeger/internal/sampling/grpc" samplinghttp "github.com/jaegertracing/jaeger/internal/sampling/http" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/adaptive" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/static" @@ -47,7 +47,7 @@ type rsExtension struct { telemetry component.TelemetrySettings httpServer *http.Server grpcServer *grpc.Server - strategyProvider strategy.Provider // TODO we should rename this to Provider, not "store" + strategyProvider samplingstrategy.Provider // TODO we should rename this to Provider, not "store" adaptiveStore samplingstore.Store distLock *leaderelection.DistributedElectionParticipant shutdownWG sync.WaitGroup diff --git a/cmd/jaeger/internal/processors/adaptivesampling/processor.go b/cmd/jaeger/internal/processors/adaptivesampling/processor.go index 011370578ff..de3f2cfae88 100644 --- a/cmd/jaeger/internal/processors/adaptivesampling/processor.go +++ b/cmd/jaeger/internal/processors/adaptivesampling/processor.go @@ -12,14 +12,14 @@ import ( "github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/remotesampling" "github.com/jaegertracing/jaeger/internal/metrics/otelmetrics" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/adaptive" "github.com/jaegertracing/jaeger/storage_v2/v1adapter" ) type traceProcessor struct { config *Config - aggregator strategy.Aggregator + aggregator samplingstrategy.Aggregator telset component.TelemetrySettings } diff --git a/internal/sampling/grpc/grpc_handler.go b/internal/sampling/grpc/grpc_handler.go index b0920f71aec..f1ac4d0cac3 100644 --- a/internal/sampling/grpc/grpc_handler.go +++ b/internal/sampling/grpc/grpc_handler.go @@ -6,17 +6,17 @@ package grpc import ( "context" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) // Handler is sampling strategy handler for gRPC. type Handler struct { - samplingProvider strategy.Provider + samplingProvider samplingstrategy.Provider } // NewHandler creates a handler that controls sampling strategies for services. -func NewHandler(provider strategy.Provider) Handler { +func NewHandler(provider samplingstrategy.Provider) Handler { return Handler{ samplingProvider: provider, } diff --git a/internal/sampling/http/cfgmgr.go b/internal/sampling/http/cfgmgr.go index bfd1c0e2871..16d733f7d9d 100644 --- a/internal/sampling/http/cfgmgr.go +++ b/internal/sampling/http/cfgmgr.go @@ -6,13 +6,13 @@ package http import ( "context" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) // ConfigManager implements ClientConfigManager. type ConfigManager struct { - SamplingProvider strategy.Provider + SamplingProvider samplingstrategy.Provider } // GetSamplingStrategy implements ClientConfigManager.GetSamplingStrategy. diff --git a/internal/sampling/strategy/empty_test.go b/internal/sampling/samplingstrategy/empty_test.go similarity index 89% rename from internal/sampling/strategy/empty_test.go rename to internal/sampling/samplingstrategy/empty_test.go index 39bcc20b0c6..846e203d61c 100644 --- a/internal/sampling/strategy/empty_test.go +++ b/internal/sampling/samplingstrategy/empty_test.go @@ -1,7 +1,7 @@ // Copyright (c) 2019 The Jaeger Authors. // SPDX-License-Identifier: Apache-2.0 -package strategy +package samplingstrategy import ( "testing" diff --git a/internal/sampling/strategy/factory.go b/internal/sampling/samplingstrategy/factory.go similarity index 97% rename from internal/sampling/strategy/factory.go rename to internal/sampling/samplingstrategy/factory.go index 5d720312442..243d08595ec 100644 --- a/internal/sampling/strategy/factory.go +++ b/internal/sampling/samplingstrategy/factory.go @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Jaeger Authors. // SPDX-License-Identifier: Apache-2.0 -package strategy +package samplingstrategy import ( "go.uber.org/zap" diff --git a/internal/sampling/strategy/interface.go b/internal/sampling/samplingstrategy/interface.go similarity index 98% rename from internal/sampling/strategy/interface.go rename to internal/sampling/samplingstrategy/interface.go index 9553c7f60c8..e47688a7319 100644 --- a/internal/sampling/strategy/interface.go +++ b/internal/sampling/samplingstrategy/interface.go @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Jaeger Authors. // SPDX-License-Identifier: Apache-2.0 -package strategy +package samplingstrategy import ( "context" diff --git a/plugin/sampling/strategyprovider/adaptive/aggregator.go b/plugin/sampling/strategyprovider/adaptive/aggregator.go index 3cd0a2841fb..b48de796f52 100644 --- a/plugin/sampling/strategyprovider/adaptive/aggregator.go +++ b/plugin/sampling/strategyprovider/adaptive/aggregator.go @@ -10,7 +10,7 @@ import ( "go.uber.org/zap" "github.com/jaegertracing/jaeger/internal/leaderelection" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" span_model "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/pkg/hostname" "github.com/jaegertracing/jaeger/pkg/metrics" @@ -43,7 +43,7 @@ type aggregator struct { // NewAggregator creates a throughput aggregator that simply emits metrics // about the number of operations seen over the aggregationInterval. -func NewAggregator(options Options, logger *zap.Logger, metricsFactory metrics.Factory, participant leaderelection.ElectionParticipant, store samplingstore.Store) (strategy.Aggregator, error) { +func NewAggregator(options Options, logger *zap.Logger, metricsFactory metrics.Factory, participant leaderelection.ElectionParticipant, store samplingstore.Store) (samplingstrategy.Aggregator, error) { hostId, err := hostname.AsIdentifier() if err != nil { return nil, err diff --git a/plugin/sampling/strategyprovider/adaptive/factory.go b/plugin/sampling/strategyprovider/adaptive/factory.go index 9e59dd3f398..578d6591973 100644 --- a/plugin/sampling/strategyprovider/adaptive/factory.go +++ b/plugin/sampling/strategyprovider/adaptive/factory.go @@ -11,7 +11,7 @@ import ( "go.uber.org/zap" "github.com/jaegertracing/jaeger/internal/leaderelection" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/distributedlock" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" @@ -20,8 +20,8 @@ import ( ) var ( - _ plugin.Configurable = (*Factory)(nil) - _ strategy.Factory = (*Factory)(nil) + _ plugin.Configurable = (*Factory)(nil) + _ samplingstrategy.Factory = (*Factory)(nil) ) // Factory implements samplingstrategy.Factory for an adaptive strategy store. @@ -81,7 +81,7 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, ssFactory storage.S } // CreateStrategyProvider implements samplingstrategy.Factory -func (f *Factory) CreateStrategyProvider() (strategy.Provider, strategy.Aggregator, error) { +func (f *Factory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { s := NewProvider(*f.options, f.logger, f.participant, f.store) a, err := NewAggregator(*f.options, f.logger, f.metricsFactory, f.participant, f.store) if err != nil { diff --git a/plugin/sampling/strategyprovider/adaptive/factory_test.go b/plugin/sampling/strategyprovider/adaptive/factory_test.go index 89d8791168e..409abd801fc 100644 --- a/plugin/sampling/strategyprovider/adaptive/factory_test.go +++ b/plugin/sampling/strategyprovider/adaptive/factory_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/distributedlock" lmocks "github.com/jaegertracing/jaeger/pkg/distributedlock/mocks" @@ -25,8 +25,8 @@ import ( ) var ( - _ ss.Factory = new(Factory) - _ plugin.Configurable = new(Factory) + _ samplingstrategy.Factory = new(Factory) + _ plugin.Configurable = new(Factory) ) func TestFactory(t *testing.T) { diff --git a/plugin/sampling/strategyprovider/factory.go b/plugin/sampling/strategyprovider/factory.go index 2d15554d955..05fc222d07d 100644 --- a/plugin/sampling/strategyprovider/factory.go +++ b/plugin/sampling/strategyprovider/factory.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/viper" "go.uber.org/zap" - "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/plugin/sampling/strategyprovider/adaptive" @@ -31,15 +31,15 @@ const ( var AllSamplingTypes = []string{samplingTypeFile, samplingTypeAdaptive} var ( - _ plugin.Configurable = (*Factory)(nil) - _ strategy.Factory = (*Factory)(nil) + _ plugin.Configurable = (*Factory)(nil) + _ samplingstrategy.Factory = (*Factory)(nil) ) // Factory implements samplingstrategy.Factory interface as a meta-factory for strategy storage components. type Factory struct { FactoryConfig - factories map[Kind]strategy.Factory + factories map[Kind]samplingstrategy.Factory } // NewFactory creates the meta-factory. @@ -48,7 +48,7 @@ func NewFactory(config FactoryConfig) (*Factory, error) { uniqueTypes := map[Kind]struct{}{ f.StrategyStoreType: {}, } - f.factories = make(map[Kind]strategy.Factory) + f.factories = make(map[Kind]samplingstrategy.Factory) for t := range uniqueTypes { ff, err := f.getFactoryOfType(t) if err != nil { @@ -59,7 +59,7 @@ func NewFactory(config FactoryConfig) (*Factory, error) { return f, nil } -func (*Factory) getFactoryOfType(factoryType Kind) (strategy.Factory, error) { +func (*Factory) getFactoryOfType(factoryType Kind) (samplingstrategy.Factory, error) { switch factoryType { case samplingTypeFile: return static.NewFactory(), nil @@ -99,7 +99,7 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, ssFactory storage.S } // CreateStrategyProvider implements samplingstrategy.Factory -func (f *Factory) CreateStrategyProvider() (strategy.Provider, strategy.Aggregator, error) { +func (f *Factory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { factory, ok := f.factories[f.StrategyStoreType] if !ok { return nil, nil, fmt.Errorf("no %s strategy store registered", f.StrategyStoreType) diff --git a/plugin/sampling/strategyprovider/factory_test.go b/plugin/sampling/strategyprovider/factory_test.go index 9629fcc2cf0..753a827e999 100644 --- a/plugin/sampling/strategyprovider/factory_test.go +++ b/plugin/sampling/strategyprovider/factory_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/distributedlock" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" @@ -23,8 +23,8 @@ import ( ) var ( - _ ss.Factory = new(Factory) - _ plugin.Configurable = new(Factory) + _ samplingstrategy.Factory = new(Factory) + _ plugin.Configurable = new(Factory) ) func TestNewFactory(t *testing.T) { @@ -121,7 +121,7 @@ func (f *mockFactory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.logger = logger } -func (f *mockFactory) CreateStrategyProvider() (ss.Provider, ss.Aggregator, error) { +func (f *mockFactory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { if f.retError { return nil, nil, errors.New("error creating store") } diff --git a/plugin/sampling/strategyprovider/static/factory.go b/plugin/sampling/strategyprovider/static/factory.go index 4170c49d96f..3e5b2503da4 100644 --- a/plugin/sampling/strategyprovider/static/factory.go +++ b/plugin/sampling/strategyprovider/static/factory.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/viper" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" "github.com/jaegertracing/jaeger/storage" @@ -48,7 +48,7 @@ func (f *Factory) Initialize(_ metrics.Factory, _ storage.SamplingStoreFactory, } // CreateStrategyProvider implements samplingstrategy.Factory -func (f *Factory) CreateStrategyProvider() (ss.Provider, ss.Aggregator, error) { +func (f *Factory) CreateStrategyProvider() (samplingstrategy.Provider, samplingstrategy.Aggregator, error) { s, err := NewProvider(*f.options, f.logger) if err != nil { return nil, nil, err diff --git a/plugin/sampling/strategyprovider/static/factory_test.go b/plugin/sampling/strategyprovider/static/factory_test.go index 19045839968..338722de474 100644 --- a/plugin/sampling/strategyprovider/static/factory_test.go +++ b/plugin/sampling/strategyprovider/static/factory_test.go @@ -9,15 +9,15 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/pkg/config" "github.com/jaegertracing/jaeger/pkg/metrics" "github.com/jaegertracing/jaeger/plugin" ) var ( - _ ss.Factory = new(Factory) - _ plugin.Configurable = new(Factory) + _ samplingstrategy.Factory = new(Factory) + _ plugin.Configurable = new(Factory) ) func TestFactory(t *testing.T) { diff --git a/plugin/sampling/strategyprovider/static/provider.go b/plugin/sampling/strategyprovider/static/provider.go index 0143f2b4235..193b4459b94 100644 --- a/plugin/sampling/strategyprovider/static/provider.go +++ b/plugin/sampling/strategyprovider/static/provider.go @@ -18,7 +18,7 @@ import ( "go.uber.org/zap" - ss "github.com/jaegertracing/jaeger/internal/sampling/strategy" + "github.com/jaegertracing/jaeger/internal/sampling/samplingstrategy" "github.com/jaegertracing/jaeger/proto-gen/api_v2" ) @@ -44,7 +44,7 @@ type storedStrategies struct { type strategyLoader func() ([]byte, error) // NewProvider creates a strategy store that holds static sampling strategies. -func NewProvider(options Options, logger *zap.Logger) (ss.Provider, error) { +func NewProvider(options Options, logger *zap.Logger) (samplingstrategy.Provider, error) { ctx, cancelFunc := context.WithCancel(context.Background()) h := &samplingProvider{ logger: logger,