Skip to content
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

Document that application.conf is not read by default when using the Cassandra auto-configuration #21787

Closed
Esakkimuthu991 opened this issue Jun 9, 2020 · 4 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@Esakkimuthu991
Copy link

Esakkimuthu991 commented Jun 9, 2020

CqlSession.getMetrics() returning null value, even after configuration for enabling the metrics has been added to it.

@Autowired
private CqlSession cqlsession;

MetricRegistry metricRegistry = cqlsession.getMetrics()
            .orElseThrow(() -> new IllegalArgumentException("not able to get metrics"))
            .getRegistry();

application.properties:

datastax-java-driver.advanced.metrics {
  session.enabled = [connected-nodes, cql-requests]
  node.enabled = [pool.open-connections, pool.in-flight]
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 9, 2020
@wilkinsona
Copy link
Member

wilkinsona commented Jun 9, 2020

Your application.properties configuration doesn't look like it is in the correct format. It looks like Cassandra driver's .conf file format to me. Perhaps a typo in the file's name in the description above?

Using application.conf won't fix your problem as, when using Spring Boot's auto-configuration of Cassandra's Driver, application.conf is not used. The supported mechanisms for configuring Cassandra are described in the documentation. In your case, you should use a DriverConfigLoaderBuilderCustomizer bean:

@Bean
DriverConfigLoaderBuilderCustomizer metricsCustomizer() {
	return (builder) -> {
		builder.withStringList(DefaultDriverOption.METRICS_SESSION_ENABLED,
				Arrays.asList("connected-nodes", "cql-requests"));
		builder.withStringList(DefaultDriverOption.METRICS_NODE_ENABLED,
				Arrays.asList("pool.open-connections", "pool.in-flight"));
	};
}

We should probably update the documentation to clarify that application.conf is not used by the auto-configured DriverConfigLoader.

@wilkinsona wilkinsona changed the title Cassandra CqlSession.getMetrics() is returning optional.empty() even relevent configuration addedin project Document that application.conf is not read by default when using the Cassandra auto-configuration Jun 9, 2020
@wilkinsona wilkinsona added type: documentation A documentation update for: team-attention An issue we'd like other members of the team to review and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 9, 2020
@wilkinsona wilkinsona added this to the 2.2.x milestone Jun 9, 2020
@snicoll snicoll modified the milestones: 2.2.x, 2.3.x Jun 9, 2020
@Esakkimuthu991
Copy link
Author

Esakkimuthu991 commented Jun 9, 2020

Your application.properties configuration doesn't look like it is in the correct format. It looks like Cassandra driver's .conf file format to me. Perhaps a typo in the file's name in the description above?

Using application.conf won't fix your problem as, when using Spring Boot's auto-configuration of Cassandra's Driver, application.conf is not used. The supported mechanisms for configuring Cassandra are described in the documentation. In your case, you should use a DriverConfigLoaderBuilderCustomizer bean:

@Bean
DriverConfigLoaderBuilderCustomizer metricsCustomizer() {
	return (builder) -> {
		builder.withStringList(DefaultDriverOption.METRICS_SESSION_ENABLED,
				Arrays.asList("connected-nodes, cql-requests"));
		builder.withStringList(DefaultDriverOption.METRICS_NODE_ENABLED,
				Arrays.asList("pool.open-connections", "pool.in-flight"));
	};
}

We should probably update the documentation to clarify that application.conf is not used by the auto-configured DriverConfigLoader.

After changing my code to use above as suggested.

cqlsessionmetrics

Its Skip the properties and returns empty as earlier for cqlsession.getMetrics()

@wilkinsona
Copy link
Member

Sorry, that was a typo in my code snippet. I've edited it above to correct it. It should have read Arrays.asList("connected-nodes", "cql-requests") rather than Arrays.asList("connected-nodes, cql-requests").

@Esakkimuthu991
Copy link
Author

Sorry, that was a typo in my code snippet. I've edited it above to correct it. It should have read Arrays.asList("connected-nodes", "cql-requests") rather than Arrays.asList("connected-nodes, cql-requests").

Thanks Solved my problem

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Jun 10, 2020
@snicoll snicoll self-assigned this Aug 11, 2020
@snicoll snicoll modified the milestones: 2.3.x, 2.3.3 Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

5 participants