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

⚡ opt unuse label #13034

Merged
merged 15 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -43,6 +43,11 @@ public Map<String, String> getTags() {
return MetricsSupport.applicationTags(applicationModel, getExtraInfo());
}

public Map<String, String> getTags(Map<String, String> tags) {
return MetricsSupport.applicationPrivateTags(applicationModel, tags);
}


public Map<String, String> getExtraInfo() {
return extraInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,30 @@
public class MetricsSupport {

private static final String version = Version.getVersion();

private static final String commitId = Version.getLastCommitId();


public static Map<String, String> applicationTags(ApplicationModel applicationModel) {
return applicationTags(applicationModel, null);
}

public static Map<String, String> applicationTags(ApplicationModel applicationModel, @Nullable Map<String, String> extraInfo) {
Map<String, String> tags = new HashMap<>();
tags.put(TAG_IP, getLocalHost());
tags.put(TAG_HOSTNAME, getLocalHostName());
tags.put(TAG_APPLICATION_NAME, applicationModel.getApplicationName());
tags.put(TAG_APPLICATION_MODULE, applicationModel.getInternalId());
tags.put(TAG_APPLICATION_VERSION_KEY, version);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version key can be moved into gitTags

tags.put(MetricsKey.METADATA_GIT_COMMITID_METRIC.getName(), commitId);
if (CollectionUtils.isNotEmptyMap(extraInfo)) {
tags.putAll(extraInfo);
}
return tags;
}
public static Map<String, String> applicationPrivateTags(ApplicationModel applicationModel, Map<String, String> tags) {
songxiaosheng marked this conversation as resolved.
Show resolved Hide resolved
tags.put(TAG_IP, getLocalHost());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

服务方法的指标数据,ip标签为何移走了?是怎么考量的?
某个方法耗时长,怎么反推定位到是某个ip实例触发的?通过traceId定位么

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ip可以直接查指标来源的

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

明白了,感谢!👍🏻

tags.put(TAG_HOSTNAME, getLocalHostName());
tags.put(MetricsKey.METADATA_GIT_COMMITID_METRIC.getName(), commitId);
return tags;
}

public static Map<String, String> serviceTags(ApplicationModel applicationModel, String serviceKey, Map<String, String> extraInfo) {
Map<String, String> tags = applicationTags(applicationModel, extraInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public List<MetricSample> sample() {
.ifPresent(map -> map.forEach((k, v) ->
samples.add(new CounterMetricSample<>(APPLICATION_METRIC_INFO.getName(),
APPLICATION_METRIC_INFO.getDescription(),
k.getTags(), APPLICATION, v)))
k.getTags(k.getTags()), APPLICATION, v)))
);
return samples;
}
Expand Down
Loading