Skip to content

Commit

Permalink
metricbeat/module/rabbitmq/queue: Fix data type for `consumers.utilis…
Browse files Browse the repository at this point in the history
…ation.pct` (elastic#38436)

Fix mapping type for `rabbitmq.queue.consumers.utilisation.pct` to be `scaled_float` instead of `long` because the values range on `[0, 1.0]`. Previously, truncation converted the value to an integer so it either reported zero or one.

There was a bug in the unit tests that did not catch this until we updated to testify 1.9.0 (stretchr/testify#1531). This PR removes the temporary testify v1.8.4 pin.
  • Loading branch information
andrewkroh authored Mar 20, 2024
1 parent 22af217 commit 5715699
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ fields added to events containing the Beats version. {pull}37553[37553]
- Fix panics when parsing dereferencing invalid parsed url. {pull}34702[34702]
- Fix setuid root when running under cgroups v2. {pull}37794[37794]
- Adjust State loader to only retry when response code status is 5xx {pull}37981[37981]
- Reset prctl dumpable flag after cap drop. {pull}38269[38269]
- Reset prctl dumpable flag after cap drop. {pull}38269[38269]

*Metricbeat*

- Fix Azure Monitor 429 error by causing metricbeat to retry the request again. {pull}38294[38294]
- Fix fields not being parsed correctly in postgresql/database {issue}25301[25301] {pull}37720[37720]
- rabbitmq/queue - Change the mapping type of `rabbitmq.queue.consumers.utilisation.pct` to `scaled_float` from `long` because the values fall within the range of `[0.0, 1.0]`. Previously, conversion to integer resulted in reporting either `0` or `1`.

*Osquerybeat*

Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22892,11 +22892,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------
Dependency : github.com/stretchr/testify
Version: v1.8.4
Version: v1.9.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.8.4/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/stretchr/testify@v1.9.0/LICENSE:

MIT License

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ replace (
github.com/google/gopacket => github.com/elastic/gopacket v1.1.20-0.20211202005954-d412fca7f83a
github.com/insomniacslk/dhcp => github.com/elastic/dhcp v0.0.0-20200227161230-57ec251c7eb3 // indirect
github.com/snowflakedb/gosnowflake => github.com/snowflakedb/gosnowflake v1.6.19
github.com/stretchr/testify v1.9.0 => github.com/stretchr/testify v1.8.4 // Temporary fix for https://github.com/elastic/beats/pull/38436.
github.com/tonistiigi/fifo => github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c
k8s.io/kubernetes v1.13.0 => k8s.io/kubernetes v1.24.15
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1847,8 +1847,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57758,7 +57758,7 @@ type: long
Fraction of the time (between 0.0 and 1.0) that the queue is able to immediately deliver messages to consumers. This can be less than 1.0 if consumers are limited by network congestion or prefetch count.


type: long
type: scaled_float

format: percent

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/rabbitmq/fields.go

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

4 changes: 2 additions & 2 deletions metricbeat/module/rabbitmq/queue/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"consumers": {
"count": 3,
"utilisation": {
"pct": 0
"pct": 0.7
}
},
"disk": {
Expand Down Expand Up @@ -68,4 +68,4 @@
"address": "127.0.0.1:55555",
"type": "rabbitmq"
}
}
}
3 changes: 2 additions & 1 deletion metricbeat/module/rabbitmq/queue/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
description: >
Number of consumers.
- name: consumers.utilisation.pct
type: long
type: scaled_float
scaling_factor: 100
format: percent
description: >
Fraction of the time (between 0.0 and 1.0) that the queue is able to immediately deliver messages to consumers. This can be less than 1.0 if consumers are limited by network congestion or prefetch count.
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/rabbitmq/queue/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
"consumers": s.Object{
"count": c.Int("consumers"),
"utilisation": s.Object{
"pct": c.Int("consumer_utilisation", s.IgnoreAllErrors),
"pct": c.Float("consumer_utilisation", s.IgnoreAllErrors),
},
},
"messages": s.Object{
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/rabbitmq/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestFetchEventContents(t *testing.T) {
consumers := event["consumers"].(mapstr.M)
utilisation := consumers["utilisation"].(mapstr.M)
assert.EqualValues(t, 3, consumers["count"])
assert.EqualValues(t, 0.7, utilisation["pct"])
assert.Equal(t, 0.7, utilisation["pct"])

memory := event["memory"].(mapstr.M)
assert.EqualValues(t, 232720, memory["bytes"])
Expand Down

0 comments on commit 5715699

Please sign in to comment.