[SCB-327] Update metrics publish data module (Re-organized)#555
Conversation
| this.invocationType, finishedTime - startProcessingTime, | ||
| finishedTime - startTime, statusCode, success)); | ||
| .triggerEvent(new InvocationFinishedEvent(operationMeta.getMicroserviceQualifiedName(), this.invocationType, | ||
| startProcessingTime - startTime, |
There was a problem hiding this comment.
Can you explain the meaning of startTime, startProcessingTime?
There was a problem hiding this comment.
On producer side , startTime is when invocation received,startProcessingTime is when invocation fetch from queue and start execute;
| package org.apache.servicecomb.metrics.common; | ||
| package org.apache.servicecomb.foundation.metrics.publish; | ||
|
|
||
| public class DefaultHealthCheckExtraData { |
There was a problem hiding this comment.
What's the relationship between the DefaultHealthCheckExtraData and HealthCheckResult.extraData?
We don't need to use the String to store result, it's easy to use toString method to turn the instance of HealthCheckExtraData into a string.
There was a problem hiding this comment.
We may no need provider this default health check because :
1.make some confusion
2.Service Center had same function
|
|
||
| import org.apache.servicecomb.foundation.metrics.MetricsConst; | ||
|
|
||
| public class MetricNode { |
There was a problem hiding this comment.
Can you show me the unit test of MetricNode?
| if (metrics.containsKey(id)) { | ||
| return new MetricNode(metrics.get(id), groupTagKeys); | ||
| } | ||
| return null; |
There was a problem hiding this comment.
I'm not a big fan of null, you can throw exception or using Option return the value.
| if (InvocationType.PRODUCER.equals(event.getInvocationType())) { | ||
| ProducerInvocationMonitor monitor = registryMonitor.getProducerInvocationMonitor(event.getOperationName()); | ||
| monitor.getWaitInQueue().increment(-1); | ||
| monitor.getLifeTimeInQueue().update(event.getInQueueNanoTime()); |
There was a problem hiding this comment.
Why did you remove this line?
There was a problem hiding this comment.
queue stage latency had move from this event to finish event
| import org.apache.servicecomb.foundation.metrics.MetricsConst; | ||
|
|
||
| public class ConsumerInvocationMonitor extends InvocationMonitor { | ||
| public class ConsumerInvocationMonitor { |
There was a problem hiding this comment.
What we should do if we want to change the ConsumerInvocationMonitor into ProducerInvocationMonitor?We don't need to write lots Classes here, please use abstraction to reduce the number of the class.
There was a problem hiding this comment.
I had use DefaultMonitorRegistry as monitor container replace it;
In order to update monitor,I had add a group of basic wrapped monitor extends from AbstractMonitor;
Measure metrics will direct from DefaultMonitorRegistry.getInstance().getRegisteredMonitors() then getValue()
| public RegistryMetric toRegistryMetric(int windowTimeIndex) { | ||
| Map<String, ConsumerInvocationMetric> consumerInvocationMetrics = new HashMap<>(); | ||
| public Map<String, Double> measure(int windowTimeIndex, boolean calculateLatency) { | ||
| Map<String, Double> measurements = new HashMap<>(systemMonitor.measure()); |
There was a problem hiding this comment.
If we want measure the invocation monitor, we don't need to know if it consumerInvocationMonitor or producerInvocationMonitor.
ec11b9e to
cdd41b8
Compare
|
|
||
| InvocationStartedEvent startedEvent = new InvocationStartedEvent(operationMeta.getMicroserviceQualifiedName(), | ||
| InvocationType.PRODUCER, System.nanoTime()); | ||
| ProducerInvocationStartedEvent startedEvent = new ProducerInvocationStartedEvent( |
There was a problem hiding this comment.
Why do you introduce the ProducerInvocationStartedEvent?
| } | ||
|
|
||
| runOnExecutor(startedEvent); | ||
| runOnExecutor(startedEvent.getStartedTime()); |
There was a problem hiding this comment.
Using the Event could be easy for the user to extend.
| } | ||
| } | ||
| } | ||
| } catch (ServiceCombException ignored) { |
There was a problem hiding this comment.
Why did you ignored the exception.
| return new MetricNode(metrics.get(id), groupTagKeys); | ||
| } | ||
| return null; | ||
| throw new ServiceCombException("no such id"); |
There was a problem hiding this comment.
Please keep the id in the exception for the developer to find out the failed reason.
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.servicecomb.metrics.core.event.servo; |
There was a problem hiding this comment.
Listener is application level code, it should not bind to the servo implementation.
195b5c2 to
ede2c86
Compare
| public void triggerStartExecutionEvent() { | ||
| if (InvocationType.PRODUCER.equals(invocationType)) { | ||
| this.startExecutionTime = System.nanoTime(); | ||
| EventUtils.triggerEvent(new InvocationStartExecutionEvent(operationMeta.getMicroserviceQualifiedName())); |
There was a problem hiding this comment.
This EventUtils is more like a singleton.
There was a problem hiding this comment.
OK , delete EventUtils and make EventBus as a singleton
| TestMgr.check(true, metrics.size() > 0); | ||
| TestMgr.check(true, metrics.get( | ||
| "servicecomb.invocation(operation=springmvc.codeFirst.saySomething,role=producer,stage=whole,statistic=count,status=200)") | ||
| "servicecomb.invocation(operation=springmvc.codeFirst.saySomething,role=PRODUCER,stage=total,statistic=count,status=200)") |
There was a problem hiding this comment.
the PRODUCER is upper case, but other tags are lower case.
| } | ||
| //before receive any request,there are no MetricsConst.SERVICECOMB_INVOCATION,so getMetricTree will throw ServiceCombException | ||
| catch (ServiceCombException ignored) { | ||
| return; |
There was a problem hiding this comment.
We need to log the exception for trace the issue
There was a problem hiding this comment.
add a containsId method and no need throw exception any more
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
|
|
||
| public class TestMetricNode { | ||
| @Test | ||
| public void test() { |
There was a problem hiding this comment.
The unit test method is not generic one, it should has some meaning which can help us to find out the key reason of failed test.
There was a problem hiding this comment.
Ok ,add comments for explain check reason
There was a problem hiding this comment.
You need to separate the test methods, please take https://github.com/apache/incubator-servicecomb-saga/blob/master/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackTest.java as an example.
| System.getProperties().setProperty("servo.pollers", time > 0 ? String.valueOf(time) : "5000"); | ||
| } | ||
|
|
||
| public Counter getCounter(boolean isStepCounter, String name, String... tags) { |
There was a problem hiding this comment.
This method exposes the counter detail which is not right way.
There was a problem hiding this comment.
separate into two method named getCounter and getStepCounter
| @CrossOrigin | ||
| public HealthCheckResult healthWithName(@PathVariable(name = "name") String name) { | ||
| return manager.check(name); | ||
| public Map<String, HealthCheckResult> checkHealthDetail() { |
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
ede2c86 to
db0755c
Compare
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
| @@ -66,6 +47,6 @@ public boolean checkHealth() { | |||
| @RequestMapping(path = "/detail", method = RequestMethod.GET) | |||
There was a problem hiding this comment.
The path name need to updated.
There was a problem hiding this comment.
finnal path is /health/details
| public void test() { | ||
| HealthCheckerManager manager = new HealthCheckerManager(); | ||
| manager.register(new HealthChecker() { | ||
| HealthCheckerManager.getInstance().register(new HealthChecker() { |
There was a problem hiding this comment.
Here you just check one HealthChecker. The test should test at least zero,one and two HealthChecker.
There was a problem hiding this comment.
zero,one and two HealthChecker check logic had added in TestHealthCheckerManager
Signed-off-by: zhengyangyong <yangyong.zheng@huawei.com>
| @RequestMapping(path = "/health") | ||
| public class HealthCheckerPublisher { | ||
| @RequestMapping(path = "/", method = RequestMethod.GET) | ||
| @CrossOrigin |
There was a problem hiding this comment.
This annotation may not work
Follow this checklist to help us incorporate your contribution quickly and easily:
[SCB-XXX] Fixes bug in ApproximateQuantiles, where you replaceSCB-XXXwith the appropriate JIRA issue.mvn clean installto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.Re-organize commits of PR : #550
Adjust metrics publish format to spring cloud netflix style
Before:
servicecomb.instance.system.cpu.load
servicecomb.instance.system.cpu.runningThreads
servicecomb.instance.system.heap.init
servicecomb.instance.system.heap.max
servicecomb.instance.system.heap.commit
servicecomb.instance.system.heap.used
servicecomb.instance.system.nonHeap.init
servicecomb.instance.system.nonHeap.max
servicecomb.instance.system.nonHeap.commit
servicecomb.instance.system.nonHeap.used
servicecomb.instance | operationName.producer.waitInQueue.count
servicecomb.instance | operationName.producer.lifeTimeInQueue.average
servicecomb.instance | operationName.producer.lifeTimeInQueue.max
servicecomb.instance | operationName.producer.lifeTimeInQueue.min
servicecomb.instance | operationName.producer.executionTime.average
servicecomb.instance | operationName.producer.executionTime.max
servicecomb.instance | operationName.producer.executionTime.min
servicecomb.instance | operationName.producer.producerLatency.average
servicecomb.instance | operationName.producer.producerLatency.max
servicecomb.instance | operationName.producer.producerLatency.min
servicecomb.instance | operationName.producer.producerCall.total
servicecomb.instance | operationName.producer.producerCall.tps
servicecomb.instance | operationName.consumer.consumerLatency.average
servicecomb.instance | operationName.consumer.consumerLatency.max
servicecomb.instance | operationName.consumer.consumerLatency.min
servicecomb.instance | operationName.consumer.consumerCall.total
servicecomb.instance | operationName.consumer.consumerCall.tps
Current:
jvm(statistic=gauge,name={name})
{name} include :
cpuLoad,cpuRunningThreads,heapInit,heapMax,heapCommit,
heapUsed,nonHeapInit,nonHeapMax,nonHeapCommit,nonHeapUsed
servicecomb.invocation(operation={operationName},role={role},stage={stage},statistic={statistic},status={status},unit={unit})