-
Notifications
You must be signed in to change notification settings - Fork 286
CPP-964 Add refresh-interval support for histogram metrics #561
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
Conversation
Up next: add a new unit test or two to confirm that this impl actually does what we think it does.
Some sample code for playing with the refresh rate in a real app:
|
@@ -142,6 +142,7 @@ | |||
#define CASS_DEFAULT_MAX_TRACING_DATA_WAIT_TIME_MS 15 | |||
#define CASS_DEFAULT_RETRY_TRACING_DATA_WAIT_TIME_MS 3 | |||
#define CASS_DEFAULT_TRACING_CONSISTENCY CASS_CONSISTENCY_ONE | |||
#define CASS_DEFAULT_HISTOGRAM_REFRESH_INTERVAL_NO_REFRESH 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love this name for the constant but... I couldn't come up with something I liked better.
: thread_state_(thread_state) | ||
, histograms_(new PerThreadHistogram[thread_state->max_threads()]) { | ||
, histograms_(new PerThreadHistogram[thread_state->max_threads()]) | ||
, zero_snapshot_(Snapshot {0,0,0,0,0,0,0,0,0,0}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like something that should be a static value on the Histogram class but repeated attempts to setup such a value hit various issues that my knowledge of C++ wasn't subtle enough to address. Since we're only creating one of these for a given metrics impl I wasn't too worried about it (the size of a Snapshot shouldn't be a driving concern) but I concede it's not ideal.
} | ||
|
||
copy_snapshot(cached_snapshot_, snapshot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Model here very much is the impl of similar functionality in the 4.x Java driver
src/metrics.hpp
Outdated
histograms_[i].add(histogram_); | ||
} | ||
|
||
cached_snapshot_ = build_new_snapshot(histogram_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we use build_and_copy_snapshot(histogram_, &cached_snapshot_)
here to save an object creation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not obviously. The whole point of build_and_copy_snapshot() was to avoid the creation of an intermediate Snapshot object and just update the "rv" Snapshot* pointer directly. In this line we very explicitly want to create that intermediate Snapshot object because then we're going to cache it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a NIT comment, I don't have time to set up an env to build this locally and I see that Henry is already doing that so I'll leave that part to him for now 😅
Hey @hhughes and/or @joao-r-reis ; you guys good after the last round of changes? I think everything has been addressed but wanted a final confirmation from one or (ideally) both of you on that point. |
Yeah the issue I brought up is resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Port of Java functionality as defined here.