Skip to content

Commit b600652

Browse files
committed
Refactor challenge request metrics to include difficulty parameter
1 parent 28b8dd5 commit b600652

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

captchaservice-backend/src/main/java/de/muenchen/captchaservice/service/captcha/CaptchaService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ public CaptchaService(final CaptchaProperties captchaProperties, final Difficult
3737

3838
public Altcha.Challenge createChallenge(final String siteKey, final SourceAddress sourceAddress) {
3939
final long difficulty = difficultyService.getDifficultyForSourceAddress(siteKey, sourceAddress);
40-
41-
metricsService.recordChallengeRequest(siteKey, sourceAddress);
42-
4340
difficultyService.registerRequest(siteKey, sourceAddress);
41+
metricsService.recordChallengeRequest(siteKey, sourceAddress, difficulty);
4442
final Altcha.ChallengeOptions options = new Altcha.ChallengeOptions();
4543
options.algorithm = Altcha.Algorithm.SHA256;
4644
options.hmacKey = captchaProperties.hmacKey();

captchaservice-backend/src/main/java/de/muenchen/captchaservice/service/captcha/MetricsService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public MetricsService(MeterRegistry meterRegistry, DifficultyService difficultyS
2929
this.invalidatedPayloadRepository = invalidatedPayloadRepository;
3030
}
3131

32-
public void recordChallengeRequest(String siteKey, SourceAddress sourceAddress) {
33-
final long difficulty = difficultyService.getDifficultyForSourceAddress(siteKey, sourceAddress);
34-
32+
public void recordChallengeRequest(String siteKey, SourceAddress sourceAddress, long difficulty) {
3533
Counter.builder("captcha.challenge.requests")
3634
.tag("site_key", siteKey)
3735
.tag("difficulty", String.valueOf(difficulty))

0 commit comments

Comments
 (0)