Simplify deletion reason reporting
This commit is contained in:
		
							parent
							
								
									2881c0fd7e
								
							
						
					
					
						commit
						ae57853ec4
					
				|  | @ -4,20 +4,17 @@ | ||||||
|  */ |  */ | ||||||
| package org.whispersystems.textsecuregcm.storage; | package org.whispersystems.textsecuregcm.storage; | ||||||
| 
 | 
 | ||||||
| import com.google.common.annotations.VisibleForTesting; | import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name; | ||||||
|  | 
 | ||||||
|  | import io.micrometer.core.instrument.Metrics; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Optional; | import java.util.Optional; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||||
| import io.micrometer.core.instrument.Metrics; |  | ||||||
| import io.micrometer.core.instrument.Tag; |  | ||||||
| import io.micrometer.core.instrument.Tags; |  | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
| import org.whispersystems.textsecuregcm.util.Util; | import org.whispersystems.textsecuregcm.util.Util; | ||||||
| 
 | 
 | ||||||
| import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name; |  | ||||||
| 
 |  | ||||||
| public class AccountCleaner extends AccountDatabaseCrawlerListener { | public class AccountCleaner extends AccountDatabaseCrawlerListener { | ||||||
| 
 | 
 | ||||||
|   private static final Logger log = LoggerFactory.getLogger(AccountCleaner.class); |   private static final Logger log = LoggerFactory.getLogger(AccountCleaner.class); | ||||||
|  | @ -43,17 +40,11 @@ public class AccountCleaner extends AccountDatabaseCrawlerListener { | ||||||
|   protected void onCrawlChunk(Optional<UUID> fromUuid, List<Account> chunkAccounts) { |   protected void onCrawlChunk(Optional<UUID> fromUuid, List<Account> chunkAccounts) { | ||||||
|     for (Account account : chunkAccounts) { |     for (Account account : chunkAccounts) { | ||||||
|       if (isExpired(account) || needsExplicitRemoval(account)) { |       if (isExpired(account) || needsExplicitRemoval(account)) { | ||||||
|         final Tag deletionReason; |         final String deletionReason = needsExplicitRemoval(account) ? "newlyExpired" : "previouslyExpired"; | ||||||
| 
 |  | ||||||
|         if (needsExplicitRemoval(account)) { |  | ||||||
|           deletionReason = Tag.of(DELETION_REASON_TAG_NAME, "newlyExpired"); |  | ||||||
|         } else { |  | ||||||
|           deletionReason = Tag.of(DELETION_REASON_TAG_NAME, "previouslyExpired"); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|           accountsManager.delete(account, AccountsManager.DeletionReason.EXPIRED); |           accountsManager.delete(account, AccountsManager.DeletionReason.EXPIRED); | ||||||
|           Metrics.counter(DELETED_ACCOUNT_COUNTER_NAME, Tags.of(deletionReason)).increment(); |           Metrics.counter(DELETED_ACCOUNT_COUNTER_NAME, DELETION_REASON_TAG_NAME, deletionReason).increment(); | ||||||
|         } catch (final Exception e) { |         } catch (final Exception e) { | ||||||
|           log.warn("Failed to delete account {}", account.getUuid(), e); |           log.warn("Failed to delete account {}", account.getUuid(), e); | ||||||
|         } |         } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Jon Chambers
						Jon Chambers