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

optimize: add applicationId for metric #3371

Merged
merged 8 commits into from
Jan 12, 2021

Conversation

spilledyear
Copy link
Contributor

@spilledyear spilledyear commented Dec 14, 2020

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #3370

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@funky-eyes funky-eyes added the first-time contributor first-time contributor label Dec 14, 2020
@spilledyear spilledyear changed the title fix #3370 add appId in metric feature: #3370 add appId in metric Dec 14, 2020
@spilledyear spilledyear changed the title feature: #3370 add appId in metric feature:add appId for metric Dec 14, 2020
@@ -44,6 +44,8 @@
*/
private final String name;

private String appId;
Copy link
Contributor

Choose a reason for hiding this comment

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

may applicationId better?

@@ -23,6 +23,8 @@
public interface IdConstants {
String SEATA_TRANSACTION = "seata.transaction";

String APP_ID_KEY = "appId";
Copy link
Contributor

Choose a reason for hiding this comment

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

may applicationId better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已改成applicationId

@@ -35,6 +38,8 @@

private final Map<GlobalStatus, Consumer<GlobalTransactionEvent>> consumers;

private static final String EMPTY_APP_ID = "EMPTY_APP";
Copy link
Contributor

Choose a reason for hiding this comment

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

why we need an empty app id ,default value ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

就是想给个默认值

Copy link
Contributor

Choose a reason for hiding this comment

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

在Prometheus中,Metrics是一个多维概念,null和"EMPTY_APP"(默认值)表现出来的含义是不一样的:

  1. 如果有一个APP的ID就叫"EMPTY_APP"是不是也可以呢?那么就冲突了;
  2. Metrics终究会被汇聚在一个上层的监控系统中,别的系统中的null不一定解释为等价于"EMPTY_APP",也许他们做的不好可能叫“DEFAULT_APP”另当别论,但是null是没有二义性的。

}

@Subscribe
public void recordGlobalTransactionEventForMetrics(GlobalTransactionEvent event) {
if (registry != null && consumers.containsKey(event.getStatus())) {
if (StringUtils.isEmpty(event.getAppId())) {
event.setAppId(EMPTY_APP_ID);
Copy link
Contributor

Choose a reason for hiding this comment

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

if there is no app id ,maybe there is no need to generate this tag (app id tag)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

为什么不是 没有appId, 就使用默认的appId呢?担心性能吗?

@@ -63,7 +63,7 @@ public void test() throws IOException, TransactionException, InterruptedExceptio

Assertions.assertEquals(1, measurements.size());
Assertions.assertEquals(1,
measurements.get("seata.transaction(meter=counter,role=tc,status=active)").getValue(), 0);
measurements.get("seata.transaction(appId=EMPTY_APP,meter=counter,role=tc,status=active)").getValue(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

same above,if there is no app id ,maybe there is no need to generate this tag (app id tag)

@codecov-io
Copy link

codecov-io commented Jan 3, 2021

Codecov Report

Merging #3371 (462ea63) into develop (95d39e6) will decrease coverage by 0.00%.
The diff coverage is 79.48%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3371      +/-   ##
=============================================
- Coverage      51.56%   51.56%   -0.01%     
+ Complexity      3374     3372       -2     
=============================================
  Files            617      617              
  Lines          20438    20455      +17     
  Branches        2565     2565              
=============================================
+ Hits           10539    10547       +8     
- Misses          8839     8846       +7     
- Partials        1060     1062       +2     
Impacted Files Coverage Δ Complexity Δ
...va/io/seata/core/event/GlobalTransactionEvent.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ava/io/seata/server/metrics/MetricsSubscriber.java 78.72% <76.92%> (-0.69%) 7.00 <4.00> (ø)
...o/seata/server/coordinator/DefaultCoordinator.java 53.92% <100.00%> (-0.50%) 28.00 <0.00> (-1.00)
.../java/io/seata/server/coordinator/DefaultCore.java 48.19% <100.00%> (+0.63%) 24.00 <0.00> (ø)
...c/main/java/io/seata/config/FileConfiguration.java 43.10% <0.00%> (-1.15%) 12.00% <0.00%> (ø%)
...in/java/io/seata/server/session/GlobalSession.java 83.63% <0.00%> (-0.46%) 71.00% <0.00%> (-1.00%)

Copy link
Contributor

@zhengyangyong zhengyangyong left a comment

Choose a reason for hiding this comment

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

all seems good

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM . for zhengyangyong

@l81893521 l81893521 changed the title feature:add appId for metric optimize: add applicationId for metric Jan 12, 2021
Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature:add appId for metric
6 participants