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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
4 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'
group
'com.ipgallery.common'
version
'2.0.
2
-services'
version
'2.0.
4
-services'
apply
plugin:
'java'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
apply
plugin:
'maven-publish'
...
...
src/main/java/microservice/handlers/MonitorHandler.java
View file @
ca53eff4
...
@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
...
@@ -7,6 +7,7 @@ import java.util.stream.Collectors;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
import
com.codahale.metrics.Counter
;
import
com.codahale.metrics.Counter
;
import
com.codahale.metrics.Gauge
;
import
com.codahale.metrics.Meter
;
import
com.codahale.metrics.Meter
;
import
com.codahale.metrics.Timer
;
import
com.codahale.metrics.Timer
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.JsonNode
;
...
@@ -70,6 +71,7 @@ public class MonitorHandler implements CommonServices.IMethodClass
...
@@ -70,6 +71,7 @@ public class MonitorHandler implements CommonServices.IMethodClass
final
SortedMap
<
String
,
Counter
>
counterSortedMap
=
factoryImpl
.
getMetrics
().
getCounters
();
final
SortedMap
<
String
,
Counter
>
counterSortedMap
=
factoryImpl
.
getMetrics
().
getCounters
();
final
SortedMap
<
String
,
Meter
>
meterSortedMap
=
factoryImpl
.
getMetrics
().
getMeters
();
final
SortedMap
<
String
,
Meter
>
meterSortedMap
=
factoryImpl
.
getMetrics
().
getMeters
();
final
SortedMap
<
String
,
Timer
>
timerSortedMap
=
factoryImpl
.
getMetrics
().
getTimers
();
final
SortedMap
<
String
,
Timer
>
timerSortedMap
=
factoryImpl
.
getMetrics
().
getTimers
();
final
SortedMap
<
String
,
Gauge
>
gaugeSortedMap
=
factoryImpl
.
getMetrics
().
getGauges
();
if
(
"list"
.
equals
(
reqCtx
.
getParameter
(
"viewType"
)))
if
(
"list"
.
equals
(
reqCtx
.
getParameter
(
"viewType"
)))
{
{
// as list
// as list
...
@@ -100,7 +102,15 @@ public class MonitorHandler implements CommonServices.IMethodClass
...
@@ -100,7 +102,15 @@ public class MonitorHandler implements CommonServices.IMethodClass
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
objectNode
.
set
(
"timers"
,
this
.
objMapper
.
valueToTree
(
meters
));
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
{
}
else
{
// as object
// as object
...
...
src/main/java/microservice/io/impl/IRestClientHttpImpl.java
View file @
ca53eff4
...
@@ -6,6 +6,7 @@ import java.util.Optional;
...
@@ -6,6 +6,7 @@ import java.util.Optional;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
import
com.netflix.config.ConfigurationManager
;
import
microservice.MicroserviceApp
;
import
microservice.MicroserviceApp
;
import
microservice.defs.Enums
;
import
microservice.defs.Enums
;
import
microservice.io.iface.IServiceDiscovery
;
import
microservice.io.iface.IServiceDiscovery
;
...
...
src/main/resources/microservice/services/metrics.html
View file @
ca53eff4
...
@@ -7,21 +7,28 @@
...
@@ -7,21 +7,28 @@
<script>
<script>
// Builds the HTML Table out of myList.
// Builds the HTML Table out of myList.
function
buildHtmlTable
(
data
)
{
function
buildHtmlTable
(
data
)
{
// meters
var
selector
=
'#meterTable'
;
var
selector
=
'#meterTable'
;
$
(
selector
).
empty
()
$
(
selector
).
empty
()
var
list
=
data
.
objectNode
.
meters
;
var
list
=
data
.
objectNode
.
meters
;
var
columns
=
addAllColumnHeaders
(
list
,
selector
);
var
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
addRows
(
selector
,
columns
,
list
);
// timers
selector
=
'#timerTable'
;
selector
=
'#timerTable'
;
$
(
selector
).
empty
()
$
(
selector
).
empty
()
list
=
data
.
objectNode
.
timers
;
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
);
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
addRows
(
selector
,
columns
,
list
);
}
}
function
addRows
(
selector
,
columns
,
myList
){
function
addRows
(
selector
,
columns
,
myList
){
...
@@ -87,6 +94,8 @@ $(document).ready(function(){
...
@@ -87,6 +94,8 @@ $(document).ready(function(){
</table>
</table>
<table
class=
"striped"
id=
"timerTable"
border=
"1"
>
<table
class=
"striped"
id=
"timerTable"
border=
"1"
>
</table>
</table>
<table
class=
"striped"
id=
"gaugeTable"
border=
"1"
>
</table>
</body>
</body>
</html>
</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