private void setTargetAccountAndContainerInRestRequest(RestRequest restRequest, Account targetAccount,
      Container targetContainer, RestRequestMetricsGroup metricsGroup) {
    restRequest.setArg(InternalKeys.TARGET_ACCOUNT_KEY, targetAccount);
    restRequest.setArg(InternalKeys.TARGET_CONTAINER_KEY, targetContainer);
    logger.trace("Setting targetAccount={} and targetContainer={} for restRequest={} ", targetAccount, targetContainer,
        restRequest);
    if (metricsGroup != null) {
      if (!frontendConfig.containerMetricsExcludedAccounts.contains(targetAccount.getName())) {
        boolean shouldIncludeAccountMetrics =
            frontendConfig.containerMetricsAggregatedAccounts.contains(targetAccount.getName());
        restRequest.getMetricsTracker()
            .injectContainerMetrics(metricsGroup.getContainerMetrics(targetAccount.getName(), targetContainer.getName(),
                shouldIncludeAccountMetrics));
      }
    }
  }
Sets target {@link Account} and {@link Container} objects in the {@link RestRequest}. Also handles instantiation
and injection of {@link ContainerMetrics} instances.
@param restRequest The {@link RestRequest} to set.
@param targetAccount The target {@link Account} to set.
@param targetContainer The target {@link Container} to set.
@param metricsGroup The {@link RestRequestMetricsGroup} to use to set up {@link ContainerMetrics}, or {@code null}
                    if {@link ContainerMetrics} instantiation is not needed.
ambry-frontend/src/main/java/com/github/ambry/frontend/AccountAndContainerInjector.java