Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ca53eff4
authored
Jun 13, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
2.0.4 add hystrix metrics to display
parent
6cef7404
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
5 deletions
build.gradle
src/main/java/microservice/handlers/MonitorHandler.java
src/main/java/microservice/io/impl/IRestClientHttpImpl.java
src/main/resources/microservice/services/metrics.html
build.gradle
View file @
ca53eff4
group
'com.ipgallery.common'
version
'2.0.
2
-services'
version
'2.0.
4
-services'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
...
...
src/main/java/microservice/handlers/MonitorHandler.java
View file @
ca53eff4
...
...
@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import
java.util.stream.Stream
;
import
com.codahale.metrics.Counter
;
import
com.codahale.metrics.Gauge
;
import
com.codahale.metrics.Meter
;
import
com.codahale.metrics.Timer
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
...
@@ -70,6 +71,7 @@ public class MonitorHandler implements CommonServices.IMethodClass
final
SortedMap
<
String
,
Counter
>
counterSortedMap
=
factoryImpl
.
getMetrics
().
getCounters
();
final
SortedMap
<
String
,
Meter
>
meterSortedMap
=
factoryImpl
.
getMetrics
().
getMeters
();
final
SortedMap
<
String
,
Timer
>
timerSortedMap
=
factoryImpl
.
getMetrics
().
getTimers
();
final
SortedMap
<
String
,
Gauge
>
gaugeSortedMap
=
factoryImpl
.
getMetrics
().
getGauges
();
if
(
"list"
.
equals
(
reqCtx
.
getParameter
(
"viewType"
)))
{
// as list
...
...
@@ -100,7 +102,15 @@ public class MonitorHandler implements CommonServices.IMethodClass
}).
collect
(
Collectors
.
toList
());
objectNode
.
set
(
"timers"
,
this
.
objMapper
.
valueToTree
(
meters
));
}
if
(!
gaugeSortedMap
.
isEmpty
())
{
final
List
<
ObjectNode
>
meters
=
gaugeSortedMap
.
entrySet
().
stream
().
map
(
metricEntry
->
{
ObjectNode
objNode
=
JsonNodeFactory
.
instance
.
objectNode
().
put
(
FIELD_NAME
,
metricEntry
.
getKey
());
final
JsonNode
jsonNode
=
this
.
objMapper
.
valueToTree
(
metricEntry
.
getValue
());
jsonNode
.
fields
().
forEachRemaining
(
entry
->
objNode
.
set
(
entry
.
getKey
(),
entry
.
getValue
()));
return
objNode
;
}).
collect
(
Collectors
.
toList
());
objectNode
.
set
(
"gauges"
,
this
.
objMapper
.
valueToTree
(
meters
));
}
}
else
{
// as object
...
...
src/main/java/microservice/io/impl/IRestClientHttpImpl.java
View file @
ca53eff4
...
...
@@ -6,6 +6,7 @@ import java.util.Optional;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.function.Consumer
;
import
com.netflix.config.ConfigurationManager
;
import
microservice.MicroserviceApp
;
import
microservice.defs.Enums
;
import
microservice.io.iface.IServiceDiscovery
;
...
...
src/main/resources/microservice/services/metrics.html
View file @
ca53eff4
...
...
@@ -7,21 +7,28 @@
<script>
// Builds the HTML Table out of myList.
function
buildHtmlTable
(
data
)
{
// meters
var
selector
=
'#meterTable'
;
$
(
selector
).
empty
()
var
list
=
data
.
objectNode
.
meters
;
var
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
// timers
selector
=
'#timerTable'
;
$
(
selector
).
empty
()
list
=
data
.
objectNode
.
timers
;
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
// gauges
selector
=
'#gaugeTable'
;
$
(
selector
).
empty
()
list
=
data
.
objectNode
.
gauges
;
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
}
function
addRows
(
selector
,
columns
,
myList
){
...
...
@@ -87,6 +94,8 @@ $(document).ready(function(){
</table>
<table
class=
"striped"
id=
"timerTable"
border=
"1"
>
</table>
<table
class=
"striped"
id=
"gaugeTable"
border=
"1"
>
</table>
</body>
</html>
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