Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Add removeAbovePercentile and removeBelowPercentile functions #992

Merged
merged 6 commits into from
Aug 15, 2018

Conversation

stivenbb
Copy link
Contributor

docs/graphite.md Outdated
| scale(seriesList, num) series | | Stable |
| removeAbovePercentile(seriesList, n) seriesList | | Stable |
| removeBelowPercentile(seriesList, n) seriesList | | Stable |
| scale(seriesLists, num) series | | Stable |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the change to scale? graphite's scale only takes a single serieslist. do we allow multiple? (it's possible, would need to dig into the code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this is merge weirdness. It used to say seriesLists incorrectly, and I fixed it in one of my commits, but when I rebased this branch, it pulled the old value.

Copy link
Contributor

@Dieterbe Dieterbe Aug 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. anyway you should rebase again in master to use the new table format. at least it should cause less conflicts now.


if s.n <= 0 {
return nil, errors.New("The requested percent is required to be greater than 0")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a validator on the arg as returned by signature. that way we can check it in advance, instead of waiting until we've done a bunch of other work like fetching the data.

return output, nil
}

func getPercentileValue(datapoints []schema.Point, n float64, sortedDatapointVals []float64) float64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function should be documented better. what is sortedDatapointVals ? looks a slice for this function to use as it pleases. also what's the expected/valid range for n? is it 0 < n <= 100 ?

}

var output []models.Series
sortedDatapointVals := make([]float64, 0, len(series[0].Datapoints)) //reuse float64 slice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confusing comment. maybe "will be reused for each getPercentileValue call" ?

Copy link
Contributor

@Dieterbe Dieterbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few minor tweaks needed

@stivenbb
Copy link
Contributor Author

rebased on top of master


sort.Float64s(sortedDatapointVals)

index := math.Min(math.Ceil(n/100.0*float64(len(sortedDatapointVals)+1)), float64(len(sortedDatapointVals))) - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this correspond to the method used by graphite? it looks different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just simplified it.

@Dieterbe Dieterbe merged commit 3afbcd6 into grafana:master Aug 15, 2018
@shanson7 shanson7 deleted the removeAboveBelowPercentile branch August 21, 2018 20:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants