Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
21a0b054
Commit
21a0b054
authored
Mar 01, 2020
by
Johnny Lim
Committed by
Stephane Nicoll
Mar 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add descriptions for data source pool metrics
See gh-20354
parent
c71ed407
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
DataSourcePoolMetrics.java
...work/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java
+14
-9
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jdbc/DataSourcePoolMetrics.java
View file @
21a0b054
...
@@ -22,6 +22,7 @@ import java.util.function.Function;
...
@@ -22,6 +22,7 @@ import java.util.function.Function;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
io.micrometer.core.instrument.Gauge
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
io.micrometer.core.instrument.MeterRegistry
;
import
io.micrometer.core.instrument.Tag
;
import
io.micrometer.core.instrument.Tag
;
import
io.micrometer.core.instrument.Tags
;
import
io.micrometer.core.instrument.Tags
;
...
@@ -65,23 +66,27 @@ public class DataSourcePoolMetrics implements MeterBinder {
...
@@ -65,23 +66,27 @@ public class DataSourcePoolMetrics implements MeterBinder {
@Override
@Override
public
void
bindTo
(
MeterRegistry
registry
)
{
public
void
bindTo
(
MeterRegistry
registry
)
{
if
(
this
.
metadataProvider
.
getDataSourcePoolMetadata
(
this
.
dataSource
)
!=
null
)
{
if
(
this
.
metadataProvider
.
getDataSourcePoolMetadata
(
this
.
dataSource
)
!=
null
)
{
bindPoolMetadata
(
registry
,
"active"
,
DataSourcePoolMetadata:
:
getActive
);
bindPoolMetadata
(
registry
,
"active"
,
DataSourcePoolMetadata:
:
getActive
,
bindPoolMetadata
(
registry
,
"idle"
,
DataSourcePoolMetadata:
:
getIdle
);
"Current number of active connections that have been allocated from the data source."
);
bindPoolMetadata
(
registry
,
"max"
,
DataSourcePoolMetadata:
:
getMax
);
bindPoolMetadata
(
registry
,
"idle"
,
DataSourcePoolMetadata:
:
getIdle
,
bindPoolMetadata
(
registry
,
"min"
,
DataSourcePoolMetadata:
:
getMin
);
"Number of established but idle connections."
);
bindPoolMetadata
(
registry
,
"max"
,
DataSourcePoolMetadata:
:
getMax
,
"Maximum number of active connections that can be allocated at the same time."
);
bindPoolMetadata
(
registry
,
"min"
,
DataSourcePoolMetadata:
:
getMin
,
"Minimum number of idle connections in the pool."
);
}
}
}
}
private
<
N
extends
Number
>
void
bindPoolMetadata
(
MeterRegistry
registry
,
String
metricName
,
private
<
N
extends
Number
>
void
bindPoolMetadata
(
MeterRegistry
registry
,
String
metricName
,
Function
<
DataSourcePoolMetadata
,
N
>
function
)
{
Function
<
DataSourcePoolMetadata
,
N
>
function
,
String
description
)
{
bindDataSource
(
registry
,
metricName
,
this
.
metadataProvider
.
getValueFunction
(
function
));
bindDataSource
(
registry
,
metricName
,
this
.
metadataProvider
.
getValueFunction
(
function
)
,
description
);
}
}
private
<
N
extends
Number
>
void
bindDataSource
(
MeterRegistry
registry
,
String
metricName
,
private
<
N
extends
Number
>
void
bindDataSource
(
MeterRegistry
registry
,
String
metricName
,
Function
<
DataSource
,
N
>
function
)
{
Function
<
DataSource
,
N
>
function
,
String
description
)
{
if
(
function
.
apply
(
this
.
dataSource
)
!=
null
)
{
if
(
function
.
apply
(
this
.
dataSource
)
!=
null
)
{
registry
.
gauge
(
"jdbc.connections."
+
metricName
,
this
.
tags
,
this
.
dataSource
,
Gauge
.
builder
(
"jdbc.connections."
+
metricName
,
this
.
dataSource
,
(
m
)
->
function
.
apply
(
m
).
doubleValue
())
(
m
)
->
function
.
apply
(
m
).
doubleValue
()
);
.
tags
(
this
.
tags
).
description
(
description
).
register
(
registry
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment