Skip to content

Am I still able to intercept exceptions on retry to emit client side metrics? #2144

Closed
@kevinrobayna

Description

@kevinrobayna

Describe the issue

In v1 I was able to add a lambda to intercept exceptions in client and emit metrics if desired, I'm struggling to do the same with v2.

import com.amazonaws.retry.PredefinedRetryPolicies;
import com.amazonaws.retry.RetryPolicy;

  private RetryPolicy buildRetryPolicy() {
    return new RetryPolicy(
        (originalRequest, exception, retriesAttempted) -> {
          LOGGER.info("AWS failed with exception {}", exception.getClass());
          if (exception instanceof ProvisionedThroughputExceededException) {
            metrics.getCounter(PROVIDER_EXCEPTION,Map.of("exception", "ProvisionedThroughputExceededException")).inc();
          }
          return PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION.shouldRetry(
              originalRequest, exception, retriesAttempted);
        },
        PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY,
        PredefinedRetryPolicies.DEFAULT_MAX_ERROR_RETRY,
        false);
  }

Your Environment

  • AWS Java SDK version used: '2.15.26'
  • JDK version used: 11
  • Operating System and version: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    closing-soonThis issue will close in 4 days unless further comments are made.guidanceQuestion that needs advice or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions