-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmetrics_events.go
More file actions
40 lines (34 loc) · 1.07 KB
/
metrics_events.go
File metadata and controls
40 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cmd
import (
"context"
"fmt"
"github.com/spf13/cobra"
)
const metricsEventsMeasures = "count, successful_count, failed_count, scheduled_count, paused_count, error_rate, avg_attempts, scheduled_retry_count"
type metricsEventsCmd struct {
cmd *cobra.Command
flags metricsCommonFlags
}
func newMetricsEventsCmd() *metricsEventsCmd {
c := &metricsEventsCmd{}
c.cmd = &cobra.Command{
Use: "events",
Args: cobra.NoArgs,
Short: ShortBeta("Query event metrics"),
Long: LongBeta(`Query metrics for events (volume, success/failure counts, error rate, etc.). Measures: ` + metricsEventsMeasures + `.`),
RunE: c.runE,
}
addMetricsCommonFlags(c.cmd, &c.flags)
return c
}
func (c *metricsEventsCmd) runE(cmd *cobra.Command, args []string) error {
if err := Config.Profile.ValidateAPIKey(); err != nil {
return err
}
params := metricsParamsFromFlags(&c.flags)
data, err := Config.GetAPIClient().QueryEventMetrics(context.Background(), params)
if err != nil {
return fmt.Errorf("query event metrics: %w", err)
}
return printMetricsResponse(data, c.flags.output)
}