示例#1
0
def metrics_process(registry, queue):  # pragma: no cover
    session = db.get_session(registry.settings)

    newrelic.agent.initialize()
    application = newrelic.agent.application()

    while True:
        with db.read_only_transaction(session):

            newrelic.agent.record_custom_metrics(websocket_metrics(queue),
                                                 application=application)

        gevent.sleep(METRICS_INTERVAL)
示例#2
0
文件: metrics.py 项目: yaohwu/h
def metrics_process(registry, queue):  # pragma: no cover
    session = db.get_session(registry.settings)

    newrelic.agent.initialize(
        config_file=resource_filename("h.streamer", "conf/newrelic.ini"))
    newrelic.agent.register_application(timeout=5)
    application = newrelic.agent.application()

    while True:
        with db.read_only_transaction(session):
            application.record_custom_metrics(websocket_metrics(queue))

        gevent.sleep(METRICS_INTERVAL)
示例#3
0
def metrics_process(registry, queue):  # pragma: no cover
    session = db.get_session(registry.settings)

    with importlib_resources.as_file(NEW_RELIC_CONFIG_REF) as config_file:
        newrelic.agent.initialize(config_file=config_file)
    newrelic.agent.register_application(timeout=5)
    application = newrelic.agent.application()

    while True:
        with db.read_only_transaction(session):
            application.record_custom_metrics(websocket_metrics(queue))

        gevent.sleep(METRICS_INTERVAL)
示例#4
0
文件: streamer.py 项目: kaydoh/h
def process_work_queue(registry, queue):
    """
    Process each message from the queue in turn, handling exceptions.

    This is the core of the streamer: we pull messages off the work queue,
    dispatching them as appropriate. The handling of each message is wrapped in
    code that ensures the database session is appropriately committed and
    closed between messages.
    """

    session = db.get_session(registry.settings)

    for msg in queue:
        with db.read_only_transaction(session):
            if isinstance(msg, messages.Message):
                messages.handle_message(msg, registry, session, TOPIC_HANDLERS)
            elif isinstance(msg, websocket.Message):
                websocket.handle_message(msg, session)
            else:
                raise UnknownMessageType(repr(msg))
示例#5
0
文件: db_test.py 项目: timgates42/h
    def test_it(self, db):
        session = get_session(sentinel.settings)

        db.make_engine.assert_called_once_with(sentinel.settings)
        db.Session.assert_called_once_with(bind=db.make_engine.return_value)
        assert session == db.Session.return_value