Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
prymitive committed Aug 27, 2024
1 parent 7d0d534 commit bfb010e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (cfg Config) String() string {
func (cfg *Config) GetChecksForEntry(ctx context.Context, gen *PrometheusGenerator, entry discovery.Entry) []checks.RuleChecker {
enabled := []checks.RuleChecker{}

defaultMatch := []Match{{State: defaultMatchStates(ctx.Value(CommandKey).(ContextCommandVal))}}
defaultMatch := []Match{{State: defaultMatchStates(commandFromContext(ctx))}}
proms := gen.ServersForPath(entry.Path.Name)

if entry.PathError != nil || entry.Rule.Error.Err != nil {
Expand Down Expand Up @@ -229,3 +229,10 @@ func parseDuration(d string) (time.Duration, error) {
}
return time.Duration(mdur), nil
}

func commandFromContext(ctx context.Context) (cmd ContextCommandVal) {
if val := ctx.Value(CommandKey); val != nil {
cmd = val.(ContextCommandVal)
}
return cmd
}
2 changes: 1 addition & 1 deletion internal/config/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (m Match) validate(allowEmpty bool) error {
}

func (m Match) IsMatch(ctx context.Context, path string, e discovery.Entry) bool {
cmd := ctx.Value(CommandKey).(ContextCommandVal)
cmd := commandFromContext(ctx)

if m.Command != nil {
if cmd != *m.Command {
Expand Down

0 comments on commit bfb010e

Please # to comment.