Skip to content

Conversation

@gr8routdoors
Copy link

This builds on #1791 with the following:

  • adds JedisCommandListener.commandConnected() to allow tracking of connection time metrics separately from command execution time
  • adds coverage with unit tests
  • rebases from the current master

More details from the PR #1791 description:
As per https://groups.google.com/forum/?fromgroups#!topic/jedis_redis/UaJubt42f_0,

This PR adds a command listener that allows for

sane integration with tracing libraries like http://opentracing.io/
capturing metrics and integration with metric libraries like http://metrics.dropwizard.io/4.0.0/
integration with logging libraries
None of the public signatures was changed, so the change should be fully backwards compatible.

@gkorland gkorland requested a review from sazzad16 April 24, 2019 07:28
@gr8routdoors
Copy link
Author

@gkorland , any update here? I believe I've addressed all your concerns.

@gkorland
Copy link
Contributor

gkorland commented May 23, 2019

gr8routdoors did you check my latest comments?

@gr8routdoors
Copy link
Author

@gkorland which comments? AFAICT they've all been addressed.

@gr8routdoors
Copy link
Author

Any update here @gkorland ?

@SerCeMan
Copy link

SerCeMan commented Jul 9, 2019

Hey, @gkorland! Would you be able to take a look at the PR? I believe it's almost there, just need to agree on some minor points :)

@SerCeMan
Copy link

Hey, @gkorland, @sazzad16! Would you be able to take a look? There is clearly a need for this, #1791 (comment).

@gkorland
Copy link
Contributor

gkorland commented Dec 17, 2019

@gr8routdoors can you please rebase the PR

@gr8routdoors
Copy link
Author

OK, I've updated to the latest from master @gkorland

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class ConnectionTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Connection operation or connection methods are not going to be tested. Move the test methods in a new test class.

Comment on lines +53 to +54
Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null, sslSocketFactory, sslParameters,
hostnameVerifier, listeners), new GenericObjectPoolConfig());
Copy link
Contributor

Choose a reason for hiding this comment

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

Use two spaces per tab.

Comment on lines +57 to +59
Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null,
Protocol.DEFAULT_DATABASE, null, false, null, null, null,
listeners), new GenericObjectPoolConfig());
Copy link
Contributor

Choose a reason for hiding this comment

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

Use two spaces per tab.

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

No need.


JedisFactory(final URI uri, final int connectionTimeout, final int soTimeout,
final String clientName, final SSLSocketFactory sslSocketFactory,
final SSLParameters sslParameters, final HostnameVerifier hostnameVerifier) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks backward compatibility. Create a new constructor.

public void setListeners(List<JedisCommandListener> listeners) {
if (listeners == null) {
if (!this.listeners.isEmpty()) { // No reason to re-create an already empty list
this.listeners = new LinkedList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

this.listeners.clear()?

}

public void addListener(JedisCommandListener listener) {
this.listeners.add(listener);
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to think if we don't need to protect here from concurrency issues, especially when use in a pool


public void sendCommand(final ProtocolCommand cmd, final byte[]... args) {
try {
notifyCommandStarted(cmd, args);
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 have more "lightweight" solution that will not add this overhead in case no listeners were set.

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.

4 participants