diff options
author | 2018-07-29 16:13:45 +0300 | |
---|---|---|
committer | 2018-07-29 16:20:34 +0300 | |
commit | 5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch) | |
tree | 2f9dfc45191e723da69cf74be7829784e9741b94 /common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java | |
parent | 9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff) |
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5
Issue-ID: SDC-1566
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java')
-rw-r--r-- | common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java b/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java deleted file mode 100644 index 76262e7815..0000000000 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/ecomplog/Stopwatch.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.openecomp.sdc.common.ecomplog; - -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME; -import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP; - -import java.time.Clock; -import java.time.Duration; -import java.time.LocalDateTime; - -import org.openecomp.sdc.common.ecomplog.api.IStopWatch; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; - -/** - * Created by dd4296 on 12/13/2017. - * this is local implementation of the stopwatch class from EELF standard with the same interface - * can be replaced if needed with EELF lib - */ -public class Stopwatch implements IStopWatch { - - private static Logger log = LoggerFactory.getLogger(Stopwatch.class.getName()); - - public Stopwatch() { - } - - public void start() { - if (MDC.get(MDC_BEGIN_TIMESTAMP) == null || MDC.get(MDC_BEGIN_TIMESTAMP).trim().length() == 0) - MDC.put(MDC_BEGIN_TIMESTAMP, generatedTimeNow()); - } - - public void stop() { - if (MDC.get(MDC_BEGIN_TIMESTAMP) == null) { - log.error("call to stop without calling start first, this is not compliant with EELF format"); - } - MDC.put(MDC_END_TIMESTAMP, generatedTimeNow()); - setElapsedTime(); - } - - private void setElapsedTime() { - - try { - - final LocalDateTime startTime = LocalDateTime.parse(MDC.get(MDC_BEGIN_TIMESTAMP)); - final LocalDateTime endTime = LocalDateTime.parse(MDC.get(MDC_END_TIMESTAMP)); - - final Duration timeDifference = Duration.between(startTime, endTime); - - MDC.put(MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); - - } catch(Exception ex) { - log.error("failed to calculate elapsed time",ex); - } - } - - private String generatedTimeNow() { - return String.valueOf(LocalDateTime.now(Clock.systemUTC())); - } - -}
\ No newline at end of file |