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
f10210f7
Commit
f10210f7
authored
Jan 11, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make MetricsEndpoint response types public
Closes gh-11602
parent
a051e30f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
43 deletions
+44
-43
MetricsEndpoint.java
...springframework/boot/actuate/metrics/MetricsEndpoint.java
+42
-41
MetricsEndpointTests.java
...gframework/boot/actuate/metrics/MetricsEndpointTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java
View file @
f10210f7
...
@@ -92,8 +92,8 @@ public class MetricsEndpoint {
...
@@ -92,8 +92,8 @@ public class MetricsEndpoint {
Map
<
String
,
Set
<
String
>>
availableTags
=
getAvailableTags
(
meters
);
Map
<
String
,
Set
<
String
>>
availableTags
=
getAvailableTags
(
meters
);
tags
.
forEach
((
t
)
->
availableTags
.
remove
(
t
.
getKey
()));
tags
.
forEach
((
t
)
->
availableTags
.
remove
(
t
.
getKey
()));
return
new
MetricResponse
(
requiredMetricName
,
return
new
MetricResponse
(
requiredMetricName
,
asList
(
samples
,
MetricResponse
.
Sample
::
new
),
asList
(
samples
,
Sample:
:
new
),
asList
(
availableTags
,
MetricResponse
.
AvailableTag
::
new
));
asList
(
availableTags
,
AvailableTag:
:
new
));
}
}
private
List
<
Tag
>
parseTags
(
List
<
String
>
tags
)
{
private
List
<
Tag
>
parseTags
(
List
<
String
>
tags
)
{
...
@@ -154,7 +154,7 @@ public class MetricsEndpoint {
...
@@ -154,7 +154,7 @@ public class MetricsEndpoint {
/**
/**
* Response payload for a metric name listing.
* Response payload for a metric name listing.
*/
*/
static
class
ListNamesResponse
{
public
static
final
class
ListNamesResponse
{
private
final
Set
<
String
>
names
;
private
final
Set
<
String
>
names
;
...
@@ -170,7 +170,7 @@ public class MetricsEndpoint {
...
@@ -170,7 +170,7 @@ public class MetricsEndpoint {
/**
/**
* Response payload for a metric name selector.
* Response payload for a metric name selector.
*/
*/
static
class
MetricResponse
{
public
static
final
class
MetricResponse
{
private
final
String
name
;
private
final
String
name
;
...
@@ -197,58 +197,59 @@ public class MetricsEndpoint {
...
@@ -197,58 +197,59 @@ public class MetricsEndpoint {
return
this
.
availableTags
;
return
this
.
availableTags
;
}
}
/**
}
* A set of tags for further dimensional drilldown and their potential values.
*/
static
class
AvailableTag
{
private
final
String
tag
;
/**
* A set of tags for further dimensional drilldown and their potential values.
*/
public
static
final
class
AvailableTag
{
private
final
Set
<
String
>
values
;
private
final
String
tag
;
AvailableTag
(
String
tag
,
Set
<
String
>
values
)
{
private
final
Set
<
String
>
values
;
this
.
tag
=
tag
;
this
.
values
=
values
;
}
public
String
getTag
()
{
AvailableTag
(
String
tag
,
Set
<
String
>
values
)
{
return
this
.
tag
;
this
.
tag
=
tag
;
}
this
.
values
=
values
;
}
public
Set
<
String
>
getValues
()
{
public
String
getTag
()
{
return
this
.
values
;
return
this
.
tag
;
}
}
}
/**
public
Set
<
String
>
getValues
()
{
* A measurement sample combining a {@link Statistic statistic} and a value.
return
this
.
values
;
*/
}
static
class
Sample
{
}
private
final
Statistic
statistic
;
/**
* A measurement sample combining a {@link Statistic statistic} and a value.
*/
public
static
final
class
Sample
{
private
final
Double
value
;
private
final
Statistic
statistic
;
Sample
(
Statistic
statistic
,
Double
value
)
{
private
final
Double
value
;
this
.
statistic
=
statistic
;
this
.
value
=
value
;
}
public
Statistic
getStatistic
()
{
Sample
(
Statistic
statistic
,
Double
value
)
{
return
this
.
statistic
;
this
.
statistic
=
statistic
;
}
this
.
value
=
value
;
}
public
Double
getValue
()
{
public
Statistic
getStatistic
()
{
return
this
.
value
;
return
this
.
statistic
;
}
}
@Override
public
Double
getValue
()
{
public
String
toString
()
{
return
this
.
value
;
return
"MeasurementSample{"
+
"statistic="
+
this
.
statistic
+
", value="
}
+
this
.
value
+
'}'
;
}
@Override
public
String
toString
()
{
return
"MeasurementSample{"
+
"statistic="
+
this
.
statistic
+
", value="
+
this
.
value
+
'}'
;
}
}
}
}
}
}
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/MetricsEndpointTests.java
View file @
f10210f7
...
@@ -132,12 +132,12 @@ public class MetricsEndpointTests {
...
@@ -132,12 +132,12 @@ public class MetricsEndpointTests {
private
Optional
<
Double
>
getCount
(
MetricsEndpoint
.
MetricResponse
response
)
{
private
Optional
<
Double
>
getCount
(
MetricsEndpoint
.
MetricResponse
response
)
{
return
response
.
getMeasurements
().
stream
()
return
response
.
getMeasurements
().
stream
()
.
filter
((
ms
)
->
ms
.
getStatistic
().
equals
(
Statistic
.
Count
)).
findAny
()
.
filter
((
ms
)
->
ms
.
getStatistic
().
equals
(
Statistic
.
Count
)).
findAny
()
.
map
(
MetricsEndpoint
.
MetricResponse
.
Sample
::
getValue
);
.
map
(
MetricsEndpoint
.
Sample
::
getValue
);
}
}
private
Stream
<
String
>
availableTagKeys
(
MetricsEndpoint
.
MetricResponse
response
)
{
private
Stream
<
String
>
availableTagKeys
(
MetricsEndpoint
.
MetricResponse
response
)
{
return
response
.
getAvailableTags
().
stream
()
return
response
.
getAvailableTags
().
stream
()
.
map
(
MetricsEndpoint
.
MetricResponse
.
AvailableTag
::
getTag
);
.
map
(
MetricsEndpoint
.
AvailableTag
::
getTag
);
}
}
}
}
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