-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmetrics_attempts.go
More file actions
40 lines (34 loc) · 1.14 KB
/
metrics_attempts.go
File metadata and controls
40 lines (34 loc) · 1.14 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 metricsAttemptsMeasures = "count, successful_count, failed_count, delivered_count, error_rate, response_latency_avg, response_latency_max, response_latency_p95, response_latency_p99, delivery_latency_avg"
type metricsAttemptsCmd struct {
cmd *cobra.Command
flags metricsCommonFlags
}
func newMetricsAttemptsCmd() *metricsAttemptsCmd {
c := &metricsAttemptsCmd{}
c.cmd = &cobra.Command{
Use: "attempts",
Args: cobra.NoArgs,
Short: ShortBeta("Query attempt metrics"),
Long: LongBeta(`Query metrics for delivery attempts (latency, success/failure). Measures: ` + metricsAttemptsMeasures + `.`),
RunE: c.runE,
}
addMetricsCommonFlags(c.cmd, &c.flags)
return c
}
func (c *metricsAttemptsCmd) runE(cmd *cobra.Command, args []string) error {
if err := Config.Profile.ValidateAPIKey(); err != nil {
return err
}
params := metricsParamsFromFlags(&c.flags)
data, err := Config.GetAPIClient().QueryAttemptMetrics(context.Background(), params)
if err != nil {
return fmt.Errorf("query attempt metrics: %w", err)
}
return printMetricsResponse(data, c.flags.output)
}