Skip to content

Metrics for DataSource #1013

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

Closed
mdeinum opened this issue Jun 2, 2014 · 3 comments
Closed

Metrics for DataSource #1013

mdeinum opened this issue Jun 2, 2014 · 3 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@mdeinum
Copy link
Contributor

mdeinum commented Jun 2, 2014

Currently the metrics provided are repository based or for the web request. It would be nice if we could also get some metrics about the datasources, like in DropWizard. It would be nice if we could get an overview of the min/max connecties, current open connecties and pool usage/saturation. Those metrics can help to tune the datasource configuration for live systems (and could be a trigger if the open connections or pool usage go upto 100%).

@snicoll snicoll self-assigned this Jun 2, 2014
@snicoll snicoll added this to the 1.2.0 milestone Jun 2, 2014
@snicoll
Copy link
Member

snicoll commented Jun 12, 2014

There are two ways we can implement this. Either we update the DatasourceHealthIndicator to provide this information (alongside the version and the status of the connection) or we add it to the metrics endpoint.

If we want to add it to the metrics endpoint, then we need to rework a bit how PublicMetrics works because it's hard to customize it. I would see a composite similar to what we have done for the health endpoint.

What do you guys think?

snicoll added a commit to snicoll/spring-boot that referenced this issue Jun 13, 2014
This commit adds an abstraction that provides a standard manner to
retrieve various information that are shared by most data sources.

DataSourceInfo is implemented by the three data source implementations
that boot supports out-of-the-box: Tomcat, Hikari and Commons dbcp.

This abstraction is used to provide two additional metrics per data
source defined in the application: the number of allocated
connection(s) and the current usage of the connection pool.

Additional DataSourceInfo implementations for other data source types
can be added very easily, check DataourceInfoProvidersConfiguration
for more details.

Fixes spring-projectsgh-1013
snicoll added a commit to snicoll/spring-boot that referenced this issue Jun 13, 2014
This commit adds an abstraction that provides a standard manner to
retrieve various information that are shared by most data sources.

DataSourceInfo is implemented by the three data source implementations
that boot supports out-of-the-box: Tomcat, Hikari and Commons dbcp.

This abstraction is used to provide two additional metrics per data
source defined in the application: the number of allocated
connection(s) and the current usage of the connection pool.

Additional DataSourceInfo implementations for other data source types
can be added very easily, check DataourceInfoProvidersConfiguration
for more details.

Fixes spring-projectsgh-1013
@markfisher markfisher modified the milestones: 1.1.4, 1.2.0 Jul 3, 2014
@philwebb philwebb removed this from the 1.1.4 milestone Jul 3, 2014
snicoll added a commit to snicoll/spring-boot that referenced this issue Jul 18, 2014
This commit adds an abstraction that provides a standard manner to
retrieve various information that are shared by most data sources.

DataSourceInfo is implemented by the three data source implementations
that boot supports out-of-the-box: Tomcat, Hikari and Commons dbcp.

This abstraction is used to provide two additional metrics per data
source defined in the application: the number of allocated
connection(s) (.active) and the current usage of the connection pool
(.usage).

All such metrics share the 'datasource.' prefix. The prefix is futher
qualifier for each data source:

* If the data source is the primary data source (that is either the
  only available data source or the one flagged @primary amongst the
  existing ones), the prefix is "datasource.primary"
* If the data source ends with "dataSource", the prefix is the name
  of the bean without it (i.e. batchDataSource becomes batch)
* In all other cases, the name of the bean is used

It is possible to override part of all of those defaults by
registering a bean with a customized version of
DataSourcePublicMetrics.

Additional DataSourceInfo implementations for other data source types
can be added very easily, check DataourceInfoProvidersConfiguration
for more details.

Fixes spring-projectsgh-1013
@snicoll
Copy link
Member

snicoll commented Jul 22, 2014

This issue is ready for review. What bothers me the most is the package location. I think we can be smarter about where to put things and avoid a cyclical dependency.

Besides, #1282 may be yet another use of DataSourceInfo so maybe it would make sense to promote this infrastructure to spring-boot itself? hint: setValidationQuery is a datasource-specific feature so you need a way to discover if a) it's available and b) it has been set

@snicoll snicoll added this to the 1.2.0 milestone Aug 5, 2014
@snicoll snicoll removed the icebox label Aug 29, 2014
@snicoll
Copy link
Member

snicoll commented Aug 29, 2014

I forgot to fix the package location issue.

@snicoll snicoll reopened this Aug 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants