def report(cls):
     event = ApplicationEvent()
     event.event_value = cls.data()
     event.event_type = 'scout.metadata'
     event.timestamp = datetime.utcnow()
     event.source = 'Pid: ' + str(getpid())
     AgentContext.socket().send(event)
Exemple #2
0
def install(*args, **kwargs):
    if "config" in kwargs:
        ScoutConfig().set(**kwargs["config"])
    context = AgentContext.build(config=ScoutConfig())

    if not context.config.value("monitor"):
        logger.info(
            "APM Not Launching on PID: %s - Configuration 'monitor' is not true",
            getpid(),
        )
        return False

    InstrumentManager().install_all()

    if objtrace is not None:
        objtrace.enable()

    logger.debug("APM Launching on PID: %s", getpid())
    launched = CoreAgentManager().launch()

    AppMetadata.report()
    if launched:
        AgentContext.socket().stop()

    return True
def install():
    if not AgentContext.instance().config.value('monitor'):
        logger.info(
            "APM Not Launching on PID: %s - Configuration 'monitor' is not true",
            getpid())
        return False

    logger.debug('APM Launching on PID: %s', getpid())
    CoreAgentManager().launch()
    AppMetadata.report()
    AgentContext.socket().stop()
    def run_samplers(cls):
        logger.debug("Starting Samplers. Acquiring samplers lock.")
        try:
            if cls._thread_lock.acquire(True):
                logger.debug("Acquired samplers lock.")
                instances = [Cpu(), Memory()]

                while True:
                    for instance in instances:
                        event = ApplicationEvent()
                        event.event_value = instance.run()
                        event.event_type = (instance.metric_type() + "/" +
                                            instance.metric_name())
                        event.timestamp = datetime.utcnow()
                        event.source = "Pid: " + str(getpid())

                        if event.event_value is not None:
                            AgentContext.socket().send(event)
                    sleep(60)
        finally:
            logger.debug("Shutting down samplers thread.")
            cls._thread_lock.release()
Exemple #5
0
def install(*args, **kwargs):
    if 'config' in kwargs:
        ScoutConfig().set(**kwargs['config'])
    context = AgentContext.build(config=ScoutConfig())

    if not context.config.value('monitor'):
        logger.info(
            "APM Not Launching on PID: %s - Configuration 'monitor' is not true",
            getpid())
        return False

    InstrumentManager().install_all()

    if HAS_OBJTRACE:
        objtrace.enable()

    logger.debug('APM Launching on PID: %s', getpid())
    CoreAgentManager().launch()

    AppMetadata.report()
    AgentContext.socket().stop()
    return True
 def flush_request(self, request):
     batch_command = BatchCommand.from_tracked_request(request)
     if batch_command is not None:
         AgentContext.socket().send(batch_command)