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

Add keepLastValue function #995

Merged
merged 6 commits into from
Aug 15, 2018
Merged

Conversation

stivenbb
Copy link
Contributor

@stivenbb stivenbb commented Aug 14, 2018

Native implementation of keepLastValue() Graphite function.

@stivenbb stivenbb closed this Aug 14, 2018
@tehlers320
Copy link

Darn, why did you close this? This is probably my favorite function

@shanson7
Copy link
Collaborator

No worries @tehlers320, it's coming :)

@stivenbb stivenbb reopened this Aug 14, 2018
@stivenbb stivenbb changed the title keepLastValue() function Add keepLastValue function Aug 14, 2018
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.

overall looks good!

ArgInt{val: &s.limit},
// Allow user to specify 'INF' as value. if so, will fall back to maxInt
// Ignores any other strings (just like Graphite)
ArgString{val: &stub},
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you mean 'inf' not 'INF' ?
this comment is confusing because it implies the behavior for INF vs other strings is different,
but actually in all cases (inf, INF, or any other strings) it will always just use the default of MaxInt64 because ANY string value is ignored. (not just "any other string" as it states)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Graphite actually says that "INF" is infinity, but accepts any string since it doesn't check for types.
From graphite:
Param('limit', ParamTypes.integer, default='INF')

I think the way this function is implemented in graphite is not what they intended it to be, but I'm including the option to put in a string just to mimic the behavior.

{Val: 1234567890, Ts: 60},
}

testKeepLastValue(
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.

similar to feedback in previous PR, using utility functions is good, but if they call t.Fatal internally, it's harder to trace back to the calling function so if a test fails it's hard to tell where it failed.
better for the util function to return an error, and here, check for error and if so call t.Fatal.

not a huge deal though, if you have more important stuff to do, then don't worry about this. but something to keep in mind for the future at least. i don't want you to refactor this if you have other functions or whatever to work on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I didn't have the utility functions when I wrote this (I just rebased), so didn't do that. Will use them in the future though.

if 0 < consecutiveNaNs && consecutiveNaNs <= limit && !math.IsNaN(lastVal) {
for i := len(out) - consecutiveNaNs; i < len(out); i++ {
out[i].Val = lastVal
}
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting. i always thought graphite would just replace nones upto the limit, instead of only replacing nones if an entire batch falls under the limit.
but i checked functions.py and it's the same.
TIL ...

@Dieterbe
Copy link
Contributor

@stivenbb can you rebase on top of latest master ?

@stivenbb
Copy link
Contributor Author

here you go

@Dieterbe Dieterbe merged commit 7841e3c into grafana:master Aug 15, 2018
@Dieterbe
Copy link
Contributor

@stivenbb thanks so much 🥇

@stivenbb
Copy link
Contributor Author

You got it!

@shanson7 shanson7 deleted the keepLastValue1 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.

4 participants