-
Notifications
You must be signed in to change notification settings - Fork 155
Draft of driver metrics #470
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
Added Basics of Driver metrics and Connection pool metrics. The driver metrics are enabled with system property `driver.metrics.enabled=true` TODO: Histgram and ConnectionMetrics
9b217c8
to
c58f606
Compare
4626caa
to
0ffda3f
Compare
0ffda3f
to
2a1c771
Compare
…d accessing a metrics of a pool before the metrics is fully created.
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.
Review round completed
|
||
InternalDriver driver = createDriver( uri, address, connectionPool, config, newRoutingSettings, | ||
eventExecutorGroup, securityPlan, retryLogic ); | ||
|
||
driver.driverMetrics( metrics ); |
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.
Would be nice to pass metrics into the driver constructor and avoid this setter.
@@ -144,6 +146,16 @@ private void assertOpen() | |||
} | |||
} | |||
|
|||
public DriverMetrics driverMetrics() |
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.
Maybe #metrics()
?
private final Map<BoltServerAddress,AtomicInteger> addressToInUseChannelCount = new ConcurrentHashMap<>(); | ||
private final Map<BoltServerAddress,AtomicInteger> addressToIdleChannelCount = new ConcurrentHashMap<>(); | ||
private final Logger log; | ||
private DriverMetricsListener metricsListener; |
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.
Field can be final
public int inUseChannelCount( BoltServerAddress address ) | ||
{ | ||
AtomicInteger count = addressToInUseChannelCount.get( address ); | ||
return count == null ? 0 : count.get(); |
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.
Maybe return addressToInUseChannelCount.getOrDefault(address, 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 cannot default to 0 as it is an Integer
object. I feel it is more expensive to do extra boxing and unboxing than this null check.
public int idleChannelCount( BoltServerAddress address ) | ||
{ | ||
AtomicInteger count = addressToIdleChannelCount.get( address ); | ||
return count == null ? 0 : count.get(); |
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.
Maybe return addressToIdleChannelCount.getOrDefault(address, 0)
?
void start(); | ||
long elapsed(); | ||
|
||
interface PoolListenerEvent extends ListenerEvent |
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.
Are these two inner interfaces needed? Can we just keep ListenerEvent
?
* The number is changing up and down from time to time. | ||
* @return The amount of connection that is to be created. | ||
*/ | ||
int toCreate(); |
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.
What do you think about #creating()
name instead?
|
||
import java.util.Map; | ||
|
||
public interface DriverMetrics |
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.
Maybe just Metrics
?
String DRIVER_METRICS_ENABLED_KEY = "driver.metrics.enabled"; | ||
static boolean isDriverMetricsEnabled() | ||
{ | ||
return Boolean.valueOf( System.getProperty( DRIVER_METRICS_ENABLED_KEY, "false" ) ); |
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.
return Boolean.getBoolean(DRIVER_METRICS_ENABLED_KEY);
can be done instead
* The status of the pool | ||
* @return The status of the pool in a string | ||
*/ | ||
String poolStatus(); |
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'd vote for an enum instead
1b21127
to
f6dc900
Compare
Added Basics of Driver metrics and Connection pool metrics.
The driver metrics are enabled with system property
driver.metrics.enabled=true