private static String expectedSeralizedSnapshot(Exception exception, boolean includeSamzaEpochId,
      boolean includeExtraHeaderField) {
    String stackTrace = ExceptionUtils.getStackTrace(exception);
    String serializedSnapshot =
        "{\"header\":[\"java.util.HashMap\",{\"job-id\":\"i001\",\"exec-env-container-id\":\"test container ID\",";
    if (includeSamzaEpochId) {
      serializedSnapshot += "\"samza-epoch-id\":\"epoch-123\",";
    }
    if (includeExtraHeaderField) {
      serializedSnapshot += "\"extra-header-field\":\"extra header value\",";
    }
    // in serialized string, backslash in whitespace characters (e.g. \n, \t) are escaped
    String escapedStackTrace = stackTrace.replace("\n", "\\n").replace("\t", "\\t");
    serializedSnapshot +=
        "\"samza-version\":\"1\",\"job-name\":\"jobName\",\"host\":\"1\",\"reset-time\":[\"java.lang.Long\",1],"
            + "\"container-name\":\"container 0\",\"source\":\"source\",\"time\":[\"java.lang.Long\",1],\"version\":\"300.14.25.1\"}],"
            + "\"metrics\":[\"java.util.HashMap\",{\"org.apache.samza.exceptions\":"
            + "[\"java.util.HashMap\",{\"exceptions\":[\"java.util.Collections$UnmodifiableRandomAccessList\","
            + "[[\"org.apache.samza.diagnostics.DiagnosticsExceptionEvent\",{\"timestamp\":1,\"exceptionType\":\"org.apache.samza.SamzaException\","
            + "\"exceptionMessage\":\"this is a samza exception\",\"compactExceptionStackTrace\":\"" + escapedStackTrace
            + "\",\"mdcMap\":[\"java.util.HashMap\",{}]}]]]}],\"org.apache.samza.container.SamzaContainerMetrics\":"
            + "[\"java.util.HashMap\",{\"commit-calls\":1}]}]}";
    return serializedSnapshot;
  }
@param includeSamzaEpochId include the new samza-epoch-id field (for testing that new code can read old data
                          without this field)
@param includeExtraHeaderField include an extra new field (for testing that old code can read new data with extra
                               fields)
samza-core/src/test/java/org/apache/samza/serializers/model/serializers/TestMetricsSnapshotSerdeV2.java