common/src/main/java/bio/terra/cloudres/common/OperationAnnotator.java
/**
   * Logs the information captured in {@link OperationData} indicating the completion of a CRL event
   * or that an exception occurred.
   *
   * <p>A structured JsonObject is included in the logging arguments; this payload will not affect
   * human-readable logging output, but will be included in JSON-formatted output for services which
   * are using the terra-common-lib logging library with JSON format enabled.
   *
   * <p>If an exception is present, it will also be included as a logging argument. SLF4J should
   * recognize this argument and include a stacktrace in the resulting error log message.
   *
   * @param operationData the {@link OperationData} associated with a cloud operation.
   */
Logs the information captured in  OperationData indicating the completion of a CRL event
or that an exception occurred.

A structured JsonObject is included in the logging arguments; this payload will not affect
human-readable logging output, but will be included in JSON-formatted output for services which
are using the terra-common-lib logging library with JSON format enabled.

If an exception is present, it will also be included as a logging argument. SLF4J should
recognize this argument and include a stacktrace in the resulting error log message.

@param operationData the  OperationData associated with a cloud operation.
Logs the information captured in OperationData indicating the completion of a CRL event or that an exception occurred . A structured JsonObject is included in the logging arguments ; this payload will not affect human - readable logging output but will be included in JSON - formatted output for services which are using the terra - common - lib logging library with JSON format enabled . If an exception is present it will also be included as a logging argument . SLF4J should recognize this argument and include a stacktrace in the resulting error log message . @param operationData the OperationData associated with a cloud operation .
@VisibleForTesting
  void logEvent(OperationData operationData) {
    JsonObject logData = new JsonObject();
    logData.addProperty("clientName", clientConfig.getClientName());
    logData.addProperty("durationMs", operationData.duration().toMillis());
    operationData.httpStatusCode().ifPresent(s -> logData.addProperty("httpStatusCode", s));
    operationData.tryCount().ifPresent(c -> logData.addProperty("tryCount", c));
    operationData
        .executionException()
        .ifPresent(e -> logData.add("exception", createExceptionEntry(e)));
    logData.addProperty("operation", operationData.cloudOperation().name());
    logData.add("requestData", operationData.requestData());
    if (operationData.executionException().isPresent()) {
      logger.debug(
          String.format(
              "CRL exception in %s (HTTP code %s, %s)",
              operationData.cloudOperation().name(),
              operationData.httpStatusCode().orElse(-1),
              prettyPrintDuration(operationData.duration())),
          logData,
          operationData.executionException().get());
    } else {
      logger.debug(
          String.format(
              "CRL completed %s (%s)",
              operationData.cloudOperation().name(), prettyPrintDuration(operationData.duration())),
          logData);
    }
  }
@ VisibleForTesting void logEvent ( OperationData operationData ) { JsonObject logData = new JsonObject ( ) ; logData . addProperty ( "clientName" , clientConfig . getClientName ( ) ) ; logData . addProperty ( "durationMs" , operationData . duration ( ) . toMillis ( ) ) ; operationData . httpStatusCode ( ) . ifPresent ( s -> logData . addProperty ( "httpStatusCode" , s ) ) ; operationData . tryCount ( ) . ifPresent ( c -> logData . addProperty ( "tryCount" , c ) ) ; operationData . executionException ( ) . ifPresent ( e -> logData . add ( "exception" , createExceptionEntry ( e ) ) ) ; logData . addProperty ( "operation" , operationData . cloudOperation ( ) . name ( ) ) ; logData . add ( "requestData" , operationData . requestData ( ) ) ; if ( operationData . executionException ( ) . isPresent ( ) ) { logger . debug ( String . format ( "CRL exception in %s (HTTP code %s, %s)" , operationData . cloudOperation ( ) . name ( ) , operationData . httpStatusCode ( ) . orElse ( - 1 ) , prettyPrintDuration ( operationData . duration ( ) ) ) , logData , operationData . executionException ( ) . get ( ) ) ; } else { logger . debug ( String . format ( "CRL completed %s (%s)" , operationData . cloudOperation ( ) . name ( ) , prettyPrintDuration ( operationData . duration ( ) ) ) , logData ) ; } }
Logs the information captured in {@link OperationData} indicating the completion of a CRL event
 or that an exception occurred.
Logs the information captured in { @link OperationData } indicating the completion of a CRL event or that an exception occurred .
// Include logData for terra-common-lib logging to pick up and include in JSON output. // Include the exception, which slf4j will append to the formatted log message. // Include logData for terra-common-lib logging to pick up and include in JSON output.