• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb / mongodb-atlas-cli / 26228926989

21 May 2026 01:27PM UTC coverage: 22.63% (-41.6%) from 64.198%
26228926989

push

github

apix-bot[bot]
Update compliance report for v1.55.0

8987 of 39713 relevant lines covered (22.63%)

0.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.81
/internal/cli/performanceadvisor/slowoperationthreshold/enable.go
1
// Copyright 2023 MongoDB Inc
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15
package slowoperationthreshold
16

17
import (
18
        "context"
19
        "fmt"
20

21
        "github.com/mongodb/atlas-cli-core/config"
22
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
23
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
24
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/store"
25
        "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
26
        "github.com/spf13/cobra"
27
)
28

29
const EnableTemplate = `Atlas management of the slow operation enabled
30
`
31

32
//go:generate go tool go.uber.org/mock/mockgen -typed -destination=enable_mock_test.go -package=slowoperationthreshold -source=enable.go
33

34
type PerformanceAdvisorSlowOperationThresholdEnabler interface {
35
        EnablePerformanceAdvisorSlowOperationThreshold(string) error
36
}
37

38
type EnableOpts struct {
39
        cli.ProjectOpts
40
        store PerformanceAdvisorSlowOperationThresholdEnabler
41
}
42

43
func (opts *EnableOpts) initStore(ctx context.Context) func() error {
×
44
        return func() error {
×
45
                var err error
×
46
                opts.store, err = store.New(store.AuthenticatedPreset(config.Default()), store.WithContext(ctx))
×
47
                return err
×
48
        }
×
49
}
50

51
func (opts *EnableOpts) Run() error {
1✔
52
        if err := opts.store.EnablePerformanceAdvisorSlowOperationThreshold(opts.ConfigProjectID()); err != nil {
1✔
53
                return err
×
54
        }
×
55

56
        fmt.Print(EnableTemplate)
1✔
57
        return nil
1✔
58
}
59

60
// atlas performanceAdvisor sot enable  [--projectId projectId].
61
func EnableBuilder() *cobra.Command {
×
62
        opts := new(EnableOpts)
×
63
        cmd := &cobra.Command{
×
64
                Use:   "enable",
×
65
                Short: "Enable the application-managed slow operation threshold for your project.",
×
66
                Long: `The slow operation threshold determines which operations are flagged by the Performance Advisor and Query Profiler. When enabled, the application uses the average execution time for operations on your cluster to determine slow-running queries. As a result, the threshold is more pertinent to your cluster workload. Application-managed slow operation threshold is enabled by default for dedicated clusters (M10+).
×
67

×
68
` + fmt.Sprintf(usage.RequiredRole, "Project Owner"),
×
69
                Annotations: map[string]string{
×
70
                        "output": EnableTemplate,
×
71
                },
×
72
                Aliases: []string{"ls"},
×
73
                Args:    require.NoArgs,
×
74
                PreRunE: func(cmd *cobra.Command, _ []string) error {
×
75
                        return opts.PreRunE(
×
76
                                opts.ValidateProjectID,
×
77
                                opts.initStore(cmd.Context()),
×
78
                        )
×
79
                },
×
80
                RunE: func(_ *cobra.Command, _ []string) error {
×
81
                        return opts.Run()
×
82
                },
×
83
        }
84

85
        opts.AddProjectOptsFlags(cmd)
×
86

×
87
        return cmd
×
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc