Search in sources :

Example 1 with InvocationStartedEvent

use of org.apache.servicecomb.core.metrics.InvocationStartedEvent in project incubator-servicecomb-java-chassis by apache.

the class TestMonitorManager method setup.

@BeforeClass
public static void setup() throws InterruptedException {
    System.getProperties().setProperty(MetricsConfig.METRICS_WINDOW_TIME, "2000");
    // ==========================================================================
    // fun1 is a PRODUCER invocation call 2 time and all is completed
    // two time success
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun1"));
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, TimeUnit.MILLISECONDS.toNanos(100), TimeUnit.MILLISECONDS.toNanos(200), TimeUnit.MILLISECONDS.toNanos(300), 200));
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun1"));
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, TimeUnit.MILLISECONDS.toNanos(300), TimeUnit.MILLISECONDS.toNanos(400), TimeUnit.MILLISECONDS.toNanos(700), 200));
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun1", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun1"));
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun1", InvocationType.PRODUCER, TimeUnit.MILLISECONDS.toNanos(300), TimeUnit.MILLISECONDS.toNanos(400), TimeUnit.MILLISECONDS.toNanos(700), 500));
    // ==========================================================================
    // fun2 is a CONSUMER invocation call once and completed
    EventBus.getInstance().triggerEvent(new InvocationFinishedEvent("fun2", InvocationType.CONSUMER, 0, 0, TimeUnit.MILLISECONDS.toNanos(300), 200));
    // ==========================================================================
    // fun3 is a PRODUCER invocation call uncompleted
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun3", InvocationType.PRODUCER, System.nanoTime()));
    EventBus.getInstance().triggerEvent(new InvocationStartExecutionEvent("fun3"));
    // ==========================================================================
    // fun4 is a PRODUCER call only started and no processing start and finished
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent("fun4", InvocationType.PRODUCER, System.nanoTime()));
    Map<String, Double> metrics = MonitorManager.getInstance().measure();
    currentWindowMetricsLoader = new MetricsLoader(metrics);
    // sim at lease one window time
    Thread.sleep(2000);
    metrics = MonitorManager.getInstance().measure();
    nextWindowMetricsLoader = new MetricsLoader(metrics);
}
Also used : InvocationFinishedEvent(org.apache.servicecomb.core.metrics.InvocationFinishedEvent) InvocationStartExecutionEvent(org.apache.servicecomb.core.metrics.InvocationStartExecutionEvent) MetricsLoader(org.apache.servicecomb.foundation.metrics.publish.MetricsLoader) InvocationStartedEvent(org.apache.servicecomb.core.metrics.InvocationStartedEvent) BeforeClass(org.junit.BeforeClass)

Example 2 with InvocationStartedEvent

use of org.apache.servicecomb.core.metrics.InvocationStartedEvent in project incubator-servicecomb-java-chassis by apache.

the class Invocation method onStart.

public void onStart() {
    this.startTime = System.nanoTime();
    EventManager.post(new InvocationStartEvent(this));
    // old logic, need to be deleted
    EventBus.getInstance().triggerEvent(new InvocationStartedEvent(getMicroserviceQualifiedName(), invocationType, startTime));
}
Also used : InvocationStartEvent(org.apache.servicecomb.core.event.InvocationStartEvent) InvocationStartedEvent(org.apache.servicecomb.core.metrics.InvocationStartedEvent)

Aggregations

InvocationStartedEvent (org.apache.servicecomb.core.metrics.InvocationStartedEvent)2 InvocationStartEvent (org.apache.servicecomb.core.event.InvocationStartEvent)1 InvocationFinishedEvent (org.apache.servicecomb.core.metrics.InvocationFinishedEvent)1 InvocationStartExecutionEvent (org.apache.servicecomb.core.metrics.InvocationStartExecutionEvent)1 MetricsLoader (org.apache.servicecomb.foundation.metrics.publish.MetricsLoader)1 BeforeClass (org.junit.BeforeClass)1