from instance 'stats_this_second' and instance 'stats_next_second', compute some per
        second stats metrics and other aggregated metrics

        :param dict stats_this_second:
        :param dict stats_next_second:
        :return: compiled instance stats that has metrics

        {'opcounters_per_node_per_second': {...},
         'server_statistics_per_second': {...},
         'aggregate_server_statistics': {...},
         'replication_lag': 0.0,
         'aggregate_database_statistics': {}
         }

def _compile_new_relic_stats(self, stats_this_second, stats_next_second):
        """
        from instance 'stats_this_second' and instance 'stats_next_second', compute some per
        second stats metrics and other aggregated metrics

        :param dict stats_this_second:
        :param dict stats_next_second:
        :return: compiled instance stats that has metrics

        {'opcounters_per_node_per_second': {...},
         'server_statistics_per_second': {...},
         'aggregate_server_statistics': {...},
         'replication_lag': 0.0,
         'aggregate_database_statistics': {}
         }
        """
        server_statistics_per_second = {}
        opcounters_per_node_per_second = []
        for subdoc in ["opcounters", "network"]:
            first_doc = stats_this_second['aggregate_server_statistics'][subdoc]
            second_doc = stats_next_second['aggregate_server_statistics'][subdoc]
            keys = set(first_doc.keys()) | set(second_doc.keys())
            server_statistics_per_second[subdoc] = {key: int(second_doc[key]) - int(first_doc[key]) for key in keys if isinstance(first_doc[key], int)}
        for node1, node2 in zip(stats_this_second['opcounters_per_node'], stats_next_second['opcounters_per_node']):
            node_opcounters_per_second = {}
            for repl, members in node2.items():
                node_opcounters_per_second[repl] = {}
                for member, ops in members.items():
                    node_opcounters_per_second[repl][member] = {}
                    for op, count in ops.items():
                        node_opcounters_per_second[repl][member][op] = count - node1[repl][member][op]
            opcounters_per_node_per_second.append(node_opcounters_per_second)

        return {'opcounters_per_node_per_second': opcounters_per_node_per_second,
                'server_statistics_per_second': server_statistics_per_second,
                'aggregate_server_statistics': stats_next_second.get('aggregate_server_statistics'),
                'replication_lag': stats_next_second.get('replication_lag'),
                'aggregate_database_statistics': self.get_aggregate_database_stats()}