docs: private ApiCallMonitoringEvent generateApiCallMonitoringEvent(Request<?> request) {
          String apiName = request.getHandlerContext(HandlerContextKey.OPERATION_NAME);
          String serviceId = request.getHandlerContext(HandlerContextKey.SERVICE_ID);
          String region = request.getHandlerContext(HandlerContextKey.SIGNING_REGION);
          ApiCallAttemptMonitoringEvent lastApiCallAttempt = request.getHandlerContext(LAST_CALL_ATTEMPT);
  
          Long timestamp = null;
          Long latency = null;
          Integer requestCount = 0;
          AWSRequestMetrics metrics = request.getAWSRequestMetrics();
  
          if (metrics != null) {
              TimingInfo timingInfo = metrics.getTimingInfo();
              requestCount = timingInfo.getCounter(AWSRequestMetrics.Field.RequestCount.name()) == null ? 0 :
                             timingInfo.getCounter(AWSRequestMetrics.Field.RequestCount.name()).intValue();
  
              TimingInfo latencyTimingInfo = timingInfo.getSubMeasurement(AwsClientSideMonitoringMetrics.ApiCallLatency.name());
              if (latencyTimingInfo != null) {
                  latency = convertToLongIfNotNull(latencyTimingInfo.getTimeTakenMillisIfKnown());
                  timestamp = latencyTimingInfo.getStartEpochTimeMilliIfKnown();
              }
          }
  
          ApiCallMonitoringEvent event = new ApiCallMonitoringEvent()
                  .withApi(apiName)
                  .withVersion(VERSION)
                  .withRegion(region)
                  .withService(serviceId)
                  .withClientId(clientId)
                  .withAttemptCount(requestCount)
                  .withLatency(latency)
                  .withUserAgent(trimValueIfExceedsMaxLength(USER_AGENT_KEY, getDefaultUserAgent(request)))
                  .withTimestamp(timestamp);
  
          if (lastApiCallAttempt != null) {
              event.withFinalAwsException(lastApiCallAttempt.getAwsException())
                   .withFinalAwsExceptionMessage(lastApiCallAttempt.getAwsExceptionMessage())
                   .withFinalSdkException(lastApiCallAttempt.getSdkException())
                   .withFinalSdkExceptionMessage(lastApiCallAttempt.getSdkExceptionMessage())
                   .withFinalHttpStatusCode(lastApiCallAttempt.getHttpStatusCode());
          }
  
          return event;
      }