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
0be8d431
authored
Jul 11, 2016
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
graphite_hostport' (default to null) , if null no reporting will start
parent
47538921
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
9 deletions
README.md
build.gradle
src/main/java/microservice/MicroserviceApp.java
src/main/java/microservice/io/iface/IMetricsFactory.java
src/main/java/microservice/io/impl/IMetricsFactoryImpl.java
README.md
View file @
0be8d431
### Microservice Framework in JAVA
## Version 1.2.2:
-
graphite_hostport' (default to null) , if null no reporting will start
## Version 1.2.1:
-
create with metrics false/true
-
init metrics publisher only once
...
...
build.gradle
View file @
0be8d431
group
'com.ipgallery.common'
version
'1.2.
1
'
version
'1.2.
2
'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
...
...
src/main/java/microservice/MicroserviceApp.java
View file @
0be8d431
...
...
@@ -349,7 +349,7 @@ public class MicroserviceApp
if
(
this
.
enableMetrics
)
{
IMetricsFactoryImpl
.
getInstance
().
startReporting
();
IMetricsFactoryImpl
.
getInstance
().
startReporting
(
appName
);
}
if
(
rsiParams
!=
null
&&
restServerActive
)
{
...
...
@@ -447,7 +447,7 @@ public class MicroserviceApp
if
(
serverList
!=
null
)
{
if
(
this
.
enableMetrics
)
{
IMetricsFactoryImpl
.
getInstance
().
startReporting
();
IMetricsFactoryImpl
.
getInstance
().
startReporting
(
appName
);
}
...
...
src/main/java/microservice/io/iface/IMetricsFactory.java
View file @
0be8d431
...
...
@@ -32,8 +32,9 @@ public interface IMetricsFactory
/**
* must be at the end of init , after the netrics are defined
* @param appName
*/
public
void
startReporting
();
public
void
startReporting
(
String
appName
);
public
IMeter
createMeter
(
String
name
);
public
ICounter
createCounter
(
String
name
);
...
...
src/main/java/microservice/io/impl/IMetricsFactoryImpl.java
View file @
0be8d431
...
...
@@ -3,7 +3,6 @@ package microservice.io.impl;
import
com.codahale.metrics.*
;
import
com.codahale.metrics.Timer.Context
;
import
com.codahale.metrics.graphite.Graphite
;
import
com.codahale.metrics.graphite.GraphiteReporter
;
import
com.codahale.metrics.graphite.PickledGraphite
;
import
microservice.MicroserviceApp
;
...
...
@@ -137,20 +136,22 @@ public class IMetricsFactoryImpl implements IMetricsFactory
}
@Override
public
void
startReporting
()
public
void
startReporting
(
String
appName
)
{
String
graphite_hostport
=
MicroserviceApp
.
getsInstance
().
getConfiguration
().
getString
(
"graphite_hostport"
,
"localhost:2015"
);
String
graphite_hostport
=
MicroserviceApp
.
getsInstance
().
getConfiguration
().
getString
(
"graphite_hostport"
,
null
);
Long
interval
=
MicroserviceApp
.
getsInstance
().
getConfiguration
().
getLong
(
"graphite_report_intrerval"
,
Long
.
valueOf
(
10
));
if
(
graphite_hostport
!=
null
)
{
int
index
=
graphite_hostport
.
indexOf
(
':'
);
final
PickledGraphite
pickledGraphite
=
new
PickledGraphite
(
new
InetSocketAddress
(
graphite_hostport
.
substring
(
0
,
index
),
Integer
.
valueOf
(
graphite_hostport
.
substring
(
index
+
1
)).
intValue
()));
final
PickledGraphite
pickledGraphite
=
new
PickledGraphite
(
new
InetSocketAddress
(
graphite_hostport
.
substring
(
0
,
index
),
Integer
.
valueOf
(
graphite_hostport
.
substring
(
index
+
1
)).
intValue
()));
reporter
=
GraphiteReporter
.
forRegistry
(
metrics
)
.
prefixedWith
(
"web1.example.com"
)
.
prefixedWith
(
appName
)
.
convertRatesTo
(
TimeUnit
.
SECONDS
)
.
convertDurationsTo
(
TimeUnit
.
MILLISECONDS
)
.
filter
(
MetricFilter
.
ALL
)
.
build
(
pickledGraphite
);
reporter
.
start
(
interval
.
intValue
(),
TimeUnit
.
SECONDS
);
}
}
@Override
public
IMeter
createMeter
(
String
name
)
...
...
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