Record error metrics from Twilio Verify
This commit is contained in:
parent
aeb9f67266
commit
8a8a848fac
|
@ -55,9 +55,10 @@ public class TwilioSmsSender {
|
||||||
private final Meter voxMeter = metricRegistry.meter(name(getClass(), "vox", "delivered"));
|
private final Meter voxMeter = metricRegistry.meter(name(getClass(), "vox", "delivered"));
|
||||||
private final Meter priceMeter = metricRegistry.meter(name(getClass(), "price"));
|
private final Meter priceMeter = metricRegistry.meter(name(getClass(), "price"));
|
||||||
|
|
||||||
private static final String FAILED_REQUEST_COUNTER_NAME = name(TwilioSmsSender.class, "failedRequest");
|
static final String FAILED_REQUEST_COUNTER_NAME = name(TwilioSmsSender.class, "failedRequest");
|
||||||
private static final String STATUS_CODE_TAG_NAME = "statusCode";
|
static final String SERVICE_NAME_TAG = "service";
|
||||||
private static final String ERROR_CODE_TAG_NAME = "errorCode";
|
static final String STATUS_CODE_TAG_NAME = "statusCode";
|
||||||
|
static final String ERROR_CODE_TAG_NAME = "errorCode";
|
||||||
|
|
||||||
private final String accountId;
|
private final String accountId;
|
||||||
private final String accountToken;
|
private final String accountToken;
|
||||||
|
@ -206,7 +207,12 @@ public class TwilioSmsSender {
|
||||||
return true;
|
return true;
|
||||||
} else if (response != null && response.isFailure()) {
|
} else if (response != null && response.isFailure()) {
|
||||||
logger.debug("Twilio request failed: " + response.failureResponse.status + "(code " + response.failureResponse.code + "), " + response.failureResponse.message);
|
logger.debug("Twilio request failed: " + response.failureResponse.status + "(code " + response.failureResponse.code + "), " + response.failureResponse.message);
|
||||||
Metrics.counter(FAILED_REQUEST_COUNTER_NAME, STATUS_CODE_TAG_NAME, String.valueOf(response.failureResponse.status), ERROR_CODE_TAG_NAME, String.valueOf(response.failureResponse.code)).increment();
|
|
||||||
|
Metrics.counter(FAILED_REQUEST_COUNTER_NAME,
|
||||||
|
SERVICE_NAME_TAG, "classic",
|
||||||
|
STATUS_CODE_TAG_NAME, String.valueOf(response.failureResponse.status),
|
||||||
|
ERROR_CODE_TAG_NAME, String.valueOf(response.failureResponse.code)).increment();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else if (throwable != null) {
|
} else if (throwable != null) {
|
||||||
logger.info("Twilio request failed", throwable);
|
logger.info("Twilio request failed", throwable);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import io.micrometer.core.instrument.Metrics;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.textsecuregcm.configuration.TwilioConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.TwilioConfiguration;
|
||||||
|
@ -137,10 +138,16 @@ class TwilioVerifySender {
|
||||||
private Optional<String> extractVerifySid(TwilioVerifyResponse twilioVerifyResponse, Throwable throwable) {
|
private Optional<String> extractVerifySid(TwilioVerifyResponse twilioVerifyResponse, Throwable throwable) {
|
||||||
|
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
|
logger.warn("Failed to send Twilio request", throwable);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (twilioVerifyResponse.isFailure()) {
|
if (twilioVerifyResponse.isFailure()) {
|
||||||
|
Metrics.counter(TwilioSmsSender.FAILED_REQUEST_COUNTER_NAME,
|
||||||
|
TwilioSmsSender.SERVICE_NAME_TAG, "verify",
|
||||||
|
TwilioSmsSender.STATUS_CODE_TAG_NAME, String.valueOf(twilioVerifyResponse.failureResponse.status),
|
||||||
|
TwilioSmsSender.ERROR_CODE_TAG_NAME, String.valueOf(twilioVerifyResponse.failureResponse.code)).increment();
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue