Skip to content

Commit

Permalink
fix: heartbeat samples were being dropped (#23)
Browse files Browse the repository at this point in the history
* fix: heartbeat samples were being dropped
becuase were were not using a pointer, the entityKey and timestamp were missing from the sample and so they get dropped
* fix: failing heartbeat sampler test
  • Loading branch information
ardias committed Jul 22, 2020
1 parent 4ccd9ff commit d35cbe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
21 changes: 3 additions & 18 deletions pkg/metrics/heartbeat_sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/newrelic/infrastructure-agent/pkg/config"
"github.com/newrelic/infrastructure-agent/pkg/log"

"github.com/newrelic/infrastructure-agent/pkg/entity"
"github.com/newrelic/infrastructure-agent/pkg/sample"
)

Expand All @@ -31,8 +30,8 @@ func NewHeartbeatSampler(context agent.AgentContext) *HeartbeatSampler {
func (f *HeartbeatSampler) Sample() (sample.EventBatch, error) {
s := HeartbeatSample{
HeartbeatCounter: f.count,
EventType: "HeartbeatSample",
}
s.Type("HeartbeatSample")
f.count++
return sample.EventBatch{&s}, nil
}
Expand Down Expand Up @@ -62,20 +61,6 @@ func (hb *HeartbeatSampler) Disabled() bool {
}

type HeartbeatSample struct {
HeartbeatCounter int `json:"heartBeatCounter"`
EventType string `json:"eventType"`
EntityKey entity.Key `json:"entityKey"`
Time int64 `json:"timestamp"`
}

func (f HeartbeatSample) Type(eventType string) {
f.EventType = eventType
}

func (f HeartbeatSample) Entity(key entity.Key) {
f.EntityKey = key
}

func (f HeartbeatSample) Timestamp(timestamp int64) {
f.Time = timestamp
sample.BaseEvent
HeartbeatCounter int `json:"heartBeatCounter"`
}
2 changes: 1 addition & 1 deletion pkg/metrics/heartbeat_sampler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestHeartBeatSampler(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, ok := sample1[0].(HeartbeatSample)
_, ok := sample1[0].(*HeartbeatSample)

assert.True(t, true, ok)
}

0 comments on commit d35cbe7

Please sign in to comment.