本文整理匯總了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
示例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()
示例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
示例4: start_timer
# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def start_timer():
request.start_time = time.time()
示例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
示例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
示例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
示例8: before_request
# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request():
request.start_time = time()
示例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
示例10: before_request
# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request():
request.start_time = time.time()
示例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
示例12: before_request
# 需要導入模塊: from flask import request [as 別名]
# 或者: from flask.request import start_time [as 別名]
def before_request():
request.start_time = time.time()
示例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
示例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
示例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