mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2025-01-06 20:48:41 +00:00
Rewording Explode -> Expand
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
This commit is contained in:
parent
e5c2d40581
commit
a125dac85b
2 changed files with 8 additions and 52 deletions
|
@ -155,8 +155,8 @@ type MultiObserverEvent struct {
|
||||||
SampleRate float64
|
SampleRate float64
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExplodableEvent interface {
|
type ExpandableEvent interface {
|
||||||
Explode() []Event
|
Expand() []Event
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MultiObserverEvent) MetricName() string { return m.OMetricName }
|
func (m *MultiObserverEvent) MetricName() string { return m.OMetricName }
|
||||||
|
@ -165,10 +165,10 @@ func (m *MultiObserverEvent) Labels() map[string]string { return m.OLabels }
|
||||||
func (m *MultiObserverEvent) MetricType() mapper.MetricType { return mapper.MetricTypeObserver }
|
func (m *MultiObserverEvent) MetricType() mapper.MetricType { return mapper.MetricTypeObserver }
|
||||||
func (m *MultiObserverEvent) Values() []float64 { return m.OValues }
|
func (m *MultiObserverEvent) Values() []float64 { return m.OValues }
|
||||||
|
|
||||||
// Explode returns a list of events that are the result of exploding the multi-value event.
|
// Expand returns a list of events that are the result of expanding the multi-value event.
|
||||||
// This will be used as a middle-step in the pipeline to convert multi-value events to single-value events.
|
// This will be used as a middle-step in the pipeline to convert multi-value events to single-value events.
|
||||||
// And keep the exporter code compatible with previous versions.
|
// And keep the exporter code compatible with previous versions.
|
||||||
func (m *MultiObserverEvent) Explode() []Event {
|
func (m *MultiObserverEvent) Expand() []Event {
|
||||||
if len(m.OValues) == 1 && m.SampleRate == 0 {
|
if len(m.OValues) == 1 && m.SampleRate == 0 {
|
||||||
return []Event{m}
|
return []Event{m}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ func (m *MultiObserverEvent) Explode() []Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ ExplodableEvent = &MultiObserverEvent{}
|
_ ExpandableEvent = &MultiObserverEvent{}
|
||||||
_ MultiValueEvent = &MultiObserverEvent{}
|
_ MultiValueEvent = &MultiObserverEvent{}
|
||||||
_ MultiValueEvent = &CounterEvent{}
|
_ MultiValueEvent = &CounterEvent{}
|
||||||
_ MultiValueEvent = &GaugeEvent{}
|
_ MultiValueEvent = &GaugeEvent{}
|
||||||
|
|
|
@ -179,7 +179,7 @@ func TestMultiValueEvent(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiObserverEvent_Explode(t *testing.T) {
|
func TestMultiObserverEvent_Expand(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
event *MultiObserverEvent
|
event *MultiObserverEvent
|
||||||
|
@ -263,54 +263,10 @@ func TestMultiObserverEvent_Explode(t *testing.T) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got := tt.event.Explode()
|
got := tt.event.Expand()
|
||||||
if !reflect.DeepEqual(got, tt.wantEvents) {
|
if !reflect.DeepEqual(got, tt.wantEvents) {
|
||||||
t.Errorf("MultiObserverEvent.Explode() = %v, want %v", got, tt.wantEvents)
|
t.Errorf("MultiObserverEvent.Expand() = %v, want %v", got, tt.wantEvents)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEventImplementations(t *testing.T) {
|
|
||||||
t.Run("MultiObserverEvent implements MultiValueEvent", func(t *testing.T) {
|
|
||||||
event := &MultiObserverEvent{}
|
|
||||||
if _, ok := interface{}(event).(MultiValueEvent); !ok {
|
|
||||||
t.Error("MultiObserverEvent does not implement MultiValueEvent")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("MultiObserverEvent implements ExplodableEvent", func(t *testing.T) {
|
|
||||||
event := &MultiObserverEvent{}
|
|
||||||
if _, ok := interface{}(event).(ExplodableEvent); !ok {
|
|
||||||
t.Error("MultiObserverEvent does not implement ExplodableEvent")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("MultiObserverEvent implements Event", func(t *testing.T) {
|
|
||||||
event := &MultiObserverEvent{}
|
|
||||||
if _, ok := interface{}(event).(Event); !ok {
|
|
||||||
t.Error("MultiObserverEvent does not implement Event")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("CounterEvent implements MultiValueEvent", func(t *testing.T) {
|
|
||||||
event := &CounterEvent{}
|
|
||||||
if _, ok := interface{}(event).(MultiValueEvent); !ok {
|
|
||||||
t.Error("CounterEvent does not implement MultiValueEvent")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("GaugeEvent implements MultiValueEvent", func(t *testing.T) {
|
|
||||||
event := &GaugeEvent{}
|
|
||||||
if _, ok := interface{}(event).(MultiValueEvent); !ok {
|
|
||||||
t.Error("GaugeEvent does not implement MultiValueEvent")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("ObserverEvent implements MultiValueEvent", func(t *testing.T) {
|
|
||||||
event := &ObserverEvent{}
|
|
||||||
if _, ok := interface{}(event).(MultiValueEvent); !ok {
|
|
||||||
t.Error("ObserverEvent does not implement MultiValueEvent")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue