-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add account level metrics control (#1462)
- Loading branch information
Showing
14 changed files
with
227 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
src/main/java/org/prebid/server/metric/AccountMetricsVerbosity.java
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/main/java/org/prebid/server/metric/AccountMetricsVerbosityResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.prebid.server.metric; | ||
|
||
import org.prebid.server.metric.model.AccountMetricsVerbosityLevel; | ||
import org.prebid.server.settings.model.Account; | ||
import org.prebid.server.settings.model.AccountMetricsConfig; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class AccountMetricsVerbosityResolver { | ||
|
||
private final AccountMetricsVerbosityLevel defaultVerbosity; | ||
private final Map<String, AccountMetricsVerbosityLevel> accountVerbosityLevels; | ||
|
||
public AccountMetricsVerbosityResolver(AccountMetricsVerbosityLevel defaultVerbosity, | ||
List<String> basicVerbosity, | ||
List<String> detailedVerbosity) { | ||
|
||
this.defaultVerbosity = Objects.requireNonNull(defaultVerbosity); | ||
|
||
this.accountVerbosityLevels = new HashMap<>(); | ||
Objects.requireNonNull(basicVerbosity) | ||
.forEach(accountId -> accountVerbosityLevels.put(accountId, AccountMetricsVerbosityLevel.basic)); | ||
Objects.requireNonNull(detailedVerbosity) | ||
.forEach(accountId -> accountVerbosityLevels.put(accountId, AccountMetricsVerbosityLevel.detailed)); | ||
} | ||
|
||
public AccountMetricsVerbosityLevel forAccount(Account account) { | ||
final AccountMetricsConfig metricsConfig = account.getMetrics(); | ||
final AccountMetricsVerbosityLevel accountVerbosity = metricsConfig != null | ||
? metricsConfig.getVerbosityLevel() | ||
: null; | ||
return accountVerbosity != null | ||
? accountVerbosity | ||
: accountVerbosityLevels.getOrDefault(account.getId(), defaultVerbosity); | ||
} | ||
} |
Oops, something went wrong.