Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Conversation

@stanlemon
Copy link
Contributor

First part in my work on #117, this takes several bits of code that are reused between StormRecorder and LogRecorder and breaks them out so that they can be used in a forthcoming DropwizardRecorder implementation.

@stanlemon stanlemon requested a review from Crim July 12, 2018 21:44
}

/**
* Test that a {@link KeyBuilder} with parameters have them properly formatted.
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious, what happens if you do

final String metricName = "custom_metric.{}.{}"; .... keyBuilder.build(metricDefinition, new String[]{ param1 })

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the second set of {} just hangs there. String replacement is handled by the same formatted used for logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Crim I went ahead and added a test to confirm my hypothesis.

public void close() {
// Noop
}
private final KeyBuilder keyBuilder = new KeyBuilder(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be set in open()? Is KeyBuilder serializable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm... good call. It probably serializes fine, but this is a good reason to put it in open(), though I hope no one uses this recorder in production.

*
* @param clock clock instance for testing
*/
void setClock(final Clock clock) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder if this should be a package protected constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried that, but it didn’t work with the test since I need to pass in a new clock on the same instance. Check out the start stop test.

* @param key key for timer
*/
void start(final String key) {
start(key, getClock().millis());
Copy link
Contributor

Choose a reason for hiding this comment

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

may wanna have null checks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the clock? I’ll probably add that to the getter. Good call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some null checks for both key and clock as well as covering tests.

Copy link
Contributor

@Crim Crim left a comment

Choose a reason for hiding this comment

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

probably need to fix LogRecorder comment, but looks good so far

@Crim
Copy link
Contributor

Crim commented Jul 13, 2018

seems legit

@stanlemon stanlemon merged commit 7a1ccca into master Jul 13, 2018
@stanlemon stanlemon deleted the storm-metrics branch July 13, 2018 15:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants