Class UserAgentConfigurator

java.lang.Object
software.amazon.lambda.powertools.common.internal.UserAgentConfigurator

public final class UserAgentConfigurator extends Object
Can be used to create a string that can server as a User-Agent suffix in requests made with the AWS SDK clients
  • Field Details

  • Method Details

    • configureUserAgent

      public static void configureUserAgent(String ptFeature)
      Configures the AWS SDK to use Powertools user agent by setting the sdk.ua.appId system property. Preserves any user-provided value and replaces any existing Powertools user agent. Enforces a 50 character limit to comply with AWS SDK recommendations. This should be called during library initialization to ensure the user agent is properly configured.
    • getUserAgent

      public static String getUserAgent(String ptFeature)
      Retrieves the user agent string for the Powertools for AWS Lambda. It follows the pattern PT/{PT_FEATURE}/{PT_VERSION} PTENV/{PT_EXEC_ENV} The version of the project is automatically retrieved. The PT_EXEC_ENV is automatically retrieved from the AWS_EXECUTION_ENV environment variable. If it AWS_EXECUTION_ENV is not set, PT_EXEC_ENV defaults to "NA"
      Parameters:
      ptFeature - a custom feature to be added to the user agent string (e.g. idempotency). If null or empty, the default PT_FEATURE is used. The default PT_FEATURE is "no-op".
      Returns:
      the user agent string