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

[m3coordinator] Allow downsampler to configure custom rule store #2996

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/cmd/services/m3coordinator/downsample/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ var (
errRollupRuleNoTransforms = errors.New("rollup rule has no transforms set")
)

// CustomRuleStoreFn is a function to swap the backend used for the rule stores.
type CustomRuleStoreFn func(kv.Store) (kv.Store, error)

// DownsamplerOptions is a set of required downsampler options.
type DownsamplerOptions struct {
Storage storage.Storage
Expand Down
12 changes: 11 additions & 1 deletion src/query/server/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ type RunOptions struct {
// CustomBuildTags are additional tags to be added to the instrument build
// reporter.
CustomBuildTags map[string]string

// ApplyCustomRuleStore provides an option to swap the backend used for the rule stores.
ApplyCustomRuleStore downsample.CustomRuleStoreFn
}

// InstrumentOptionsReady is a set of instrument options
Expand Down Expand Up @@ -669,7 +672,7 @@ func newM3DBStorage(
ds, err := newDownsampler(
cfg.Downsample, clusterClient,
fanoutStorage, clusterNamespacesWatcher,
tsdbOpts.TagOptions(), instrumentOptions, rwOpts)
tsdbOpts.TagOptions(), instrumentOptions, rwOpts, runOpts.ApplyCustomRuleStore)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -728,6 +731,7 @@ func newDownsampler(
tagOptions models.TagOptions,
instrumentOpts instrument.Options,
rwOpts xio.Options,
applyCustomRuleStore downsample.CustomRuleStoreFn,
) (downsample.Downsampler, error) {
// Namespace the downsampler metrics.
instrumentOpts = instrumentOpts.SetMetricsScope(
Expand All @@ -743,6 +747,12 @@ func newDownsampler(
return nil, errors.Wrap(err, "unable to create KV store from the "+
"cluster management config client")
}
if applyCustomRuleStore != nil {
kvStore, err = applyCustomRuleStore(kvStore)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to return the kvStore here if you're passing it in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, idea is the aggregator will use the overridden store that's returned back

if err != nil {
return nil, errors.Wrap(err, "unable to apply custom rule store")
}
}

tagEncoderOptions := serialize.NewTagEncoderOptions()
tagDecoderOptions := serialize.NewTagDecoderOptions(serialize.TagDecoderOptionsConfig{})
Expand Down