Skip to content

Commit

Permalink
[doc] translates chinese comment to english. (#1853)
Browse files Browse the repository at this point in the history
  • Loading branch information
dukbong authored Apr 26, 2024
1 parent 8ffe0da commit 9545c8d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void collect(CollectRep.MetricsData.Builder builder, long monitorId, Stri

timeInfo.computeDetails();

// 获取ntp服务器信息
// Obtain NTP server information
Map<String, String> resultMap = getNtpInfo(timeInfo);
resultMap.put(CollectorConstants.RESPONSE_TIME, Long.toString(responseTime));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ public List<CollectRep.MetricsData> collect(CollectRep.MetricsData.Builder build
builder.setMsg("StatusCode " + statusCode);
return null;
}
// todo 这里直接将InputStream转为了String, 对于prometheus exporter大数据来说, 会生成大对象, 可能会严重影响JVM内存空间
// todo 方法一、使用InputStream进行解析, 代码改动大; 方法二、手动触发gc, 可以参考dubbo for long i
// todo: The InputStream is directly converted to a String here
// For large data in the Prometheus exporter, this can generate large objects, which could severely impact JVM memory space
// todo: Option one: Use InputStream for parsing, but this requires significant code changes
// Option two: Manually trigger garbage collection, which can be referenced from Dubbo for long i
String resp = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
long collectTime = System.currentTimeMillis();
builder.setTime(collectTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ private static void readLabelValue(MetricFamily.Metric metric, StrBuffer buffer)
}

/**
* 获取指标的名称
* Gets the name of the metric
*
* @param buffer 行数据对象
* @param buffer Line data object
* @return token name
*/
private static String readTokenAsMetricName(StrBuffer buffer) {
Expand All @@ -179,9 +179,9 @@ private static String readTokenAsMetricName(StrBuffer buffer) {
}

/**
* 获取label的名称
* Gets the name of the label
*
* @param buffer 行数据对象
* @param buffer Line data object
* @return label name
*/
private static String readTokenAsLabelName(StrBuffer buffer) {
Expand All @@ -204,17 +204,17 @@ private static String readTokenAsLabelName(StrBuffer buffer) {
}

/**
* 获取Label的值
* Gets the value of the label
*
* @param buffer 行数据对象
* @param buffer Line data object
* @return label value
*/
private static String readTokenAsLabelValue(StrBuffer buffer) {
StringBuilder builder = new StringBuilder();
boolean escaped = false;
while (!buffer.isEmpty()) {
char c = buffer.read();
// 处理 '\\' 转义
// Handle '\\' escape character
if (escaped) {
switch (c) {
case QUOTES, '\\' -> builder.append(c);
Expand All @@ -240,47 +240,47 @@ private static String readTokenAsLabelValue(StrBuffer buffer) {
}

/**
* 是否符合metric name首字符规则
* Checks if the character complies with the metric name's first character rule
*
* @param c metric字符
* @param c Metric character
* @return true/false
*/
private static boolean isValidMetricNameStart(char c) {
return isValidLabelNameStart(c) || c == ':';
}

/**
* 是否符合metric name除首字符其他字符规则
* Checks if the character complies with the metric name's non-first character rule
*
* @param c metric字符
* @param c Metric character
* @return true/false
*/
private static boolean isValidMetricNameContinuation(char c) {
return isValidLabelNameContinuation(c) || c == ':';
}

/**
* 是否符合label name首字符规则
* Checks if the character complies with the label name's first character rule
*
* @param c metric字符
* @param c Metric character
* @return true/false
*/
private static boolean isValidLabelNameStart(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
}

/**
* 是否符合label name除首字符其他字符规则
* Checks if the character complies with the label name's non-first character rule
*
* @param c metric字符
* @param c Metric character
* @return true/false
*/
private static boolean isValidLabelNameContinuation(char c) {
return isValidLabelNameStart(c) || (c >= '0' && c <= '9');
}

/**
* 检测是否是有效的utf8编码的字符串
* Checks if a string is valid UTF-8 encoded
*
* @param s label value
* @return true/false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public class PushCollectImpl extends AbstractCollect {

private static final Integer SUCCESS_CODE = 200;

// 第一次采集多久之前的数据,其实没有办法确定,因为无法确定上次何时采集,难以避免重启后重复采集的现象,默认30s
// It's hard to determine how long ago the first data collection was, because there's no way to know when the last collection occurred.
// This makes it difficult to avoid re-collecting data after a restart. The default is 30 seconds
private static final Integer firstCollectInterval = 30000;

public PushCollectImpl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ public String supportProtocol() {

private static Map<String, String> execCmdAndParseResult(SMTP smtp, String cmd, SmtpProtocol smtpProtocol) throws IOException {
Map<String, String> result = new HashMap<>(8);
// 存入smtp连接的响应
// Store the response of the SMTP connection
result.put("smtpBanner", smtp.getReplyString());
smtp.helo(smtpProtocol.getEmail());
// 获取helo的响应
// Retrieve the response for the HELO command
String replyString = smtp.getReplyString();
result.put("heloInfo", replyString);
String[] lines = replyString.split("\n");
Expand Down

0 comments on commit 9545c8d

Please sign in to comment.