MCPcopy Create free account
hub / github.com/auth0/auth0-cli / RenderEventStreamStats

Method RenderEventStreamStats

internal/display/event_streams.go:453–508  ·  view source on GitHub ↗
(stats *management.EventStreamStats)

Source from the content-addressed store, hash-verified

451}
452
453func (r *Renderer) RenderEventStreamStats(stats *management.EventStreamStats) {
454 if r.Format == OutputFormatJSON {
455 r.JSONResult(stats)
456 return
457 }
458
459 v := &eventStreamStatsView{
460 ID: stats.GetID(),
461 Name: stats.GetName(),
462 From: stats.Window.GetDateFrom().Format(time.RFC3339),
463 To: stats.Window.GetDateTo().Format(time.RFC3339),
464 Interval: fmt.Sprintf("%ds", stats.Window.BucketInterval.GetScaleFactor()),
465 raw: stats,
466 }
467
468 r.Newline()
469 fmt.Println(ansi.Bold(ansi.Cyan("Event Stream Stats")))
470 r.Result(v)
471
472 // Metric buckets.
473 metricMap := extractMetricMap(stats.Metrics)
474
475 success := metricMap[MetricSuccessfulDeliveries]
476 fail := metricMap[MetricFailedDeliveries]
477
478 var rows []View
479 for i, bucket := range stats.Buckets {
480 timestamp := bucket.Format("2006-01-02 15:04")
481 row := &eventStreamStatsRowView{
482 Timestamp: timestamp,
483 Success: safeMetric(success, i),
484 Failure: safeMetric(fail, i),
485 raw: nil,
486 }
487 rows = append(rows, row)
488 }
489
490 r.Newline()
491 fmt.Println(ansi.Bold(ansi.Cyan("Delivery Metrics")))
492 r.Results(rows)
493
494 // Metric Totals + Types.
495 r.Newline()
496 if success != nil {
497 s := findMetric(stats.Metrics, MetricSuccessfulDeliveries)
498 if s != nil {
499 fmt.Printf(" Successful Deliveries: Total = %d, Type = %s\n", s.GetWindowTotal(), s.GetType())
500 }
501 }
502 if fail != nil {
503 f := findMetric(stats.Metrics, MetricFailedDeliveries)
504 if f != nil {
505 fmt.Printf(" Failed Deliveries: Total = %d, Type = %s\n", f.GetWindowTotal(), f.GetType())
506 }
507 }
508}
509
510func findMetric(metrics []*management.StatsMetric, name string) *management.StatsMetric {

Callers 1

statsEventStreamCmdFunction · 0.80

Calls 10

JSONResultMethod · 0.95
NewlineMethod · 0.95
ResultMethod · 0.95
ResultsMethod · 0.95
BoldFunction · 0.92
CyanFunction · 0.92
extractMetricMapFunction · 0.85
safeMetricFunction · 0.85
findMetricFunction · 0.85
GetNameMethod · 0.65

Tested by

no test coverage detected