Skip to content

Commit

Permalink
Rename storage/metricsstore To storage/metricstore
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Dec 2, 2024
1 parent 4d60802 commit 2fd5293
Show file tree
Hide file tree
Showing 25 changed files with 137 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ packages:
github.com/jaegertracing/jaeger/storage/dependencystore:
interfaces:
Reader:
github.com/jaegertracing/jaeger/storage/metricsstore:
github.com/jaegertracing/jaeger/storage/metricstore:
config:
all: true
github.com/jaegertracing/jaeger/storage/samplingstore:
Expand Down
2 changes: 1 addition & 1 deletion cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/jaegertracing/jaeger/plugin/storage"
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/storage/dependencystore"
"github.com/jaegertracing/jaeger/storage/metricsstore/metricstoremetrics"
"github.com/jaegertracing/jaeger/storage/metricstore/metricstoremetrics"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

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 @@ -21,8 +21,8 @@ import (
"github.com/jaegertracing/jaeger/pkg/telemetry"
"github.com/jaegertracing/jaeger/pkg/tenancy"
"github.com/jaegertracing/jaeger/plugin/metricstore/disabled"
"github.com/jaegertracing/jaeger/storage/metricsstore"
"github.com/jaegertracing/jaeger/storage/metricsstore/metricstoremetrics"
"github.com/jaegertracing/jaeger/storage/metricstore"
"github.com/jaegertracing/jaeger/storage/metricstore/metricstoremetrics"
)

var (
Expand Down Expand Up @@ -140,7 +140,7 @@ func (s *server) addArchiveStorage(opts *querysvc.QueryServiceOptions, host comp
return nil
}

func (s *server) createMetricReader(host component.Host) (metricsstore.Reader, error) {
func (s *server) createMetricReader(host component.Host) (metricstore.Reader, error) {
if s.config.Storage.Metrics == "" {
s.telset.Logger.Info("Metric storage not configured")
return disabled.NewMetricsReader()
Expand Down
8 changes: 4 additions & 4 deletions cmd/jaeger/internal/extension/jaegerquery/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/jaegertracing/jaeger/storage"
"github.com/jaegertracing/jaeger/storage/dependencystore"
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/metricsstore"
metricsstoremocks "github.com/jaegertracing/jaeger/storage/metricsstore/mocks"
"github.com/jaegertracing/jaeger/storage/metricstore"
metricstoremocks "github.com/jaegertracing/jaeger/storage/metricstore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
)
Expand Down Expand Up @@ -80,11 +80,11 @@ func (fmf fakeMetricsFactory) Initialize(*zap.Logger) error {
return nil
}

func (fmf fakeMetricsFactory) CreateMetricsReader() (metricsstore.Reader, error) {
func (fmf fakeMetricsFactory) CreateMetricsReader() (metricstore.Reader, error) {
if fmf.name == "need-metrics-reader-error" {
return nil, errors.New("test-error")
}
return &metricsstoremocks.Reader{}, nil
return &metricstoremocks.Reader{}, nil
}

type fakeStorageExt struct{}
Expand Down
12 changes: 6 additions & 6 deletions cmd/query/app/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/jaegertracing/jaeger/plugin/metricstore/disabled"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
"github.com/jaegertracing/jaeger/storage/metricsstore"
"github.com/jaegertracing/jaeger/storage/metricstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

Expand Down Expand Up @@ -242,7 +242,7 @@ func (g *GRPCHandler) GetLatencies(ctx context.Context, r *metrics.GetLatenciesR
if r.Quantile == 0 {
return nil, errMissingQuantile
}
queryParams := metricsstore.LatenciesQueryParameters{
queryParams := metricstore.LatenciesQueryParameters{
BaseQueryParameters: bqp,
Quantile: r.Quantile,
}
Expand All @@ -259,7 +259,7 @@ func (g *GRPCHandler) GetCallRates(ctx context.Context, r *metrics.GetCallRatesR
if err := g.handleErr("failed to build parameters", err); err != nil {
return nil, err
}
queryParams := metricsstore.CallRateQueryParameters{
queryParams := metricstore.CallRateQueryParameters{
BaseQueryParameters: bqp,
}
m, err := g.metricsQueryService.GetCallRates(ctx, &queryParams)
Expand All @@ -275,7 +275,7 @@ func (g *GRPCHandler) GetErrorRates(ctx context.Context, r *metrics.GetErrorRate
if err := g.handleErr("failed to build parameters", err); err != nil {
return nil, err
}
queryParams := metricsstore.ErrorRateQueryParameters{
queryParams := metricstore.ErrorRateQueryParameters{
BaseQueryParameters: bqp,
}
m, err := g.metricsQueryService.GetErrorRates(ctx, &queryParams)
Expand All @@ -287,7 +287,7 @@ func (g *GRPCHandler) GetErrorRates(ctx context.Context, r *metrics.GetErrorRate

// GetMinStepDuration is the gRPC handler to fetch the minimum step duration supported by the underlying metrics store.
func (g *GRPCHandler) GetMinStepDuration(ctx context.Context, _ *metrics.GetMinStepDurationRequest) (*metrics.GetMinStepDurationResponse, error) {
minStep, err := g.metricsQueryService.GetMinStepDuration(ctx, &metricsstore.MinStepDurationQueryParameters{})
minStep, err := g.metricsQueryService.GetMinStepDuration(ctx, &metricstore.MinStepDurationQueryParameters{})
if err := g.handleErr("failed to fetch min step duration", err); err != nil {
return nil, err
}
Expand All @@ -312,7 +312,7 @@ func (g *GRPCHandler) handleErr(msg string, err error) error {
return status.Errorf(codes.Internal, "%s: %v", msg, err)
}

func (g *GRPCHandler) newBaseQueryParameters(r any) (bqp metricsstore.BaseQueryParameters, err error) {
func (g *GRPCHandler) newBaseQueryParameters(r any) (bqp metricstore.BaseQueryParameters, err error) {
if r == nil {
return bqp, errNilRequest
}
Expand Down
36 changes: 18 additions & 18 deletions cmd/query/app/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/metricsstore"
metricsmocks "github.com/jaegertracing/jaeger/storage/metricsstore/mocks"
"github.com/jaegertracing/jaeger/storage/metricstore"
metricsmocks "github.com/jaegertracing/jaeger/storage/metricstore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
)
Expand Down Expand Up @@ -599,21 +599,21 @@ func TestGetMetricsSuccessGRPC(t *testing.T) {
}{
{
mockMethod: "GetLatencies",
mockParamType: "*metricsstore.LatenciesQueryParameters",
mockParamType: "*metricstore.LatenciesQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetLatencies(context.Background(), &metrics.GetLatenciesRequest{Quantile: 0.95, BaseRequest: baseQueryParam})
},
},
{
mockMethod: "GetCallRates",
mockParamType: "*metricsstore.CallRateQueryParameters",
mockParamType: "*metricstore.CallRateQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetCallRates(context.Background(), &metrics.GetCallRatesRequest{BaseRequest: baseQueryParam})
},
},
{
mockMethod: "GetErrorRates",
mockParamType: "*metricsstore.ErrorRateQueryParameters",
mockParamType: "*metricstore.ErrorRateQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetErrorRates(context.Background(), &metrics.GetErrorRatesRequest{BaseRequest: baseQueryParam})
},
Expand Down Expand Up @@ -681,8 +681,8 @@ func TestGetMetricsUseDefaultParamsGRPC(t *testing.T) {
BaseRequest: baseQueryParam,
}
expectedMetrics := &metrics.MetricFamily{Name: "foo"}
expectedParams := &metricsstore.CallRateQueryParameters{
BaseQueryParameters: metricsstore.BaseQueryParameters{
expectedParams := &metricstore.CallRateQueryParameters{
BaseQueryParameters: metricstore.BaseQueryParameters{
ServiceNames: []string{"foo"},
EndTime: &now,
Lookback: &defaultMetricsQueryLookbackDuration,
Expand Down Expand Up @@ -722,8 +722,8 @@ func TestGetMetricsOverrideDefaultParamsGRPC(t *testing.T) {
BaseRequest: baseQueryParam,
}
expectedMetrics := &metrics.MetricFamily{Name: "foo"}
expectedParams := &metricsstore.CallRateQueryParameters{
BaseQueryParameters: metricsstore.BaseQueryParameters{
expectedParams := &metricstore.CallRateQueryParameters{
BaseQueryParameters: metricstore.BaseQueryParameters{
ServiceNames: baseQueryParam.ServiceNames,
EndTime: &endTime,
Lookback: &lookback,
Expand Down Expand Up @@ -755,23 +755,23 @@ func TestGetMetricsFailureGRPC(t *testing.T) {
}{
{
mockMethod: "GetLatencies",
mockParamType: "*metricsstore.LatenciesQueryParameters",
mockParamType: "*metricstore.LatenciesQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetLatencies(context.Background(), &metrics.GetLatenciesRequest{Quantile: 0.95, BaseRequest: baseQueryParam})
},
wantErr: "failed to fetch latencies: storage error",
},
{
mockMethod: "GetCallRates",
mockParamType: "*metricsstore.CallRateQueryParameters",
mockParamType: "*metricstore.CallRateQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetCallRates(context.Background(), &metrics.GetCallRatesRequest{BaseRequest: baseQueryParam})
},
wantErr: "failed to fetch call rates: storage error",
},
{
mockMethod: "GetErrorRates",
mockParamType: "*metricsstore.ErrorRateQueryParameters",
mockParamType: "*metricstore.ErrorRateQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetErrorRates(context.Background(), &metrics.GetErrorRatesRequest{BaseRequest: baseQueryParam})
},
Expand All @@ -796,7 +796,7 @@ func TestGetMetricsFailureGRPC(t *testing.T) {
func TestGetMinStepDurationSuccessGRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
m := server.metricsQueryService.(*metricsmocks.Reader)
m.On("GetMinStepDuration", mock.AnythingOfType("*context.valueCtx"), mock.AnythingOfType("*metricsstore.MinStepDurationQueryParameters")).
m.On("GetMinStepDuration", mock.AnythingOfType("*context.valueCtx"), mock.AnythingOfType("*metricstore.MinStepDurationQueryParameters")).
Return(time.Hour, nil).Once()

res, err := client.GetMinStepDuration(context.Background(), &metrics.GetMinStepDurationRequest{})
Expand All @@ -808,7 +808,7 @@ func TestGetMinStepDurationSuccessGRPC(t *testing.T) {
func TestGetMinStepDurationFailureGRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
m := server.metricsQueryService.(*metricsmocks.Reader)
m.On("GetMinStepDuration", mock.AnythingOfType("*context.valueCtx"), mock.AnythingOfType("*metricsstore.MinStepDurationQueryParameters")).
m.On("GetMinStepDuration", mock.AnythingOfType("*context.valueCtx"), mock.AnythingOfType("*metricstore.MinStepDurationQueryParameters")).
Return(time.Duration(0), errStorageGRPC).Once()

res, err := client.GetMinStepDuration(context.Background(), &metrics.GetMinStepDurationRequest{})
Expand All @@ -831,7 +831,7 @@ func TestGetMetricsInvalidParametersGRPC(t *testing.T) {
{
name: "GetLatencies missing service names",
mockMethod: "GetLatencies",
mockParamType: "*metricsstore.LatenciesQueryParameters",
mockParamType: "*metricstore.LatenciesQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetLatencies(context.Background(), &metrics.GetLatenciesRequest{Quantile: 0.95})
},
Expand All @@ -840,7 +840,7 @@ func TestGetMetricsInvalidParametersGRPC(t *testing.T) {
{
name: "GetLatencies missing quantile",
mockMethod: "GetLatencies",
mockParamType: "*metricsstore.LatenciesQueryParameters",
mockParamType: "*metricstore.LatenciesQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetLatencies(context.Background(), &metrics.GetLatenciesRequest{
BaseRequest: &metrics.MetricsQueryBaseRequest{
Expand All @@ -853,7 +853,7 @@ func TestGetMetricsInvalidParametersGRPC(t *testing.T) {
{
name: "GetCallRates missing service names",
mockMethod: "GetCallRates",
mockParamType: "*metricsstore.CallRateQueryParameters",
mockParamType: "*metricstore.CallRateQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetCallRates(context.Background(), &metrics.GetCallRatesRequest{}) // Test
},
Expand All @@ -862,7 +862,7 @@ func TestGetMetricsInvalidParametersGRPC(t *testing.T) {
{
name: "GetErrorRates nil request",
mockMethod: "GetErrorRates",
mockParamType: "*metricsstore.ErrorRateQueryParameters",
mockParamType: "*metricstore.ErrorRateQueryParameters",
testFn: func(client *grpcClient) (*metrics.GetMetricsResponse, error) {
return client.GetErrorRates(context.Background(), &metrics.GetErrorRatesRequest{})
},
Expand Down
18 changes: 9 additions & 9 deletions cmd/query/app/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/jaegertracing/jaeger/pkg/jtracer"
"github.com/jaegertracing/jaeger/plugin/metricstore/disabled"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
"github.com/jaegertracing/jaeger/storage/metricsstore"
"github.com/jaegertracing/jaeger/storage/metricstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

Expand Down Expand Up @@ -306,32 +306,32 @@ func (aH *APIHandler) latencies(w http.ResponseWriter, r *http.Request) {
aH.handleError(w, newParseError(err, quantileParam), http.StatusBadRequest)
return
}
aH.metrics(w, r, func(ctx context.Context, baseParams metricsstore.BaseQueryParameters) (*metrics.MetricFamily, error) {
return aH.metricsQueryService.GetLatencies(ctx, &metricsstore.LatenciesQueryParameters{
aH.metrics(w, r, func(ctx context.Context, baseParams metricstore.BaseQueryParameters) (*metrics.MetricFamily, error) {
return aH.metricsQueryService.GetLatencies(ctx, &metricstore.LatenciesQueryParameters{
BaseQueryParameters: baseParams,
Quantile: q,
})
})
}

func (aH *APIHandler) calls(w http.ResponseWriter, r *http.Request) {
aH.metrics(w, r, func(ctx context.Context, baseParams metricsstore.BaseQueryParameters) (*metrics.MetricFamily, error) {
return aH.metricsQueryService.GetCallRates(ctx, &metricsstore.CallRateQueryParameters{
aH.metrics(w, r, func(ctx context.Context, baseParams metricstore.BaseQueryParameters) (*metrics.MetricFamily, error) {
return aH.metricsQueryService.GetCallRates(ctx, &metricstore.CallRateQueryParameters{
BaseQueryParameters: baseParams,
})
})
}

func (aH *APIHandler) errors(w http.ResponseWriter, r *http.Request) {
aH.metrics(w, r, func(ctx context.Context, baseParams metricsstore.BaseQueryParameters) (*metrics.MetricFamily, error) {
return aH.metricsQueryService.GetErrorRates(ctx, &metricsstore.ErrorRateQueryParameters{
aH.metrics(w, r, func(ctx context.Context, baseParams metricstore.BaseQueryParameters) (*metrics.MetricFamily, error) {
return aH.metricsQueryService.GetErrorRates(ctx, &metricstore.ErrorRateQueryParameters{
BaseQueryParameters: baseParams,
})
})
}

func (aH *APIHandler) minStep(w http.ResponseWriter, r *http.Request) {
minStep, err := aH.metricsQueryService.GetMinStepDuration(r.Context(), &metricsstore.MinStepDurationQueryParameters{})
minStep, err := aH.metricsQueryService.GetMinStepDuration(r.Context(), &metricstore.MinStepDurationQueryParameters{})
if aH.handleError(w, err, http.StatusInternalServerError) {
return
}
Expand All @@ -342,7 +342,7 @@ func (aH *APIHandler) minStep(w http.ResponseWriter, r *http.Request) {
aH.writeJSON(w, r, &structuredRes)
}

func (aH *APIHandler) metrics(w http.ResponseWriter, r *http.Request, getMetrics func(context.Context, metricsstore.BaseQueryParameters) (*metrics.MetricFamily, error)) {
func (aH *APIHandler) metrics(w http.ResponseWriter, r *http.Request, getMetrics func(context.Context, metricstore.BaseQueryParameters) (*metrics.MetricFamily, error)) {
requestParams, err := aH.queryParser.parseMetricsQueryParams(r)
if aH.handleError(w, err, http.StatusBadRequest) {
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/jaegertracing/jaeger/plugin/metricstore/disabled"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
metricsmocks "github.com/jaegertracing/jaeger/storage/metricsstore/mocks"
metricsmocks "github.com/jaegertracing/jaeger/storage/metricstore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/query/app/query_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics"
"github.com/jaegertracing/jaeger/storage/metricsstore"
"github.com/jaegertracing/jaeger/storage/metricstore"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

Expand Down Expand Up @@ -232,7 +232,7 @@ func (p *queryParser) parseDependenciesQueryParams(r *http.Request) (dqp depende
// spanKinds ::= spanKind | spanKind '&' spanKinds
// spanKind ::= 'spanKind=' spanKindType
// spanKindType ::= "unspecified" | "internal" | "server" | "client" | "producer" | "consumer"
func (p *queryParser) parseMetricsQueryParams(r *http.Request) (bqp metricsstore.BaseQueryParameters, err error) {
func (p *queryParser) parseMetricsQueryParams(r *http.Request) (bqp metricstore.BaseQueryParameters, err error) {
query := r.URL.Query()
services, ok := query[serviceParam]
if !ok {
Expand Down
4 changes: 2 additions & 2 deletions cmd/query/app/querysvc/metrics_query_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

package querysvc

import "github.com/jaegertracing/jaeger/storage/metricsstore"
import "github.com/jaegertracing/jaeger/storage/metricstore"

// MetricsQueryService provides a means of querying R.E.D metrics from an underlying metrics store.
type MetricsQueryService interface {
metricsstore.Reader
metricstore.Reader
}
2 changes: 1 addition & 1 deletion cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/jaegertracing/jaeger/plugin/metricstore"
"github.com/jaegertracing/jaeger/plugin/storage"
"github.com/jaegertracing/jaeger/ports"
"github.com/jaegertracing/jaeger/storage/metricsstore/metricstoremetrics"
"github.com/jaegertracing/jaeger/storage/metricstore/metricstoremetrics"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions plugin/metricstore/disabled/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/plugin"
"github.com/jaegertracing/jaeger/storage/metricsstore"
"github.com/jaegertracing/jaeger/storage/metricstore"
)

var _ plugin.Configurable = (*Factory)(nil)
Expand All @@ -35,6 +35,6 @@ func (*Factory) Initialize(_ *zap.Logger) error {
}

// CreateMetricsReader implements storage.MetricsFactory.
func (*Factory) CreateMetricsReader() (metricsstore.Reader, error) {
func (*Factory) CreateMetricsReader() (metricstore.Reader, error) {
return NewMetricsReader()
}
Loading

0 comments on commit 2fd5293

Please sign in to comment.