Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit c1a1bc3

Browse files
authored
Merge pull request #779 from shalousun/master
feat: Support for JMeter Prometheus Listener
2 parents b00efa8 + 8c352de commit c1a1bc3

6 files changed

Lines changed: 183 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
## smart-doc版本
22

3+
### 版本号:3.0.3
4+
5+
- 更新日期: 2024-3-30
6+
- 更新内容:
7+
1. 新功能::sparkles: 添加 WebSocket 支持并更新许可证有效期。[#752](https://github.com/TongchengOpenSource/smart-doc/pull/752)
8+
2. 修复 #746:为枚举值添加分隔符。[#754](https://github.com/TongchengOpenSource/smart-doc/pull/754)
9+
3. 新功能:优化 JSR 验证信息的提取。[#755](https://github.com/TongchengOpenSource/smart-doc/pull/755)
10+
4. 在参数中添加扩展以支持 openapi..[#759](https://github.com/TongchengOpenSource/smart-doc/pull/759)
11+
5. 修复泛型 typeName 或 returnType 的错误。[#761](https://github.com/TongchengOpenSource/smart-doc/pull/761)
12+
6. 修复 Solon 框架中的非接口文档问题。[#765](https://github.com/TongchengOpenSource/smart-doc/pull/765)
13+
7. 修复 Javadoc 标签使用错误的提示。[#767](https://github.com/TongchengOpenSource/smart-doc/pull/767)
14+
8. Solon 已弃用 PathVar 并替换为 Path。[#765](https://github.com/TongchengOpenSource/smart-doc/pull/765)
15+
9. 优化 Javadoc 标签使用错误的提示。[#767](https://github.com/TongchengOpenSource/smart-doc/pull/767)
16+
10. 修复 Solon 框架中非接口文档的问题。[#771](https://github.com/TongchengOpenSource/smart-doc/pull/771)
17+
11. 更新:修复 null 参数值中多余的双引号问题。[#772](https://github.com/TongchengOpenSource/smart-doc/pull/772)
18+
12. 新功能:支持 RPC 中多级接口继承。[#773](https://github.com/TongchengOpenSource/smart-doc/pull/773)
19+
13. 新功能:在添加自定义注解到参数后,忽略集合参数检查。[#774](https://github.com/TongchengOpenSource/smart-doc/pull/774)
20+
14. 新功能:忽略集合参数检查。[#775](https://github.com/TongchengOpenSource/smart-doc/pull/775)
21+
322
### 版本号:3.0.2
423
- 更新日期: 2024-2-26
524
- 更新内容:

src/main/java/com/ly/doc/builder/DocBuilderTemplate.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,14 @@ public Template buildAllRenderDocTemplate(List<ApiDoc> apiDocList, ApiConfig con
179179
if (Objects.nonNull(apiDoc)) {
180180
tpl.binding(TemplateVariable.DESC.getVariable(), apiDoc.getDesc());
181181
tpl.binding(TemplateVariable.ORDER.getVariable(), apiDoc.getOrder());
182-
// 类名
183182
tpl.binding(TemplateVariable.LIST.getVariable(), apiDoc.getList());
184183
}
184+
// add jmeter prometheus listener
185+
if (Objects.nonNull(config.getJmeter())){
186+
tpl.binding(TemplateVariable.JMETER_PROMETHEUS_LISTENER.getVariable(), config.getJmeter().isAddPrometheusListener());
187+
} else {
188+
tpl.binding(TemplateVariable.JMETER_PROMETHEUS_LISTENER.getVariable(), Boolean.FALSE);
189+
}
185190
return tpl;
186191
}
187192

src/main/java/com/ly/doc/constants/TemplateVariable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public enum TemplateVariable {
172172
* webSocketDocList
173173
*/
174174
WEBSOCKET_DOC_LIST("webSocketDocList"),
175+
176+
/**
177+
* jmeterPrometheusListener
178+
*/
179+
JMETER_PROMETHEUS_LISTENER("jmeterPrometheusListener"),
175180
;
176181

177182
/**

src/main/java/com/ly/doc/model/ApiConfig.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.ly.doc.constants.ComponentTypeEnum;
2424
import com.ly.doc.constants.DocLanguage;
2525
import com.ly.doc.handler.ICustomJavaMethodHandler;
26+
import com.ly.doc.model.jmeter.JMeter;
2627
import com.ly.doc.model.rpc.RpcApiDependency;
2728
import com.power.common.util.CollectionUtil;
2829

@@ -393,10 +394,18 @@ public class ApiConfig {
393394

394395
/**
395396
* Show JSR validation information
397+
*
396398
* @since 3.0.3
397399
*/
398400
private boolean showValidation = Boolean.TRUE;
399401

402+
/**
403+
* JMeter
404+
*
405+
* @since 3.0.4
406+
*/
407+
private JMeter jmeter;
408+
400409
public static ApiConfig getInstance() {
401410
return instance;
402411
}
@@ -1054,4 +1063,12 @@ public boolean isShowValidation() {
10541063
public void setShowValidation(boolean showValidation) {
10551064
this.showValidation = showValidation;
10561065
}
1066+
1067+
public JMeter getJmeter() {
1068+
return jmeter;
1069+
}
1070+
1071+
public void setJmeter(JMeter jmeter) {
1072+
this.jmeter = jmeter;
1073+
}
10571074
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2018-2024 smart-doc
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
package com.ly.doc.model.jmeter;
22+
23+
public class JMeter {
24+
private boolean AddPrometheusListener;
25+
26+
public boolean isAddPrometheusListener() {
27+
return AddPrometheusListener;
28+
}
29+
30+
public void setAddPrometheusListener(boolean addPrometheusListener) {
31+
AddPrometheusListener = addPrometheusListener;
32+
}
33+
}

src/main/resources/template/JMeter.jmx

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,109 @@ ${doc.requestExample.jsonBody}
156156
<% } %>
157157
</hashTree>
158158
<%}%>
159+
<%if(jmeterPrometheusListener){%>
160+
<com.github.johrstrom.listener.PrometheusListener guiclass="com.github.johrstrom.listener.gui.PrometheusListenerGui" testclass="com.github.johrstrom.listener.PrometheusListener" testname="Prometheus Listener" enabled="true">
161+
<collectionProp name="prometheus.collector_definitions">
162+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
163+
<stringProp name="collector.help">default help string</stringProp>
164+
<stringProp name="collector.metric_name">jmeter_summary</stringProp>
165+
<stringProp name="collector.type">SUMMARY</stringProp>
166+
<collectionProp name="collector.labels">
167+
<stringProp name="50511102">category</stringProp>
168+
<stringProp name="102727412">label</stringProp>
169+
<stringProp name="3059181">code</stringProp>
170+
</collectionProp>
171+
<stringProp name="collector.quantiles_or_buckets">0.9,0.1|0.95,0.1|0.99,0.1</stringProp>
172+
<stringProp name="listener.collector.measuring">ResponseTime</stringProp>
173+
</elementProp>
174+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
175+
<stringProp name="collector.help">default help string</stringProp>
176+
<stringProp name="collector.metric_name">jmeter_count_total</stringProp>
177+
<stringProp name="collector.type">COUNTER</stringProp>
178+
<collectionProp name="collector.labels">
179+
<stringProp name="102727412">label</stringProp>
180+
</collectionProp>
181+
<stringProp name="collector.quantiles_or_buckets"></stringProp>
182+
<stringProp name="listener.collector.measuring">CountTotal</stringProp>
183+
</elementProp>
184+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
185+
<stringProp name="collector.help">default help string</stringProp>
186+
<stringProp name="collector.metric_name">jmeter_success_total</stringProp>
187+
<stringProp name="collector.type">COUNTER</stringProp>
188+
<collectionProp name="collector.labels">
189+
<stringProp name="50511102">category</stringProp>
190+
<stringProp name="102727412">label</stringProp>
191+
<stringProp name="3059181">code</stringProp>
192+
</collectionProp>
193+
<stringProp name="collector.quantiles_or_buckets"></stringProp>
194+
<stringProp name="listener.collector.measuring">SuccessTotal</stringProp>
195+
</elementProp>
196+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
197+
<stringProp name="collector.help">default help string</stringProp>
198+
<stringProp name="collector.metric_name">jmeter_rsize</stringProp>
199+
<stringProp name="collector.type">HISTOGRAM</stringProp>
200+
<collectionProp name="collector.labels">
201+
<stringProp name="102727412">label</stringProp>
202+
</collectionProp>
203+
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
204+
<stringProp name="listener.collector.measuring">ResponseSize</stringProp>
205+
</elementProp>
206+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
207+
<stringProp name="collector.help">default help string</stringProp>
208+
<stringProp name="collector.metric_name">jmeter_success_ratio</stringProp>
209+
<stringProp name="collector.type">SUCCESS_RATIO</stringProp>
210+
<collectionProp name="collector.labels">
211+
<stringProp name="102727412">label</stringProp>
212+
</collectionProp>
213+
<stringProp name="collector.quantiles_or_buckets"></stringProp>
214+
<stringProp name="listener.collector.measuring">SuccessRatio</stringProp>
215+
</elementProp>
216+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
217+
<stringProp name="collector.help">default help string</stringProp>
218+
<stringProp name="collector.metric_name">jmeter_latency</stringProp>
219+
<stringProp name="collector.type">SUMMARY</stringProp>
220+
<collectionProp name="collector.labels">
221+
<stringProp name="102727412">label</stringProp>
222+
</collectionProp>
223+
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
224+
<stringProp name="listener.collector.measuring">Latency</stringProp>
225+
</elementProp>
226+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
227+
<stringProp name="collector.help">default help string</stringProp>
228+
<stringProp name="collector.metric_name">jmeter_idle_time</stringProp>
229+
<stringProp name="collector.type">SUMMARY</stringProp>
230+
<collectionProp name="collector.labels">
231+
<stringProp name="102727412">label</stringProp>
232+
</collectionProp>
233+
<stringProp name="collector.quantiles_or_buckets">0.9,0.1|0.95,0.1|0.99,0.01</stringProp>
234+
<stringProp name="listener.collector.measuring">IdleTime</stringProp>
235+
</elementProp>
236+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
237+
<stringProp name="collector.help">default help string</stringProp>
238+
<stringProp name="collector.metric_name">jmeter_failure_total</stringProp>
239+
<stringProp name="collector.type">COUNTER</stringProp>
240+
<collectionProp name="collector.labels">
241+
<stringProp name="50511102">category</stringProp>
242+
<stringProp name="102727412">label</stringProp>
243+
<stringProp name="3059181">code</stringProp>
244+
</collectionProp>
245+
<stringProp name="collector.quantiles_or_buckets"></stringProp>
246+
<stringProp name="listener.collector.measuring">FailureTotal</stringProp>
247+
</elementProp>
248+
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
249+
<stringProp name="collector.help">default help string</stringProp>
250+
<stringProp name="collector.metric_name">jmeter_connect_time</stringProp>
251+
<stringProp name="collector.type">COUNTER</stringProp>
252+
<collectionProp name="collector.labels">
253+
<stringProp name="102727412">label</stringProp>
254+
</collectionProp>
255+
<stringProp name="collector.quantiles_or_buckets"></stringProp>
256+
<stringProp name="listener.collector.measuring">ConnectTime</stringProp>
257+
</elementProp>
258+
</collectionProp>
259+
<stringProp name="TestPlan.comments">This listener &quot;measures&quot; everything, sometimes in summaries, sometimes in histograms.</stringProp>
260+
</com.github.johrstrom.listener.PrometheusListener>
261+
<% } %>
159262
</hashTree>
160263
</hashTree>
161264
</jmeterTestPlan>

0 commit comments

Comments
 (0)