Skip to content

Commit 623d828

Browse files
authored
(#47) 대시보드 카운터 소수점 표시, timeseries No data, API cost 로깅 누락 수정
* 대시보드 카운터 소수점 수정, timeseries No data 수정, API cost 로깅 추가 - stat 패널 6개에 round() 적용하여 정수 표시 - timeseries 패널 $__interval → $__rate_interval 전환하여 No data 해결 - GitHubApiLoggingAspect에서 응답 객체의 cost, remaining 추출하여 로그에 포함 * 배치 stat 패널 4개에도 round() 적용
1 parent 525a866 commit 623d828

2 files changed

Lines changed: 45 additions & 22 deletions

File tree

dashboards/git-ranker-dashboard.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
"gridPos": { "h": 5, "w": 4, "x": 0, "y": 8 },
229229
"id": 10,
230230
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
231-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_registrations_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Registrations", "refId": "A" }],
231+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(user_registrations_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Registrations", "refId": "A" }],
232232
"title": "Registrations",
233233
"type": "stat"
234234
},
@@ -238,7 +238,7 @@
238238
"gridPos": { "h": 5, "w": 4, "x": 4, "y": 8 },
239239
"id": 11,
240240
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
241-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_logins_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Logins", "refId": "A" }],
241+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(user_logins_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Logins", "refId": "A" }],
242242
"title": "Logins",
243243
"type": "stat"
244244
},
@@ -248,7 +248,7 @@
248248
"gridPos": { "h": 5, "w": 4, "x": 8, "y": 8 },
249249
"id": 12,
250250
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
251-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(profile_views_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Profile Views", "refId": "A" }],
251+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(profile_views_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Profile Views", "refId": "A" }],
252252
"title": "Profile Views",
253253
"type": "stat"
254254
},
@@ -258,7 +258,7 @@
258258
"gridPos": { "h": 5, "w": 4, "x": 12, "y": 8 },
259259
"id": 13,
260260
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
261-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(badge_views_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Badge Views", "refId": "A" }],
261+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(badge_views_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Badge Views", "refId": "A" }],
262262
"title": "Badge Views",
263263
"type": "stat"
264264
},
@@ -268,7 +268,7 @@
268268
"gridPos": { "h": 5, "w": 4, "x": 16, "y": 8 },
269269
"id": 16,
270270
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
271-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_refreshes_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Refreshes", "refId": "A" }],
271+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(user_refreshes_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Refreshes", "refId": "A" }],
272272
"title": "Manual Refreshes",
273273
"type": "stat"
274274
},
@@ -278,7 +278,7 @@
278278
"gridPos": { "h": 5, "w": 4, "x": 20, "y": 8 },
279279
"id": 17,
280280
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
281-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_deletions_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Deletions", "refId": "A" }],
281+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(user_deletions_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Deletions", "refId": "A" }],
282282
"title": "Account Deletions",
283283
"type": "stat"
284284
},
@@ -299,10 +299,10 @@
299299
"tooltip": { "mode": "multi", "sort": "desc" }
300300
},
301301
"targets": [
302-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_registrations_total{application=\"git-ranker-api\"}[$__interval])", "legendFormat": "Registrations", "refId": "A" },
303-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_logins_total{application=\"git-ranker-api\"}[$__interval])", "legendFormat": "Logins", "refId": "B" },
304-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_refreshes_total{application=\"git-ranker-api\"}[$__interval])", "legendFormat": "Refreshes", "refId": "C" },
305-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_deletions_total{application=\"git-ranker-api\"}[$__interval])", "legendFormat": "Deletions", "refId": "D" }
302+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_registrations_total{application=\"git-ranker-api\"}[$__rate_interval])", "legendFormat": "Registrations", "refId": "A" },
303+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_logins_total{application=\"git-ranker-api\"}[$__rate_interval])", "legendFormat": "Logins", "refId": "B" },
304+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_refreshes_total{application=\"git-ranker-api\"}[$__rate_interval])", "legendFormat": "Refreshes", "refId": "C" },
305+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(user_deletions_total{application=\"git-ranker-api\"}[$__rate_interval])", "legendFormat": "Deletions", "refId": "D" }
306306
],
307307
"title": "User Activity Trend",
308308
"type": "timeseries"
@@ -324,8 +324,8 @@
324324
"tooltip": { "mode": "multi", "sort": "desc" }
325325
},
326326
"targets": [
327-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(profile_views_total{application=\"git-ranker-api\"}[$__interval])", "legendFormat": "Profile Views", "refId": "A" },
328-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(badge_views_total{application=\"git-ranker-api\"}[$__interval])", "legendFormat": "Badge Views", "refId": "B" }
327+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(profile_views_total{application=\"git-ranker-api\"}[$__rate_interval])", "legendFormat": "Profile Views", "refId": "A" },
328+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(badge_views_total{application=\"git-ranker-api\"}[$__rate_interval])", "legendFormat": "Badge Views", "refId": "B" }
329329
],
330330
"title": "Content Views",
331331
"type": "timeseries"
@@ -375,8 +375,8 @@
375375
"id": 31,
376376
"options": { "legend": { "calcs": ["sum"], "displayMode": "table", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } },
377377
"targets": [
378-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(github_api_calls_total{application=\"git-ranker-api\", result=\"success\"}[$__interval])", "legendFormat": "Success", "refId": "A" },
379-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(github_api_calls_total{application=\"git-ranker-api\", result=\"failure\"}[$__interval])", "legendFormat": "Failure", "refId": "B" }
378+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(github_api_calls_total{application=\"git-ranker-api\", result=\"success\"}[$__rate_interval])", "legendFormat": "Success", "refId": "A" },
379+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(github_api_calls_total{application=\"git-ranker-api\", result=\"failure\"}[$__rate_interval])", "legendFormat": "Failure", "refId": "B" }
380380
],
381381
"title": "API Call Volume",
382382
"type": "timeseries"
@@ -444,7 +444,7 @@
444444
"gridPos": { "h": 5, "w": 3, "x": 12, "y": 31 },
445445
"id": 41,
446446
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
447-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(batch_jobs_completed_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Completed", "refId": "A" }],
447+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(batch_jobs_completed_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Completed", "refId": "A" }],
448448
"title": "Jobs Completed",
449449
"type": "stat"
450450
},
@@ -454,7 +454,7 @@
454454
"gridPos": { "h": 5, "w": 3, "x": 15, "y": 31 },
455455
"id": 42,
456456
"options": { "colorMode": "value", "graphMode": "none", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "auto" },
457-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(batch_jobs_failed_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Failures", "refId": "A" }],
457+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(batch_jobs_failed_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Failures", "refId": "A" }],
458458
"title": "Jobs Failed",
459459
"type": "stat"
460460
},
@@ -477,8 +477,8 @@
477477
"id": 45,
478478
"options": { "colorMode": "value", "graphMode": "area", "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "textMode": "value_and_name" },
479479
"targets": [
480-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(batch_items_processed_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Processed", "refId": "A" },
481-
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "increase(batch_items_skipped_total{application=\"git-ranker-api\"}[$__range])", "legendFormat": "Skipped", "refId": "B" }
480+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(batch_items_processed_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Processed", "refId": "A" },
481+
{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "round(increase(batch_items_skipped_total{application=\"git-ranker-api\"}[$__range]))", "legendFormat": "Skipped", "refId": "B" }
482482
],
483483
"title": "Items",
484484
"type": "stat"
@@ -516,7 +516,7 @@
516516
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 42 },
517517
"id": 70,
518518
"options": { "legend": { "calcs": ["sum"], "displayMode": "table", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } },
519-
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "sum by (error_code) (increase(errors_total{application=\"git-ranker-api\"}[$__interval]))", "legendFormat": "{{error_code}}", "refId": "A" }],
519+
"targets": [{ "datasource": { "type": "prometheus", "uid": "${prometheus_ds}" }, "expr": "sum by (error_code) (increase(errors_total{application=\"git-ranker-api\"}[$__rate_interval]))", "legendFormat": "{{error_code}}", "refId": "A" }],
520520
"title": "Error by Code",
521521
"type": "timeseries"
522522
},

src/main/java/com/gitranker/api/global/aop/GitHubApiLoggingAspect.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.gitranker.api.global.logging.Event;
44
import com.gitranker.api.global.logging.LogContext;
55
import com.gitranker.api.infrastructure.github.GitHubApiMetrics;
6+
import com.gitranker.api.infrastructure.github.dto.GitHubAllActivitiesResponse;
7+
import com.gitranker.api.infrastructure.github.dto.GitHubRateLimitInfo;
8+
import com.gitranker.api.infrastructure.github.dto.GitHubUserInfoResponse;
69
import lombok.RequiredArgsConstructor;
710
import lombok.extern.slf4j.Slf4j;
811
import org.aspectj.lang.ProceedingJoinPoint;
@@ -31,11 +34,19 @@ public Object logGithubApiCall(ProceedingJoinPoint joinPoint) throws Throwable {
3134

3235
long latency = System.currentTimeMillis() - start;
3336

34-
LogContext.event(Event.GITHUB_API_CALLED)
37+
GitHubRateLimitInfo rateLimit = extractRateLimit(result);
38+
39+
LogContext ctx = LogContext.event(Event.GITHUB_API_CALLED)
3540
.with("method", methodName)
3641
.with("latency_ms", latency)
37-
.with("success", true)
38-
.info();
42+
.with("success", true);
43+
44+
if (rateLimit != null) {
45+
ctx.with("cost", rateLimit.cost())
46+
.with("remaining", rateLimit.remaining());
47+
}
48+
49+
ctx.info();
3950

4051
apiMetrics.recordSuccess(latency);
4152

@@ -55,4 +66,16 @@ public Object logGithubApiCall(ProceedingJoinPoint joinPoint) throws Throwable {
5566
throw e;
5667
}
5768
}
69+
70+
private GitHubRateLimitInfo extractRateLimit(Object result) {
71+
if (result instanceof GitHubAllActivitiesResponse r
72+
&& r.data() != null && r.data().rateLimit() != null) {
73+
return r.data().rateLimit();
74+
}
75+
if (result instanceof GitHubUserInfoResponse r
76+
&& r.data() != null && r.data().rateLimit() != null) {
77+
return r.data().rateLimit();
78+
}
79+
return null;
80+
}
5881
}

0 commit comments

Comments
 (0)