Skip to content

Fix mtypes zero divide when the input has no summary metrics or no histogram metrics #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ringerc
Copy link

@ringerc ringerc commented Apr 4, 2025

Fix a zero-divide crash in mtypes if the input lacks either summary metrics or histogram metrics.

In the process, add test cover for the -avalanche-flags-for-adjusted-series flag, and expand the other mtypes tests a bit.

Fixes #136

ringerc added 6 commits April 4, 2025 17:03
This makes them easier to test.

The function to compute avalanche flags now generates a []string of
flags instead of writing directly to an output stream.

Signed-off-by: Craig Ringer <[email protected]>
This can be seen when the input doesn't have any summary metrics, as in
this minimal example:

    $ ./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

Add a test to repro it.

Signed-off-by: Craig Ringer <[email protected]>
The cmd/mtypes and cmd/avalanche directories were being inadvertently
gitignore'd because the .gitignore didn't specify that only these names
at the root of the project should be ignored.

Signed-off-by: Craig Ringer <[email protected]>
@ringerc ringerc force-pushed the fix-mtypes-zero-divide branch from 64edc31 to 588b9fa Compare April 4, 2025 04:03
@ringerc
Copy link
Author

ringerc commented Apr 14, 2025

Anyone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mtypes divide by zero crash if input has no summary or histogram metrics
1 participant