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

Feature: promote adhoc to permanent feature #615

Merged
merged 1 commit into from
Feb 12, 2024
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
44 changes: 26 additions & 18 deletions cmd/synthetic-monitoring-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func run(args []string, stdout io.Writer) error {
Bool("pprof-enabled", *enablePProf).
Msg("starting")

notifyAboutDeprecatedFeatureFlags(features, zl)

if features.IsSet(feature.K6) {
newUri, err := validateK6URI(*k6URI)
if err != nil {
Expand Down Expand Up @@ -244,26 +246,24 @@ func run(args []string, stdout io.Writer) error {
return checksUpdater.Run(ctx)
})

if features.IsSet(feature.AdHoc) {
adhocHandler, err := adhoc.NewHandler(adhoc.HandlerOpts{
Conn: conn,
Logger: zl.With().Str("subsystem", "adhoc").Logger(),
Backoff: newConnectionBackoff(),
Publisher: publisher,
TenantCh: tenantCh,
PromRegisterer: promRegisterer,
Features: features,
K6Runner: k6Runner,
})
if err != nil {
return fmt.Errorf("Cannot create ad-hoc checks handler: %w", err)
}

g.Go(func() error {
return adhocHandler.Run(ctx)
})
adhocHandler, err := adhoc.NewHandler(adhoc.HandlerOpts{
mem marked this conversation as resolved.
Show resolved Hide resolved
Conn: conn,
Logger: zl.With().Str("subsystem", "adhoc").Logger(),
Backoff: newConnectionBackoff(),
Publisher: publisher,
TenantCh: tenantCh,
PromRegisterer: promRegisterer,
Features: features,
K6Runner: k6Runner,
})
if err != nil {
return fmt.Errorf("Cannot create ad-hoc checks handler: %w", err)
}

g.Go(func() error {
return adhocHandler.Run(ctx)
})

return g.Wait()
}

Expand Down Expand Up @@ -332,3 +332,11 @@ func validateK6URI(uri string) (string, error) {

return uri, nil
}

func notifyAboutDeprecatedFeatureFlags(features feature.Collection, zl zerolog.Logger) {
for _, ff := range []string{feature.AdHoc, feature.Traceroute} {
if features.IsSet(ff) {
zl.Info().Msgf("the `%s` feature is now permanently enabled in the agent, you can remove it from the --feature flag without loss of functionality", ff)
}
}
}
5 changes: 0 additions & 5 deletions internal/adhoc/adhoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ type HandlerOpts struct {

// NewHandler creates a new Handler using the specified options.
func NewHandler(opts HandlerOpts) (*Handler, error) {
// We should never hit this, but just in case.
if !opts.Features.IsSet(feature.AdHoc) {
return nil, fmt.Errorf("AdHoc feature is not enabled")
}

opsCounter := prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "sm",
Expand Down
Loading