-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Conversation
@@ -44,6 +44,8 @@ | |||
*/ | |||
private final String name; | |||
|
|||
private String appId; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may applicationId better?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就是想给个默认值
There was a problem hiding this comment.
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"(默认值)表现出来的含义是不一样的:
- 如果有一个APP的ID就叫"EMPTY_APP"是不是也可以呢?那么就冲突了;
- 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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 Report
@@ 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all seems good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM . for zhengyangyong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. 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