Skip to content

mtypes divide by zero crash if input has no summary or histogram metrics #136

Open
@ringerc

Description

@ringerc

The mtypes utility crashes with a 0 divide error if the input lacks summary or histogram metrics and the -avalanche-flags-for-adjusted-series flag is passed, e.g.

$ ./mtypes < /dev/null -avalanche-flags-for-adjusted-series 10

./mtypes < /dev/null -avalanche-flags-for-adjusted-series 10
Metric Type    Metric Families    Series (adjusted)    Series (adjusted) %        Average Buckets/Objectives
---            ---                ---                  ---                        ---
*              0                  0 (0)                100.000000 (100.000000)    -

Avalanche flags for the similar distribution to get to the adjusted series goal of: 10
panic: runtime error: integer divide by zero

goroutine 1 [running]:
main.computeAvalancheFlags(0x8a55a0?, {0x0, 0x0, 0x0, 0x0, 0x0}, 0xc0001239b0)
    [...]/avalanche/cmd/mtypes/main.go:127 +0xcbd
main.main()
    [...]/avalanche/cmd/mtypes/main.go:81 +0x5c5

This is true even if valid metrics are passed, so long as the metric set omits summary and/or histogram metrics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions