Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform MetricsParseService annotation #512

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ public MetricsParseResult metricsParse(TSpanData tSpanData) {
jtd.setTraceId(tSpanData.getTraceId());
long startTime = tSpanData.getStartEpochNanos();
if (startTime > 0) {
// 纳秒转为毫秒
// ns to ms
jtd.setStartTime(startTime / (1000 * 1000));
}
long duration = tSpanData.getEndEpochNanos() - startTime;
// 纳秒转为微秒,微秒到毫秒需要保留小数
// Nanoseconds to microseconds, microseconds to milliseconds need to keep decimal
long durationUs = duration / 1000;
if (duration > 0) {
jtd.setDuration(durationUs);
Expand Down Expand Up @@ -248,7 +248,7 @@ public MetricsParseResult metricsParse(TSpanData tSpanData) {
}
}
}
// 获取process中的属性
// Gets the properties in process
TResource resource = tSpanData.getResouce();
if (resource != null) {
TAttributes resourceAttributes = resource.getAttributes();
Expand Down Expand Up @@ -286,7 +286,7 @@ private void computeMetrics(JaegerTracerDomain jtc, HeraTraceEtlConfig config) {
if (StringUtils.isEmpty(jtc.getType())) {
return;
}
// 请求类型处理
// Request type processing
if ("redis".equals(jtc.getType())) {
redisBuild(jtc.getStatement(), jtc);
}
Expand All @@ -296,23 +296,23 @@ private void computeMetrics(JaegerTracerDomain jtc, HeraTraceEtlConfig config) {
String serviceName = jtc.getServiceName();
String metricsServiceName = formatServiceName(serviceName);
jtc.setMetricsServiceName(metricsServiceName);
// http请求
// http request
if (SpanType.HTTP.equals(jtc.getType())) {
String httpMetricsName = "hera_";
if (SpanKind.SERVER.equals(jtc.getKind())) {
// 过滤http server端指标
// Filters http server counters
if (exclude(config == null ? excludeHttpServer : config.getExcludeHttpserverMethod(), jtc.getMethod())) {
return;
}
singleMetrics.newCounter(httpMetricsName+jtc.getType() + "TotalMethodCount", "methodName", "application", "serverIp", "serverEnv", "serverEnvId")
.with(jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId())
.add(1, jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId());
// 成功失败数
// success or fail counter
if (jtc.isSuccess()) {
singleMetrics.newCounter(httpMetricsName+jtc.getType() + "SuccessMethodCount", "methodName", "application", "serverIp", "serverEnv", "serverEnvId")
.with(jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId())
.add(1, jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId());
// 慢查询
// slow query
if (jtc.getDuration() > (config == null ? httpSlowTime : config.getHttpSlowThreshold())) {
singleMetrics.newCounter(httpMetricsName+"httpSlowQuery", "methodName", "application", "serverIp", "serverEnv", "serverEnvId")
.with(jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId())
Expand All @@ -335,12 +335,10 @@ private void computeMetrics(JaegerTracerDomain jtc, HeraTraceEtlConfig config) {
singleMetrics.newCounter(httpMetricsName+jtc.getType() + "ClientTotalMethodCount", "methodName", "application", "serverIp", "serverEnv", "serverEnvId")
.with(jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId())
.add(1, jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId());
// 成功失败数
if (jtc.isSuccess()) {
singleMetrics.newCounter(httpMetricsName+jtc.getType() + "ClientSuccessMethodCount", "methodName", "application", "serverIp", "serverEnv", "serverEnvId")
.with(jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId())
.add(1, jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId());
// 慢查询
if (jtc.getDuration() > (config == null ? httpSlowTime : config.getHttpSlowThreshold())) {
singleMetrics.newCounter(httpMetricsName+"httpClientSlowQuery", "methodName", "application", "serverIp", "serverEnv", "serverEnvId")
.with(jtc.getMethod(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId())
Expand All @@ -361,7 +359,7 @@ private void computeMetrics(JaegerTracerDomain jtc, HeraTraceEtlConfig config) {
.observe(jtc.getDuration(), metricsServiceName, jtc.getServerIp(), jtc.getServiceEnv(), jtc.getServiceEnvId());
}
}
// dubbo请求
// dubbo request
if (SpanType.DUBBO.equals(jtc.getType())) {
String dubboMetricsName = "hera_";
if (SpanKind.CLIENT.equals(jtc.getKind())) {
Expand Down Expand Up @@ -420,7 +418,6 @@ private void computeMetrics(JaegerTracerDomain jtc, HeraTraceEtlConfig config) {
}
// redis
if (SpanType.REDIS.equals(jtc.getType())) {
// 区分慢查询
String redisMetricsName = "hera_";
if (jtc.isSuccess()) {
singleMetrics.newCounter(redisMetricsName + "RedisSuccessCount", "method", "host", "port", "application", "serverIp", "serverEnv", "serverEnvId")
Expand Down Expand Up @@ -581,7 +578,7 @@ private boolean exclude(String excludeList, String excludeString) {
}

/**
* 处理redis method\key
* deal redis method\key
*
* @param statement
* @param jtc
Expand Down