Fixup invalid accept-language counter
- Fix name - Add platform/version tags to the counter
This commit is contained in:
parent
9f5d97e1c6
commit
31e2be2e4d
|
@ -47,6 +47,7 @@ import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import io.micrometer.core.instrument.Counter;
|
import io.micrometer.core.instrument.Counter;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
|
import io.micrometer.core.instrument.Tags;
|
||||||
import org.apache.commons.codec.DecoderException;
|
import org.apache.commons.codec.DecoderException;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.codec.binary.Hex;
|
import org.apache.commons.codec.binary.Hex;
|
||||||
|
@ -77,6 +78,7 @@ import org.whispersystems.textsecuregcm.entities.BaseProfileResponse;
|
||||||
import org.whispersystems.textsecuregcm.entities.UserCapabilities;
|
import org.whispersystems.textsecuregcm.entities.UserCapabilities;
|
||||||
import org.whispersystems.textsecuregcm.entities.VersionedProfileResponse;
|
import org.whispersystems.textsecuregcm.entities.VersionedProfileResponse;
|
||||||
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
||||||
|
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
|
||||||
import org.whispersystems.textsecuregcm.s3.PolicySigner;
|
import org.whispersystems.textsecuregcm.s3.PolicySigner;
|
||||||
import org.whispersystems.textsecuregcm.s3.PostPolicyGenerator;
|
import org.whispersystems.textsecuregcm.s3.PostPolicyGenerator;
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
|
@ -116,7 +118,7 @@ public class ProfileController {
|
||||||
private static final String PNI_CREDENTIAL_TYPE = "pni";
|
private static final String PNI_CREDENTIAL_TYPE = "pni";
|
||||||
|
|
||||||
private static final Counter VERSION_NOT_FOUND_COUNTER = Metrics.counter(name(ProfileController.class, "versionNotFound"));
|
private static final Counter VERSION_NOT_FOUND_COUNTER = Metrics.counter(name(ProfileController.class, "versionNotFound"));
|
||||||
private static final Counter INVALID_ACCEPT_LANGUAGE_COUNTER = Metrics.counter(name(ProfileController.class, "invalidAcceptLanguageCounter"));
|
private static final String INVALID_ACCEPT_LANGUAGE_COUNTER_NAME = name(ProfileController.class, "invalidAcceptLanguage");
|
||||||
|
|
||||||
public ProfileController(
|
public ProfileController(
|
||||||
Clock clock,
|
Clock clock,
|
||||||
|
@ -438,10 +440,11 @@ public class ProfileController {
|
||||||
try {
|
try {
|
||||||
return containerRequestContext.getAcceptableLanguages();
|
return containerRequestContext.getAcceptableLanguages();
|
||||||
} catch (final ProcessingException e) {
|
} catch (final ProcessingException e) {
|
||||||
INVALID_ACCEPT_LANGUAGE_COUNTER.increment();
|
final String userAgent = containerRequestContext.getHeaderString(HttpHeaders.USER_AGENT);
|
||||||
|
Metrics.counter(INVALID_ACCEPT_LANGUAGE_COUNTER_NAME, Tags.of(UserAgentTagUtil.getPlatformTag(userAgent))).increment();
|
||||||
logger.debug("Could not get acceptable languages; Accept-Language: {}; User-Agent: {}",
|
logger.debug("Could not get acceptable languages; Accept-Language: {}; User-Agent: {}",
|
||||||
containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE),
|
containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE),
|
||||||
containerRequestContext.getHeaderString(HttpHeaders.USER_AGENT),
|
userAgent,
|
||||||
e);
|
e);
|
||||||
|
|
||||||
return List.of();
|
return List.of();
|
||||||
|
|
|
@ -58,6 +58,7 @@ import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import io.micrometer.core.instrument.Counter;
|
import io.micrometer.core.instrument.Counter;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
|
import io.micrometer.core.instrument.Tags;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.signal.zkgroup.InvalidInputException;
|
import org.signal.zkgroup.InvalidInputException;
|
||||||
import org.signal.zkgroup.VerificationFailedException;
|
import org.signal.zkgroup.VerificationFailedException;
|
||||||
|
@ -74,6 +75,7 @@ import org.whispersystems.textsecuregcm.configuration.SubscriptionConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.SubscriptionLevelConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.SubscriptionLevelConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.SubscriptionPriceConfiguration;
|
import org.whispersystems.textsecuregcm.configuration.SubscriptionPriceConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.entities.Badge;
|
import org.whispersystems.textsecuregcm.entities.Badge;
|
||||||
|
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
|
||||||
import org.whispersystems.textsecuregcm.storage.IssuedReceiptsManager;
|
import org.whispersystems.textsecuregcm.storage.IssuedReceiptsManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.SubscriptionManager;
|
import org.whispersystems.textsecuregcm.storage.SubscriptionManager;
|
||||||
import org.whispersystems.textsecuregcm.storage.SubscriptionManager.GetResult;
|
import org.whispersystems.textsecuregcm.storage.SubscriptionManager.GetResult;
|
||||||
|
@ -97,7 +99,7 @@ public class SubscriptionController {
|
||||||
private final BadgeTranslator badgeTranslator;
|
private final BadgeTranslator badgeTranslator;
|
||||||
private final LevelTranslator levelTranslator;
|
private final LevelTranslator levelTranslator;
|
||||||
|
|
||||||
private static final Counter INVALID_ACCEPT_LANGUAGE_COUNTER = Metrics.counter(name(SubscriptionController.class, "invalidAcceptLanguageCounter"));
|
private static final String INVALID_ACCEPT_LANGUAGE_COUNTER_NAME = name(SubscriptionController.class, "invalidAcceptLanguage");
|
||||||
|
|
||||||
public SubscriptionController(
|
public SubscriptionController(
|
||||||
@Nonnull Clock clock,
|
@Nonnull Clock clock,
|
||||||
|
@ -865,10 +867,11 @@ public class SubscriptionController {
|
||||||
try {
|
try {
|
||||||
return containerRequestContext.getAcceptableLanguages();
|
return containerRequestContext.getAcceptableLanguages();
|
||||||
} catch (final ProcessingException e) {
|
} catch (final ProcessingException e) {
|
||||||
INVALID_ACCEPT_LANGUAGE_COUNTER.increment();
|
final String userAgent = containerRequestContext.getHeaderString(HttpHeaders.USER_AGENT);
|
||||||
|
Metrics.counter(INVALID_ACCEPT_LANGUAGE_COUNTER_NAME, Tags.of(UserAgentTagUtil.getPlatformTag(userAgent))).increment();
|
||||||
logger.debug("Could not get acceptable languages; Accept-Language: {}; User-Agent: {}",
|
logger.debug("Could not get acceptable languages; Accept-Language: {}; User-Agent: {}",
|
||||||
containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE),
|
containerRequestContext.getHeaderString(HttpHeaders.ACCEPT_LANGUAGE),
|
||||||
containerRequestContext.getHeaderString(HttpHeaders.USER_AGENT),
|
userAgent,
|
||||||
e);
|
e);
|
||||||
|
|
||||||
return List.of();
|
return List.of();
|
||||||
|
|
Loading…
Reference in New Issue