Skip to content

Commit

Permalink
[FIX]: adds case to handle kubeletstats reciever to ignore endpoint (#…
Browse files Browse the repository at this point in the history
…558)

* adds case to handle kubeletstats receiver to ignore endpoint
  • Loading branch information
mritunjaysharma394 authored Dec 14, 2021
1 parent 467baa6 commit 9e2c3c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/collector/parser/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ func singlePortFromConfigEndpoint(logger logr.Logger, name string, config map[in
case name == "tcplog" || name == "udplog":
endpoint = getAddressFromConfig(logger, name, listenAddressKey, config)

// ignore kubeletstats receiver as it holds the field key endpoint, and it
// is a scraper, we only expose endpoint through k8s service objects for
// receivers that aren't scrapers.
case name == "kubeletstats":
return nil

default:
endpoint = getAddressFromConfig(logger, name, endpointKey, config)
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/collector/parser/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ func TestReceiverFailsWhenPortIsntString(t *testing.T) {
assert.Nil(t, p)
}

func TestIgnorekubeletstatsEndpoint(t *testing.T) {
// ignore "kubeletstats" receiver endpoint field, this is special case
// as this receiver gets parsed by generic receiver parser
builder := NewGenericReceiverParser(logger, "kubeletstats", map[interface{}]interface{}{
"endpoint": "0.0.0.0:9000",
})

// test
ports, err := builder.Ports()

// verify
assert.NoError(t, err)
assert.Len(t, ports, 0)
}

func TestReceiverFallbackWhenNotRegistered(t *testing.T) {
// test
p := For(logger, "myreceiver", map[interface{}]interface{}{})
Expand Down

0 comments on commit 9e2c3c3

Please sign in to comment.