Exemple #1
0
 def get(self):
     logger.debug("top of GET /actors")
     actors = []
     for k, v in actors_store.items():
         if v['tenant'] == g.tenant:
             actor = Actor.from_db(v)
             if check_permissions(g.user, actor.db_id, READ):
                 actors.append(actor.display())
     logger.info("actors retrieved.")
     return ok(result=actors, msg="Actors retrieved successfully.")
Exemple #2
0
def main():
    logger.info("Running Metrics check.")
    actor_ids = [actor['db_id'] for actor in actors_store.items()]
    for actor_id in actor_ids:
        logger.debug("TOP OF CHECK METRICS")
        query = {
            'query':
            'message_count_for_actor_{}'.format(
                actor_id.decode("utf-8").replace('-', '_')),
            'time':
            datetime.datetime.utcnow().isoformat() + "Z"
        }
        r = requests.get(PROMETHEUS_URL + '/api/v1/query', params=query)
        logger.debug("METRICS QUERY: {}".format(r.text))
Exemple #3
0
 def get(self):
     logger.debug("top of GET /admin/actors")
     actors = []
     for k, v in actors_store.items():
         actor = Actor.from_db(v)
         actor.workers = Worker.get_workers(actor.db_id)
         for id, worker in actor.workers.items():
             actor.worker = worker
             break
         ch = ActorMsgChannel(actor_id=actor.db_id)
         actor.messages = len(ch._queue._queue)
         ch.close()
         summary = ExecutionsSummary(db_id=actor.db_id)
         actor.executions = summary.total_executions
         actor.runtime = summary.total_runtime
         actors.append(actor)
     logger.info("actors retrieved.")
     return ok(result=actors, msg="Actors retrieved successfully.")
Exemple #4
0
    def get_metrics(self):
        logger.debug("top of get in MetricResource")

        actor_ids = [
            db_id
            for db_id, _
            in actors_store.items()
        ]
        logger.debug("ACTOR IDS: {}".format(actor_ids))
        try:
            if actor_ids:
                for actor_id in actor_ids:
                    if actor_id not in message_gauges.keys():
                        try:
                            g = Gauge(
                                'message_count_for_actor_{}'.format(actor_id.decode("utf-8").replace('-', '_')),
                                'Number of messages for actor {}'.format(actor_id.decode("utf-8").replace('-', '_'))
                            )
                            message_gauges.update({actor_id: g})
                        except Exception as e:
                            logger.info("got exception trying to instantiate the Gauge: {}".format(e))
                    else:
                        g = message_gauges[actor_id]

                    try:
                        ch = ActorMsgChannel(actor_id=actor_id.decode("utf-8"))
                    except Exception as e:
                        logger.error("Exception connecting to ActorMsgChannel: {}".format(e))
                        raise e
                    result = {'messages': len(ch._queue._queue)}
                    ch.close()
                    g.set(result['messages'])
                    logger.debug("METRICS: {} messages found for actor: {}.".format(result['messages'], actor_id))
                return actor_ids
        except Exception as e:
            logger.info("Got exception in get_metrics: {}".format(e))
            return []
Exemple #5
0
 def get(self):
     return ok(result=[json.loads(actor[1]) for actor in actors_store.items()], msg="Actors retrieved successfully.")
Exemple #6
0
 def get(self):
     actors = []
     for k, v in actors_store.items():
         if v['tenant'] == g.tenant:
             actors.append(Actor.from_db(v).display())
     return ok(result=actors, msg="Actors retrieved successfully.")
Exemple #7
0
def get_actor_ids():
    """Returns the list of actor ids currently registered."""
    return [db_id for db_id, _ in actors_store.items()]
Exemple #8
0
def get_actor_ids():
    """Returns the list of actor ids currently registered."""
    return [db_id for db_id, _ in actors_store.items()]
Exemple #9
0
 def get(self):
     actors = []
     for k, v in actors_store.items():
         if v['tenant'] == g.tenant:
             actors.append(Actor.from_db(v).display())
     return ok(result=actors, msg="Actors retrieved successfully.")