-
Notifications
You must be signed in to change notification settings - Fork 224
Exitpoint Stage #3564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Exitpoint Stage #3564
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
67b7703
Add Exitpoint Stage
AntoxaAntoxic fdbb724
Add Exitpoint Stage
AntoxaAntoxic 47314eb
Add tests
AntoxaAntoxic 3cb0342
Some fixes
AntoxaAntoxic 8346d4f
Some fixes
AntoxaAntoxic 3de7a14
Refactoring and Tests
AntoxaAntoxic f251be0
Code Style
AntoxaAntoxic 7903175
Package Renaming
AntoxaAntoxic dc80e05
Fix comments
AntoxaAntoxic 5bc9a91
Merge remote-tracking branch 'origin/master' into exitpoint-stage
CTMBNara 4fa3dbe
Merge remote-tracking branch 'origin/master' into exitpoint-stage
CTMBNara ca64df6
Fix merge issues.
CTMBNara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
81 changes: 81 additions & 0 deletions
81
src/main/java/org/prebid/server/auction/HooksMetricsService.java
This file contains hidden or 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,81 @@ | ||
| package org.prebid.server.auction; | ||
|
|
||
| import org.prebid.server.auction.model.AuctionContext; | ||
| import org.prebid.server.hooks.execution.model.ExecutionAction; | ||
| import org.prebid.server.hooks.execution.model.ExecutionStatus; | ||
| import org.prebid.server.hooks.execution.model.GroupExecutionOutcome; | ||
| import org.prebid.server.hooks.execution.model.HookExecutionOutcome; | ||
| import org.prebid.server.hooks.execution.model.HookId; | ||
| import org.prebid.server.hooks.execution.model.Stage; | ||
| import org.prebid.server.hooks.execution.model.StageExecutionOutcome; | ||
| import org.prebid.server.metric.Metrics; | ||
| import org.prebid.server.settings.model.Account; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.EnumMap; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class HooksMetricsService { | ||
|
|
||
| private final Metrics metrics; | ||
|
|
||
| public HooksMetricsService(Metrics metrics) { | ||
| this.metrics = Objects.requireNonNull(metrics); | ||
| } | ||
|
|
||
| public AuctionContext updateHooksMetrics(AuctionContext context) { | ||
| final EnumMap<Stage, List<StageExecutionOutcome>> stageOutcomes = | ||
| context.getHookExecutionContext().getStageOutcomes(); | ||
|
|
||
| final Account account = context.getAccount(); | ||
|
|
||
| stageOutcomes.forEach((stage, outcomes) -> updateHooksStageMetrics(account, stage, outcomes)); | ||
|
|
||
| // account might be null if request is rejected by the entrypoint hook | ||
| if (account != null) { | ||
| stageOutcomes.values().stream() | ||
| .flatMap(Collection::stream) | ||
| .map(StageExecutionOutcome::getGroups) | ||
| .flatMap(Collection::stream) | ||
| .map(GroupExecutionOutcome::getHooks) | ||
| .flatMap(Collection::stream) | ||
| .filter(hookOutcome -> hookOutcome.getAction() != ExecutionAction.no_invocation) | ||
| .collect(Collectors.groupingBy( | ||
| outcome -> outcome.getHookId().getModuleCode(), | ||
| Collectors.summingLong(HookExecutionOutcome::getExecutionTime))) | ||
| .forEach((moduleCode, executionTime) -> | ||
| metrics.updateAccountModuleDurationMetric(account, moduleCode, executionTime)); | ||
| } | ||
|
|
||
| return context; | ||
| } | ||
|
|
||
| private void updateHooksStageMetrics(Account account, Stage stage, List<StageExecutionOutcome> stageOutcomes) { | ||
| stageOutcomes.stream() | ||
| .flatMap(stageOutcome -> stageOutcome.getGroups().stream()) | ||
| .flatMap(groupOutcome -> groupOutcome.getHooks().stream()) | ||
| .forEach(hookOutcome -> updateHookInvocationMetrics(account, stage, hookOutcome)); | ||
| } | ||
|
|
||
| private void updateHookInvocationMetrics(Account account, Stage stage, HookExecutionOutcome hookOutcome) { | ||
| final HookId hookId = hookOutcome.getHookId(); | ||
| final ExecutionStatus status = hookOutcome.getStatus(); | ||
| final ExecutionAction action = hookOutcome.getAction(); | ||
| final String moduleCode = hookId.getModuleCode(); | ||
|
|
||
| metrics.updateHooksMetrics( | ||
| moduleCode, | ||
| stage, | ||
| hookId.getHookImplCode(), | ||
| status, | ||
| hookOutcome.getExecutionTime(), | ||
| action); | ||
|
|
||
| // account might be null if request is rejected by the entrypoint hook | ||
| if (account != null) { | ||
| metrics.updateAccountHooksMetrics(account, moduleCode, status, action); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.