當前位置: 首頁>>代碼示例>>Python>>正文


Python request.start_time方法代碼示例

本文整理匯總了Python中flask.request.start_time方法的典型用法代碼示例。如果您正苦於以下問題:Python request.start_time方法的具體用法?Python request.start_time怎麽用?Python request.start_time使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask.request的用法示例。


在下文中一共展示了request.start_time方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: stop_timer

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def stop_timer(response):
    # convert this into milliseconds for statsd
    resp_time = (time.time() - request.start_time)*1000
    key = REQUEST_LATENCY_METRIC_KEY_PATTERN.format(
        request.endpoint,
        request.method,
        response.status_code,
    )
    statsd.timing(key, resp_time)

    key = REQUEST_COUNT_METRIC_KEY_PATTERN.format(
        request.endpoint,
        request.method,
        response.status_code,
    )
    statsd.incr(key)
    return response 
開發者ID:amitsaha,項目名稱:python-monitoring-talk,代碼行數:19,代碼來源:middleware.py

示例2: before_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request(self):  # pylint: disable=R0201
        request.start_time = time.time() 
開發者ID:python-microservices,項目名稱:pyms,代碼行數:4,代碼來源:metrics.py

示例3: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def after_request(self, response):
        request_latency = time.time() - request.start_time
        FLASK_REQUEST_LATENCY.labels(self.app_name, request.method, request.path, response.status_code).observe(request_latency)
        FLASK_REQUEST_COUNT.labels(self.app_name, request.method, request.path, response.status_code).inc()

        return response 
開發者ID:python-microservices,項目名稱:pyms,代碼行數:8,代碼來源:metrics.py

示例4: start_timer

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def start_timer():
    request.start_time = time.time() 
開發者ID:amitsaha,項目名稱:python-monitoring-talk,代碼行數:4,代碼來源:middleware.py

示例5: stop_timer

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def stop_timer(response):
    resp_time = time.time() - request.start_time
    statsd.histogram(REQUEST_LATENCY_METRIC_NAME,
            resp_time,
            tags=[
                'service:webapp',
                'endpoint: %s' % request.path,
                ]
    )
    return response 
開發者ID:amitsaha,項目名稱:python-monitoring-talk,代碼行數:12,代碼來源:middleware.py

示例6: stop_timer

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def stop_timer(response):
    # convert this into milliseconds for statsd
    resp_time = (time.time() - request.start_time)*1000
    node_id = node_ids[random.choice(range(len(node_ids)))]
    with open('metrics.csv', 'a', newline='') as f:
        csvwriter = csv.writer(f)
        csvwriter.writerow([
            str(int(time.time())), 'webapp1', node_id,
            request.endpoint, request.method, str(response.status_code),
            str(resp_time)
        ])

    return response 
開發者ID:amitsaha,項目名稱:python-monitoring-talk,代碼行數:15,代碼來源:middleware.py

示例7: stop_timer

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def stop_timer(response):
    # convert this into milliseconds for statsd
    resp_time = (time.time() - request.start_time)*1000
    with open('metrics.csv', 'a', newline='') as f:
        csvwriter = csv.writer(f)
        csvwriter.writerow([str(int(time.time())), str(resp_time)])

    return response 
開發者ID:amitsaha,項目名稱:python-monitoring-talk,代碼行數:10,代碼來源:middleware.py

示例8: before_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request():
    request.start_time = time() 
開發者ID:c3bottles,項目名稱:c3bottles,代碼行數:4,代碼來源:metrics.py

示例9: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def after_request(response):
    latency = time() - request.start_time
    request_latency.labels(request.method, request.endpoint).observe(latency)
    request_count.labels(request.method, request.endpoint, response.status_code).inc()
    return response 
開發者ID:c3bottles,項目名稱:c3bottles,代碼行數:7,代碼來源:metrics.py

示例10: before_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request():
    request.start_time = time.time() 
開發者ID:sbarratt,項目名稱:flask-prometheus,代碼行數:4,代碼來源:__init__.py

示例11: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def after_request(response):
    request_latency = time.time() - request.start_time
    FLASK_REQUEST_LATENCY.labels(request.method, request.path).observe(request_latency)
    FLASK_REQUEST_COUNT.labels(request.method, request.path, response.status_code).inc()

    return response 
開發者ID:sbarratt,項目名稱:flask-prometheus,代碼行數:8,代碼來源:__init__.py

示例12: before_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request():
	request.start_time = time.time() 
開發者ID:sbarratt,項目名稱:flask-prometheus,代碼行數:4,代碼來源:__init__.py

示例13: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def after_request(response):
	request_latency = time.time() - request.start_time
	FLASK_REQUEST_LATENCY.labels(request.method, request.path).observe(request_latency)
	FLASK_REQUEST_COUNT.labels(request.method, request.path, response.status_code).inc()

	return response 
開發者ID:sbarratt,項目名稱:flask-prometheus,代碼行數:8,代碼來源:__init__.py

示例14: after_request

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def after_request(response):
    request_latency = time.time() - request.start_time
    FLASK_REQUEST_LATENCY.labels(request.method, request.path).observe(request_latency)
    FLASK_REQUEST_COUNT.labels(request.method, request.path, response.status_code).inc()
    return response 
開發者ID:kubernetes-for-developers,項目名稱:kfd-flask,代碼行數:7,代碼來源:exampleapp.py

示例15: record_request_data

# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def record_request_data(response):
    resp_time = time.time() - request.start_time

    REQUEST_LATENCY.labels(request.method, request.path).observe(resp_time)
    REQUEST_COUNT.labels(request.method, request.path, response.status_code).inc()

    return response 
開發者ID:Mirantis,項目名稱:kqueen,代碼行數:9,代碼來源:middleware.py


注:本文中的flask.request.start_time方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。