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
6230d905
Commit
6230d905
authored
Jun 05, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
9b5e5f7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
23 deletions
+18
-23
AggregateMetricReader.java
...boot/actuate/metrics/aggregate/AggregateMetricReader.java
+15
-20
AggregateMetricReaderTests.java
...actuate/metrics/aggregate/AggregateMetricReaderTests.java
+3
-3
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/aggregate/AggregateMetricReader.java
View file @
6230d905
...
...
@@ -29,9 +29,8 @@ import org.springframework.util.StringUtils;
* collecting data from many sources in the same form (like a scaled-out application). The
* source has metrics with names in the form {@code *.*.counter.**} and
* {@code *.*.[anything].**}, and the result has metric names in the form
* {@code aggregate.count.**} and {@code aggregate.[anything].**}. Counters are
* summed and anything else (i.e. gauges) are aggregated by choosing the most recent
* value.
* {@code aggregate.count.**} and {@code aggregate.[anything].**}. Counters are summed and
* anything else (i.e. gauges) are aggregated by choosing the most recent value.
*
* @author Dave Syer
* @since 1.3.0
...
...
@@ -60,7 +59,6 @@ public class AggregateMetricReader implements MetricReader {
* names)</li>
* </ul>
* Default is "d.d" (we assume there is a global prefix of length 2).
*
* @param keyPattern the keyPattern to set
*/
public
void
setKeyPattern
(
String
keyPattern
)
{
...
...
@@ -68,13 +66,15 @@ public class AggregateMetricReader implements MetricReader {
}
/**
* Prefix to apply to all output metrics. A period will be appended if not present in the
* provided value.
*
* Prefix to apply to all output metrics. A period will be appended if not present in
* the provided value.
* @param prefix the prefix to use (default "aggregator.")
*/
public
void
setPrefix
(
String
prefix
)
{
this
.
prefix
=
prefix
.
endsWith
(
"."
)
?
prefix
:
(
StringUtils
.
hasText
(
prefix
)
?
prefix
+
"."
:
""
);
if
(
StringUtils
.
hasText
(
prefix
)
&&
!
prefix
.
endsWith
(
"."
))
{
prefix
=
prefix
+
"."
;
}
this
.
prefix
=
prefix
;
}
@Override
...
...
@@ -139,20 +139,15 @@ public class AggregateMetricReader implements MetricReader {
String
[]
keys
=
StringUtils
.
delimitedListToStringArray
(
name
,
"."
);
String
[]
patterns
=
StringUtils
.
delimitedListToStringArray
(
this
.
keyPattern
,
"."
);
StringBuilder
builder
=
new
StringBuilder
();
int
index
=
0
;
for
(
index
=
0
;
index
<
patterns
.
length
;
index
++)
{
if
(
"k"
.
equals
(
patterns
[
index
]))
{
if
(
builder
.
length
()
>
0
)
{
builder
.
append
(
"."
);
}
builder
.
append
(
keys
[
index
]);
for
(
int
i
=
0
;
i
<
patterns
.
length
;
i
++)
{
if
(
"k"
.
equals
(
patterns
[
i
]))
{
builder
.
append
(
builder
.
length
()
>
0
?
"."
:
""
);
builder
.
append
(
keys
[
i
]);
}
}
for
(;
index
<
keys
.
length
;
index
++)
{
if
(
builder
.
length
()
>
0
)
{
builder
.
append
(
"."
);
}
builder
.
append
(
keys
[
index
]);
for
(
int
i
=
patterns
.
length
;
i
<
keys
.
length
;
i
++)
{
builder
.
append
(
builder
.
length
()
>
0
?
"."
:
""
);
builder
.
append
(
keys
[
i
]);
}
return
builder
.
toString
();
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/aggregate/AggregateMetricReaderTests.java
View file @
6230d905
...
...
@@ -16,9 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
aggregate
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
java.util.Date
;
import
org.junit.Test
;
...
...
@@ -26,6 +23,9 @@ import org.springframework.boot.actuate.metrics.Metric;
import
org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository
;
import
org.springframework.boot.actuate.metrics.writer.Delta
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
/**
* Tests for {@link AggregateMetricReader}.
*
...
...
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