-
Notifications
You must be signed in to change notification settings - Fork 440
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
[target-allocator] Add a pre-hook to the allocator to filter out dropped targets #1127
Conversation
dac6b9a
to
cbc48bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few thoughts
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter.go
Outdated
Show resolved
Hide resolved
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter.go
Outdated
Show resolved
Hide resolved
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter_test.go
Outdated
Show resolved
Hide resolved
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter.go
Outdated
Show resolved
Hide resolved
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter.go
Outdated
Show resolved
Hide resolved
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter.go
Outdated
Show resolved
Hide resolved
cmd/otel-allocator/prehooktargetfilter/relabel_config_filter.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is definitely moving in the right direction. A few comments and questions.
func (hook mockHook) SetConfig(map[string][]*relabel.Config) { | ||
} | ||
|
||
func (hook mockHook) GetConfig() map[string][]*relabel.Config { | ||
dummyRet := map[string][]*relabel.Config{} | ||
return dummyRet | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't seem to be at all relevant to the use of the prehook.Hook
type here. Can that interface have just the Apply()
method and leave [SG]etConfig()
to the concrete implementation of the relabeling hook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'm still unsure the best way to implement this suggestion. I agree that [SG}etConfig()
methods are specific to relabeling filter but therelabelCfg
gets set in discovery. So I'm actually unsure if I'm able to get access to the concrete struct's method, when I only pass in the allocator interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found one potential problem, otherwise this looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few suggestions for having smaller, more specific interfaces with their caller code. In general, we could define smaller interfaces in the prehook
package but I'm not sure how useful that would be. I would rather define smaller interfaces in the packages that use them, especially if the prehook
package must define an interface with all functions in order to allow for the injection of custom hooks.
I thought these were some interesting reads:
https://stackoverflow.com/questions/73954228/in-golang-how-can-a-consumer-define-an-interface-for-a-function-that-accepts-an
https://dave.cheney.net/practical-go/presentations/gophercon-israel.html#_let_callers_define_the_interface_they_require
I also expanded on my example playground code just for fun 🙂 https://go.dev/play/p/fQU_JdouqT-
52d2daa
to
a2b20ef
Compare
SetConfig(map[string][]*relabel.Config) | ||
} | ||
|
||
func NewManager(log logr.Logger, ctx context.Context, logger log.Logger, hook discoveryHook, options ...func(*discovery.Manager)) *Manager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function signature needs some love, but that can probably be handled in a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a note to create an issue to refactor this function signature.
dd1281c
to
112500e
Compare
…ped targets (open-telemetry#1127) * Adding prehook allocator filter to reduce assigned targets * add metrics to track number of targets kept after filtering * add smaller interfaces local to packages using them * address review feedback * remove outdated references
PR to resolve #1064
The goal of this PR is to drop targets before targets are assigned to the collectors by the allocator. Not necessary to allocate targets that will be dropped in the relabel step.
Now the
Allocator
will check if there is aFilter
set and apply it to filter down the list of targets.filterStrategy=relabel-config
drops targets based on Prometheus relabel_configNo filtering is the default.