diff --git a/pkg/event/event.go b/pkg/event/event.go index 9584828..4f8a531 100644 --- a/pkg/event/event.go +++ b/pkg/event/event.go @@ -155,8 +155,8 @@ type MultiObserverEvent struct { SampleRate float64 } -type ExplodableEvent interface { - Explode() []Event +type ExpandableEvent interface { + Expand() []Event } 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) 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. // 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 { return []Event{m} } @@ -200,7 +200,7 @@ func (m *MultiObserverEvent) Explode() []Event { } var ( - _ ExplodableEvent = &MultiObserverEvent{} + _ ExpandableEvent = &MultiObserverEvent{} _ MultiValueEvent = &MultiObserverEvent{} _ MultiValueEvent = &CounterEvent{} _ MultiValueEvent = &GaugeEvent{} diff --git a/pkg/event/event_test.go b/pkg/event/event_test.go index 88040b9..a4e21d5 100644 --- a/pkg/event/event_test.go +++ b/pkg/event/event_test.go @@ -179,7 +179,7 @@ func TestMultiValueEvent(t *testing.T) { } } -func TestMultiObserverEvent_Explode(t *testing.T) { +func TestMultiObserverEvent_Expand(t *testing.T) { tests := []struct { name string event *MultiObserverEvent @@ -263,54 +263,10 @@ func TestMultiObserverEvent_Explode(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got := tt.event.Explode() + got := tt.event.Expand() 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") - } - }) -}