1
1
package tech .wetech .flexmodel .application ;
2
2
3
- import io .quarkus .arc .Arc ;
4
3
import jakarta .enterprise .context .ApplicationScoped ;
5
4
import jakarta .inject .Inject ;
6
5
import lombok .extern .slf4j .Slf4j ;
@@ -64,19 +63,19 @@ public FmMetricsResponse getFmMetrics() {
64
63
int queryCount = 0 ;
65
64
int mutationCount = 0 ;
66
65
int subscribeCount = 0 ;
67
-
66
+
68
67
try {
69
68
// 同步调用所有服务
70
69
List <ApiDefinition > defList = apiDefinitionService .findList ();
71
70
List <Datasource > dsList = datasourceService .findAll ();
72
-
71
+
73
72
// 计算模型数量
74
73
AtomicInteger modelCount = new AtomicInteger ();
75
74
for (Datasource datasource : dsList ) {
76
75
List <SchemaObject > ds = modelService .findAll (datasource .getName ());
77
76
modelCount .addAndGet (ds .size ());
78
77
}
79
-
78
+
80
79
// 获取各种计数
81
80
int reqLogCount = (int ) apiLogService .count (TRUE );
82
81
int flowDefCount = (int ) flowDefService .count (TRUE );
@@ -915,16 +914,6 @@ public AllMetricsResponse getAllMetrics() {
915
914
long startTime = System .currentTimeMillis ();
916
915
try {
917
916
// 并行获取所有指标
918
- CompletableFuture <FmMetricsResponse > fmFuture =
919
- CompletableFuture .supplyAsync (() -> {
920
- Arc .container ().requestContext ().activate ();
921
- try {
922
- return this .getFmMetrics ();
923
- } finally {
924
- Arc .container ().requestContext ().deactivate ();
925
- }
926
- });
927
-
928
917
CompletableFuture <JvmMetricsResponse > jvmFuture =
929
918
CompletableFuture .supplyAsync (this ::getJvmMetrics );
930
919
@@ -951,15 +940,15 @@ public AllMetricsResponse getAllMetrics() {
951
940
952
941
// 等待所有任务完成,设置超时时间为30秒
953
942
CompletableFuture <Void > allFutures = CompletableFuture .allOf (
954
- fmFuture , jvmFuture , cpuFuture , memoryFuture , threadsFuture ,
943
+ jvmFuture , cpuFuture , memoryFuture , threadsFuture ,
955
944
diskFuture , networkFuture , summaryFuture , prometheusFuture
956
945
);
957
946
958
947
// 等待所有任务完成或超时
959
948
allFutures .get (30 , TimeUnit .SECONDS );
960
949
961
950
// 获取结果
962
- FmMetricsResponse fm = fmFuture . get ();
951
+ FmMetricsResponse fm = this . getFmMetrics ();
963
952
JvmMetricsResponse jvm = jvmFuture .get ();
964
953
CpuMetricsResponse cpu = cpuFuture .get ();
965
954
MemoryMetricsResponse memory = memoryFuture .get ();
0 commit comments