diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index 08b26a43db..829cbec961 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -1035,6 +1035,8 @@ private Map preloadProperties(AtlasVertex entityVertex) { private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex, Set attributes) throws AtlasBaseException { AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("mapVertexToAtlasEntityHeader"); + AtlasPerfMetrics.MetricRecorder attributeProcessingRecorder = null; + boolean metricEnded = false; AtlasEntityHeader ret = new AtlasEntityHeader(); try { //pre-fetching the properties @@ -1098,6 +1100,7 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex, //attributes = only the attributes of entityType if (CollectionUtils.isNotEmpty(attributes)) { + attributeProcessingRecorder = RequestContext.get().startMetricRecord("attributeProcessingTime"); for (String attrName : attributes) { AtlasAttribute attribute = entityType.getAttribute(attrName); @@ -1120,11 +1123,17 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex, if (attrValue != null) { ret.setAttribute(attrName, attrValue); } + } + RequestContext.get().endMetricRecord(attributeProcessingRecorder); + metricEnded = true; } } } finally { + if (!metricEnded) { + RequestContext.get().endMetricRecord(attributeProcessingRecorder); + } RequestContext.get().endMetricRecord(metricRecorder); } return ret;