-
Notifications
You must be signed in to change notification settings - Fork 119
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
Record metrics when INIT revision or an old revision is used #874
Conversation
Motivation: Before we apply line#681 that removes old commits, it would be nice if we can find any usages that access data with the INIT Revision or revisions that are more than 5000 (default minimum number of commit retentions) commits ahead from the head. Modifications: - Add a counter that is incresed when INIT Revision or revisions that are more than 5000 ahead from the head are used. Result: - Track the number of usages. - This commit will be reverted after we find the usage and fix it.
ServiceRequestContext ctx, String projectName, String repoName, | ||
Revision normalized, Revision head) { | ||
if (normalized.major() == 1 || head.major() - normalized.major() >= 5000) { | ||
ctx.log().whenComplete().thenAccept(log -> { |
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.
Question) Do we want to differentiate between cases using 1
vs. >5000
?
Imagining that the counter goes up, I wonder if we want to know which case needs handling.
Nevermind, I realized you added the revision as a 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.
Left some minor comments, but basically looks good 👍
Tag.of("repo", repoName), | ||
Tag.of("service", firstNonNull(log.serviceName(), "none")), | ||
Tag.of("method", log.name()), | ||
Tag.of("normalized", Integer.toString(normalized.major())), |
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.
Instead of adding a tag which can increase cardinality, what do you think of just adding a distribution?
i.e. If there is a repo with head version 1M, this is the possible cardinality worse case.
ctx.meterRegistry().summary("").record(head.major() - normalized.major());
ctx.meterRegistry().counter("", "init.major", String.valueOf(normalized.major() == 1)).increment();
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.
I have added the metric with the assumption that this will be short-lived and there will not be many requests that are caught by the condition.
However, there's no reason not to decrease the cardinality so let me use the distribution. Thanks!
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.
I have added the metric with the assumption that this will be short-lived and there will not be many requests that are caught by the condition.
I agree, but I also thought this code will also need to go to production env. to confirm our hypothesis 😄
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.
That is correct. 🤣
.../src/main/java/com/linecorp/centraldogma/server/internal/thrift/CentralDogmaServiceImpl.java
Outdated
Show resolved
Hide resolved
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #874 +/- ##
============================================
+ Coverage 65.69% 65.73% +0.04%
- Complexity 3350 3351 +1
============================================
Files 358 358
Lines 13893 13954 +61
Branches 1496 1502 +6
============================================
+ Hits 9127 9173 +46
- Misses 3914 3924 +10
- Partials 852 857 +5
☔ View full report in Codecov by Sentry. |
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.
Looks good to me 👍 Thanks @minwoox ! 🙇 👍 🚀
@@ -22,5 +22,7 @@ if (tasks.findByName('trimShadedJar')) { | |||
keep "class com.linecorp.centraldogma.internal.shaded.caffeine.** { *; }" | |||
// Prevent ProGuard from removing all enum values from Option because otherwise it becomes a non-enum class. | |||
keep "class com.linecorp.centraldogma.internal.shaded.jsonpath.Option { *; }" | |||
|
|||
dontnote |
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.
This reduces the verbosity of ProGuardTask when running in parallel.
The original comment: https://github.com/line/armeria/pull/2172/files#r332367951
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.
Please add a line comment about it.
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.
New changes still look good 👍
@@ -22,5 +22,7 @@ if (tasks.findByName('trimShadedJar')) { | |||
keep "class com.linecorp.centraldogma.internal.shaded.caffeine.** { *; }" | |||
// Prevent ProGuard from removing all enum values from Option because otherwise it becomes a non-enum class. | |||
keep "class com.linecorp.centraldogma.internal.shaded.jsonpath.Option { *; }" | |||
|
|||
dontnote |
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.
Please add a line comment about it.
if (normalized.major() == 1) { | ||
ctx.log().whenComplete().thenAccept( | ||
log -> ctx.meterRegistry() | ||
.counter("init.revisions", generateTags(projectName, repoName, log).build()) |
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.
revisions.init?
if (head.major() - normalized.major() >= 5000) { | ||
ctx.log().whenComplete().thenAccept( | ||
log -> ctx.meterRegistry() | ||
.summary("old.revisions", |
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.
revisions.old?
// Trigger old revision recording | ||
jsonNodeWatchRequest.start(Revision.INIT).join(); | ||
content = dogma.httpClient().get("/monitor/metrics").aggregate().join().contentUtf8(); | ||
assertThat(content).contains("init_revisions"); |
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.
Can we also add a similar test for old_revisions
? Should check if the meters with init=true
and init=false
both exists.
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 addressed. PTAL. 😉
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.
Thanks, @minwoox
} | ||
|
||
public static void increaseCounterIfOldRevisionUsed( | ||
ServiceRequestContext ctx, String projectName, String repoName, |
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.
nit: It may be simpler.
ServiceRequestContext ctx, String projectName, String repoName, | |
ServiceRequestContext ctx, Repository repository, |
ServiceRequestContext ctx, String projectName, String repoName, | ||
Revision normalized, Revision head) { | ||
if (normalized.major() == 1) { | ||
ctx.log().whenComplete().thenAccept( |
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.
nit: ctx.log.whenRequestComplete()
could be used instead since RequestLogProperty.NAME
is a request property. But I'm okay with the current implementation for simplicity.
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.
Thanks! All addressed. 😉
Thanks for reviewing. 😉 |
Motivation:
Before we apply #681 that removes old commits, it would be nice if we could find any usages that access data with the INIT Revision or revisions that are more than 5000 (default minimum number of commit retentions) commits ahead from the head.
Modifications:
Result: