-
Notifications
You must be signed in to change notification settings - Fork 36
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
(Discuss) Abstract the FastForward client used in FastForwardReporter #76
Comments
It looks reasonable. I guess mocking won't help if you want exact list of sent metrics. |
cool, thanks! yeah, it depends on what you're trying to unit test exactly, in some cases using the real FastForward client would still be appropriate. How do you feel about me making this change in |
Hello @clairemcginty } |
hey @ao2017 ! unfortunately as it is now we can't do that because there's no non-private constructor available in |
hey @clairemcginty, could you elaborate on why you think changing this in ffwd-client-java bigger / more impactful? Do you mean more places to update/change if you want to use this new feature/ability? |
@malish8632 it's mostly because I'm less familiar with the FastForward lib itself and less sure if it's a breaking change in any way. I'll file a ticket there and link this one 👍 |
@clairemcginty good point. My comment was based on StubbedFastForwardClient above which implies the existence of a default constructor. Anyway, about just adding a protected constructor ? |
@clairemcginty I added a protected default constructor to FastForward to address this issue spotify/ffwd-client-java#13. |
semantic-metrics/ffwd-reporter/src/main/java/com/spotify/metrics/ffwd/FastForwardReporter.java
Lines 156 to 159 in 3890ddd
The current setup for
FastForwardReporter
requires a user to pass in a realFastForward
client, which is not easily unit testable -- in a production environment theFastForward
client would be already running within the container, but in a local unit testing environment this can be pretty cumbersome to set up.It would be simpler if we had some kind of interface or abstract class to allow the user to sub in different implementations of the FastForward client -- the only method it would have to implement is
public void send(Metric metric) { }
.Quick code sketch of what I'm thinking:
Then the
FastForwardReporter
's builder would look like:And in a unit-testing context we could easily sub in something like this that's easy to validate:
lmk what you think! I'm happy to make the PR myself if this seems reasonable.
(Not sure if this issue belongs more in ffwd-client-java... it would probably be better to fix it there, but it's also a bigger/more impactful change to make.)
The text was updated successfully, but these errors were encountered: