Skip to content

Commit

Permalink
feat!: Remove step..metrics (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored Sep 16, 2021
1 parent 4ce4497 commit 4cb372e
Show file tree
Hide file tree
Showing 22 changed files with 366 additions and 1,443 deletions.
1,110 changes: 350 additions & 760 deletions api/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions api/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions api/v1alpha1/metrics.go

This file was deleted.

49 changes: 0 additions & 49 deletions api/v1alpha1/source_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ type SourceStatus struct {
Pending *uint64 `json:"pending,omitempty" protobuf:"varint,3,opt,name=pending"`
// DEPRECATED: This is likely to be removed in future versions.
LastPending *uint64 `json:"lastPending,omitempty" protobuf:"varint,5,opt,name=lastPending"`
// DEPRECATED: This is likely to be removed in future versions.
Metrics map[string]Metrics `json:"metrics,omitempty" protobuf:"bytes,4,rep,name=metrics"`
}

// GetPending returns pending counts
Expand All @@ -17,50 +15,3 @@ func (in SourceStatus) GetPending() uint64 {
}
return 0
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatus) GetTotal() uint64 {
var x uint64
for _, m := range in.Metrics {
x += m.Total
}
return x
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatus) GetLeaderTotal() uint64 {
return in.Metrics["0"].Total
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatus) GetErrors() uint64 {
var x uint64
for _, m := range in.Metrics {
x += m.Errors
}
return x
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatus) AnySunk() bool {
return in.GetTotal() > 0
}

// GetRetries returns total Retries metrics
// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatus) GetRetries() uint64 {
var x uint64
for _, m := range in.Metrics {
x += m.Retries
}
return x
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatus) GetTotalBytes() uint64 {
var x uint64
for _, m := range in.Metrics {
x += m.TotalBytes
}
return x
}
65 changes: 0 additions & 65 deletions api/v1alpha1/source_status_test.go

This file was deleted.

62 changes: 0 additions & 62 deletions api/v1alpha1/source_statuses.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
package v1alpha1

import (
"strconv"
)

type SourceStatuses map[string]SourceStatus // key is source name

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) IncrTotal(name string, replica int, msgSize uint64) {
x := in[name]
if x.Metrics == nil {
x.Metrics = map[string]Metrics{}
}
m := x.Metrics[strconv.Itoa(replica)]
m.Total++
m.TotalBytes += msgSize
x.Metrics[strconv.Itoa(replica)] = m
in[name] = x
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) Get(name string) SourceStatus {
if x, ok := in[name]; ok {
Expand All @@ -27,18 +10,6 @@ func (in SourceStatuses) Get(name string) SourceStatus {
return SourceStatus{}
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) IncrErrors(name string, replica int) {
x := in[name]
if x.Metrics == nil {
x.Metrics = map[string]Metrics{}
}
m := x.Metrics[strconv.Itoa(replica)]
m.Errors++
x.Metrics[strconv.Itoa(replica)] = m
in[name] = x
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) SetPending(name string, pending uint64) {
x := in[name]
Expand Down Expand Up @@ -68,36 +39,3 @@ func (in SourceStatuses) GetLastPending() uint64 {
}
return v
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) GetErrors() uint64 {
var v uint64
for _, s := range in {
for _, m := range s.Metrics {
v += m.Errors
}
}
return v
}

// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) GetTotal() uint64 {
var v uint64
for _, s := range in {
v += s.GetTotal()
}
return v
}

// IncrRetries increase the retry_count metrics by 1
// DEPRECATED: This is likely to be removed in future versions.
func (in SourceStatuses) IncrRetries(name string, replica int) {
x := in[name]
if x.Metrics == nil {
x.Metrics = map[string]Metrics{}
}
m := x.Metrics[strconv.Itoa(replica)]
m.Retries++
x.Metrics[strconv.Itoa(replica)] = m
in[name] = x
}
67 changes: 0 additions & 67 deletions api/v1alpha1/source_statuses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestSourceStatuses_Set(t *testing.T) {
ss := SourceStatuses{}

ss.IncrTotal("bar", 1, 1)

if assert.Len(t, ss, 1) {
s := ss["bar"]
if assert.Len(t, s.Metrics, 1) {
assert.Equal(t, uint64(1), s.Metrics["1"].Total)
assert.Equal(t, uint64(1), s.Metrics["1"].TotalBytes)
}
}

ss.IncrTotal("bar", 1, 1)

if assert.Len(t, ss, 1) {
s := ss["bar"]
if assert.Len(t, s.Metrics, 1) {
assert.Equal(t, uint64(2), s.Metrics["1"].Total)
assert.Equal(t, uint64(2), s.Metrics["1"].TotalBytes)
}
}

ss.IncrTotal("bar", 0, 1)

if assert.Len(t, ss, 1) {
s := ss["bar"]
if assert.Len(t, s.Metrics, 2) {
assert.Equal(t, uint64(1), s.Metrics["0"].Total)
assert.Equal(t, uint64(2), s.Metrics["1"].Total)
assert.Equal(t, uint64(2), s.Metrics["1"].TotalBytes)
}
}

ss.IncrTotal("baz", 0, 1)

if assert.Len(t, ss, 2) {
s := ss["baz"]
if assert.Len(t, s.Metrics, 1) {
assert.Equal(t, uint64(1), s.Metrics["0"].Total)
}
}
}

func TestSourceStatuses_IncErrors(t *testing.T) {
ss := SourceStatuses{}
ss.IncrErrors("foo", 0)
assert.Equal(t, uint64(1), ss["foo"].Metrics["0"].Errors)
ss.IncrErrors("foo", 0)
assert.Equal(t, uint64(2), ss["foo"].Metrics["0"].Errors)
ss.IncrErrors("bar", 0)
assert.Equal(t, uint64(1), ss["bar"].Metrics["0"].Errors)
}

func TestSourceStatuses_SetPending(t *testing.T) {
ss := SourceStatuses{}

Expand Down Expand Up @@ -95,16 +41,3 @@ func TestSourceStatus_GetLastPending(t *testing.T) {
v := uint64(1)
assert.Equal(t, uint64(1), SourceStatuses{"0": {LastPending: &v}}.GetLastPending())
}

func TestSourceStatuses_IncrRetries(t *testing.T) {
sources := SourceStatuses{}
sources.IncrRetries("one", 1)
assert.Equal(t, uint64(1), sources.Get("one").GetRetries())
sources.IncrRetries("one", 2)
assert.Equal(t, uint64(2), sources.Get("one").GetRetries())
sources.IncrRetries("one", 1)
assert.Equal(t, uint64(3), sources.Get("one").GetRetries())
sources.IncrRetries("two", 1)
assert.Equal(t, uint64(3), sources.Get("one").GetRetries())
assert.Equal(t, uint64(1), sources.Get("two").GetRetries())
}
22 changes: 0 additions & 22 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4cb372e

Please sign in to comment.