VOL-4009: Fix Missing metric elements of openonu-go-adapter pm-data

Change-Id: I648f77ce6d08361492fea61f8cad37010f7f3f7f
diff --git a/VERSION b/VERSION
index 776b55c..c803149 100755
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.3.0-dev196
+1.3.0-dev197
diff --git a/internal/pkg/onuadaptercore/onu_metrics_manager.go b/internal/pkg/onuadaptercore/onu_metrics_manager.go
index d149878..80882f6 100644
--- a/internal/pkg/onuadaptercore/onu_metrics_manager.go
+++ b/internal/pkg/onuadaptercore/onu_metrics_manager.go
@@ -1722,10 +1722,8 @@
 	if classID == me.EthernetFramePerformanceMonitoringHistoryDataUpstreamClassID {
 		upstream = true
 	}
-	// Make sure "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
-	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
-		requestedAttributes["IntervalEndTime"] = 0
-	}
+	// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
+	requestedAttributes["IntervalEndTime"] = 0
 	if meInstance := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan); meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
@@ -1818,10 +1816,8 @@
 // nolint: gocyclo
 func (mm *onuMetricsManager) populateEthernetUniHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, ethPMUniHistData map[string]float32, intervalEndTime *int) error {
-	// Make sure "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
-	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
-		requestedAttributes["IntervalEndTime"] = 0
-	}
+	// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
+	requestedAttributes["IntervalEndTime"] = 0
 	if meInstance := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan); meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
@@ -1914,10 +1910,8 @@
 // nolint: gocyclo
 func (mm *onuMetricsManager) populateFecHistoryMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, fecHistData map[string]float32, intervalEndTime *int) error {
-	// Make sure "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
-	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
-		requestedAttributes["IntervalEndTime"] = 0
-	}
+	// Insert "IntervalEndTime" as part of the requested attributes as we need this to compare the get responses when get request is multipart
+	requestedAttributes["IntervalEndTime"] = 0
 	if meInstance := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan); meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
@@ -1974,10 +1968,8 @@
 // nolint: gocyclo
 func (mm *onuMetricsManager) populateGemPortMetrics(ctx context.Context, classID me.ClassID, entityID uint16,
 	meAttributes me.AttributeValueMap, requestedAttributes me.AttributeValueMap, gemPortHistData map[string]float32, intervalEndTime *int) error {
-	// Make sure "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
-	if _, ok := requestedAttributes["IntervalEndTime"]; !ok {
-		requestedAttributes["IntervalEndTime"] = 0
-	}
+	// Insert "IntervalEndTime" is part of the requested attributes as we need this to compare the get responses when get request is multipart
+	requestedAttributes["IntervalEndTime"] = 0
 	if meInstance := mm.pDeviceHandler.pOnuOmciDevice.PDevOmciCC.sendGetMe(ctx, classID, entityID, requestedAttributes, mm.pDeviceHandler.pOpenOnuAc.omciTimeout, true, mm.pAdaptFsm.commChan); meInstance != nil {
 		select {
 		case meAttributes = <-mm.l2PmChan:
@@ -2152,6 +2144,12 @@
 	size := 0
 	requestedAttributes := make(me.AttributeValueMap)
 	for _, v := range mEnt.GetAttributeDefinitions() {
+		if v.Name == "ManagedEntityId" || v.Name == "IntervalEndTime" || v.Name == "ThresholdData12Id" {
+			// Exclude the ManagedEntityId , it will be inserted by omci library based on 'entityID' information
+			// Exclude IntervalEndTime. It will be inserted by the group PM populater function.
+			// Exclude ThresholdData12Id as that is of no particular relevance for metrics collection.
+			continue
+		}
 		if (v.Size + size) <= MaxL2PMGetPayLoadSize {
 			requestedAttributes[v.Name] = v.DefValue
 			size = v.Size + size
@@ -2162,17 +2160,16 @@
 					log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
 				return err
 			}
-			size = 0                                         // reset size
 			requestedAttributes = make(me.AttributeValueMap) // reset map
+			requestedAttributes[v.Name] = v.DefValue         // populate the metric that was missed in the current iteration
+			size = v.Size                                    // reset size
 		}
 	}
 	// Collect the omci get attributes for the last bunch of attributes.
-	if len(requestedAttributes) > 0 {
-		if err := grpFunc(ctx, classID, entityID, meAttributes, requestedAttributes, data, intervalEndTime); err != nil {
-			logger.Errorw(ctx, "error during metric collection",
-				log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
-			return err
-		}
+	if err := grpFunc(ctx, classID, entityID, meAttributes, requestedAttributes, data, intervalEndTime); err != nil {
+		logger.Errorw(ctx, "error during metric collection",
+			log.Fields{"device-id": mm.pDeviceHandler.deviceID, "entityID": entityID, "err": err})
+		return err
 	}
 	return nil
 }