Skip to content

Conversation

@rayman7718
Copy link
Contributor

…pshot reporter.

Switched producer-shutdown logic to ensure metric-flush at shutdown-time

rmatharu added 2 commits May 10, 2018 16:31
…pshot reporter.

Switched producer-shutdown logic to ensure metric-flush at shutdown-time
@rayman7718 rayman7718 changed the title Snapshot reporter flush during shutdown, exception metric addition Improvements to MetricsSnapshotReporter May 30, 2018
Copy link
Contributor

@vjagadish1989 vjagadish1989 left a comment

Choose a reason for hiding this comment

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

Initial set of comments. Lets get a quick review from @prateekm as well since he has familiarity with the metrics system.

* All public methods are thread-safe.
*
*/
public class ListGauge implements Metric {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about this as a list of values? You don't have to expose the fact that it uses a Gauge underneath. ListGauge merely takes in an add(T val)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* Add a gauge to the list
* @param value The Gauge value to be added
*/
public synchronized void add(Gauge value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just take in a T value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* All public methods are thread-safe.
*
*/
public class ListGauge implements Metric {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to parameterize this class? ListGauge<T> since Gauges are parameterized already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
public synchronized void add(Gauge value) {
if (this.metricList.size() == nItems) {
((LinkedList<Gauge>) this.metricList).removeFirst();
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably don't need this cast here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @return the collection of gauge values
*/
public synchronized Collection<Gauge> getValue() {
return this.metricList;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we return a copy or wrap it in an immutable collection so that modifications don't alter the original?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


producer.stop
// Scheduling an event with 0 delay to ensure flushing of metrics one last time before shutdown
executor.schedule(this,0, TimeUnit.SECONDS)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit pick: spacing in commas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

import java.util.LinkedList;


/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Re-wrote this slightly:

"A {@link Metric} that stores a collection of values. By default, a {@link ListGauge} retains the {@code size} most recent values"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed these comments in new, separate PR: #541

*
* This current implementation uses a size-bound-policy and holds the N most-recent Gauge objects added to the list.
* This bound N is configurable at instantiation time.
* TODO: Support a time-based and size-and-time-based hybrid policy.
Copy link
Contributor

Choose a reason for hiding this comment

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

If this PR is only adding gauges, maybe move the TODOs to another JIRA and assign them to yourself. You can remove these from 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.

done

* This current implementation uses a size-bound-policy and holds the N most-recent Gauge objects added to the list.
* This bound N is configurable at instantiation time.
* TODO: Support a time-based and size-and-time-based hybrid policy.
* TODO: Add a derived class to do compaction for errors using hash-based errorIDs and adding timestamp for errors to dedup
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be a new metric type then? would be good to think what the end-user API is so that we build the right thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, agree

@vjagadish1989
Copy link
Contributor

also, what do you think about editing this PR title to something on the lines of: "Add a ListGauge metric type". IMO, It's more indicative of what its contents are.

@rayman7718
Copy link
Contributor Author

As discussed offline, created a separate pull requests for
ListGauge metric type #541
and separate ones for SnapshotReporter improvement, and DiagnosticAppender integr with ListGauge.

@rayman7718 rayman7718 closed this May 31, 2018
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.

3 participants