Skip to content

Commit 93e6c4c

Browse files
author
gitlab
committed
Merge branch 'metrics@@2' into 'master'
[Improvement: add more prometheus metrics] See merge request zstackio/zstack!6113
2 parents 35b5e16 + d27ff3b commit 93e6c4c

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

core/src/main/java/org/zstack/core/cloudbus/CloudBus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,8 @@ default void handleHttpRequest(HttpEntity<String> e, HttpServletResponse rsp) {
9797
String HEADER_TASK_STACK = "task-stack";
9898
String HEADER_TASK_CONTEXT = "task-context";
9999
String HEADER_SCHEMA = "schema";
100+
101+
default int getEnvelopeSize() {
102+
return 0;
103+
}
100104
}

core/src/main/java/org/zstack/core/cloudbus/CloudBusImpl3.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.zstack.header.core.FutureReturnValueCompletion;
2626
import org.zstack.header.core.NoErrorCompletion;
2727
import org.zstack.header.core.NopeNoErrorCompletion;
28+
import org.zstack.header.core.cloudbus.CloudBusExtensionPoint;
2829
import org.zstack.header.errorcode.ErrorCode;
2930
import org.zstack.header.errorcode.OperationFailureException;
3031
import org.zstack.header.errorcode.SysErrors;
@@ -86,6 +87,7 @@ public class CloudBusImpl3 implements CloudBus, CloudBusIN {
8687
private List<Service> services = new ArrayList<>();
8788
private Map<Class, List<ReplyMessagePreSendingExtensionPoint>> replyMessageMarshaller = new ConcurrentHashMap<Class, List<ReplyMessagePreSendingExtensionPoint>>();
8889
private List<RestAPIExtensionPoint> apiExts = new ArrayList<>();
90+
private List<CloudBusExtensionPoint> msgExts = new ArrayList<>();
8991

9092
private Map<Class, List<BeforeDeliveryMessageInterceptor>> beforeDeliveryMessageInterceptors = new HashMap<Class, List<BeforeDeliveryMessageInterceptor>>();
9193
private Map<Class, List<BeforeSendMessageInterceptor>> beforeSendMessageInterceptors = new HashMap<Class, List<BeforeSendMessageInterceptor>>();
@@ -328,6 +330,7 @@ public void timeout() {
328330
};
329331

330332
envelopes.put(msg.getId(), e);
333+
msgExts.forEach(m -> m.afterAddEnvelopes(msg.getId()));
331334
send(msg, false);
332335
}
333336

@@ -1056,6 +1059,7 @@ public void installBeforePublishEventInterceptor(BeforePublishEventInterceptor i
10561059
private void populateExtension() {
10571060
services = pluginRgty.getExtensionList(Service.class);
10581061
apiExts = pluginRgty.getExtensionList(RestAPIExtensionPoint.class);
1062+
msgExts = pluginRgty.getExtensionList(CloudBusExtensionPoint.class);
10591063
services.forEach(serv->{
10601064
assert serv.getId() != null : String.format("service id can not be null[%s]", serv.getClass().getName());
10611065
registerService(serv);
@@ -1201,4 +1205,9 @@ public void handleHttpRequest(HttpEntity<String> e, HttpServletResponse rsp) {
12011205
logger.warn(String.format("unable to deliver a message received from HTTP. HTTP body: %s", e.getBody()), t);
12021206
}
12031207
}
1208+
1209+
@Override
1210+
public int getEnvelopeSize() {
1211+
return envelopes.size();
1212+
}
12041213
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.zstack.header.core.cloudbus;
2+
3+
/**
4+
* Created by mingjian.deng on 2020/3/31.
5+
*/
6+
public interface CloudBusExtensionPoint {
7+
void afterAddEnvelopes(String id);
8+
}

0 commit comments

Comments
 (0)