Skip to content

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

Merged
merged 6 commits into from
Mar 1, 2018
Merged

Draft of driver metrics #470

merged 6 commits into from
Mar 1, 2018

Conversation

zhenlineo
Copy link
Contributor

@zhenlineo zhenlineo commented Feb 13, 2018

Added Basics of Driver metrics and Connection pool metrics.
The driver metrics are enabled with system property driver.metrics.enabled=true

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
@zhenlineo zhenlineo force-pushed the 1.6-metrics branch 4 times, most recently from 4626caa to 0ffda3f Compare February 21, 2018 13:20
…d accessing a metrics of a pool before the metrics is fully created.
Copy link
Contributor

@lutovich lutovich left a 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 );
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 pass metrics into the driver constructor and avoid this setter.

@@ -144,6 +146,16 @@ private void assertOpen()
}
}

public DriverMetrics driverMetrics()
Copy link
Contributor

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;
Copy link
Contributor

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();
Copy link
Contributor

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)?

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 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();
Copy link
Contributor

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
Copy link
Contributor

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();
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 #creating() name instead?


import java.util.Map;

public interface DriverMetrics
Copy link
Contributor

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" ) );
Copy link
Contributor

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();
Copy link
Contributor

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

@zhenlineo zhenlineo mentioned this pull request Feb 28, 2018
@zhenlineo zhenlineo merged commit be4cd1d into neo4j:1.6 Mar 1, 2018
@zhenlineo zhenlineo deleted the 1.6-metrics branch March 1, 2018 14:30
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.

2 participants