|
18 | 18 |
|
19 | 19 | package org.apache.skywalking.oap.server.analyzer.provider.trace.parser.listener; |
20 | 20 |
|
21 | | -import java.util.Arrays; |
| 21 | +import java.util.ArrayList; |
22 | 22 | import java.util.List; |
23 | 23 |
|
24 | 24 | import lombok.RequiredArgsConstructor; |
@@ -82,22 +82,25 @@ public Factory(ModuleManager moduleManager) { |
82 | 82 | this.namingControl = moduleManager.find(CoreModule.NAME) |
83 | 83 | .provider() |
84 | 84 | .getService(NamingControl.class); |
85 | | - this.genAIMeterAnalyzerService = moduleManager.find(GenAIAnalyzerModule.NAME) |
86 | | - .provider() |
87 | | - .getService(IGenAIMeterAnalyzerService.class); |
| 85 | + if (moduleManager.has(GenAIAnalyzerModule.NAME)) { |
| 86 | + this.genAIMeterAnalyzerService = moduleManager.find(GenAIAnalyzerModule.NAME) |
| 87 | + .provider() |
| 88 | + .getService(IGenAIMeterAnalyzerService.class); |
| 89 | + } else { |
| 90 | + this.genAIMeterAnalyzerService = null; |
| 91 | + } |
88 | 92 | } |
89 | 93 |
|
90 | 94 | @Override |
91 | 95 | public AnalysisListener create(ModuleManager moduleManager, AnalyzerModuleConfig config) { |
92 | | - return new VirtualServiceAnalysisListener( |
93 | | - sourceReceiver, |
94 | | - Arrays.asList( |
95 | | - new VirtualCacheProcessor(namingControl, config), |
96 | | - new VirtualDatabaseProcessor(namingControl, config), |
97 | | - new VirtualMQProcessor(namingControl), |
98 | | - new VirtualGenAIProcessor(genAIMeterAnalyzerService) |
99 | | - ) |
100 | | - ); |
| 96 | + List<VirtualServiceProcessor> processors = new ArrayList<>(); |
| 97 | + processors.add(new VirtualCacheProcessor(namingControl, config)); |
| 98 | + processors.add(new VirtualDatabaseProcessor(namingControl, config)); |
| 99 | + processors.add(new VirtualMQProcessor(namingControl)); |
| 100 | + if (genAIMeterAnalyzerService != null) { |
| 101 | + processors.add(new VirtualGenAIProcessor(genAIMeterAnalyzerService)); |
| 102 | + } |
| 103 | + return new VirtualServiceAnalysisListener(sourceReceiver, processors); |
101 | 104 | } |
102 | 105 | } |
103 | 106 |
|
|
0 commit comments