HTTP Server-Timing

Sun 20 May 2018 by admin

One of the easiest way to visualize your app internal performance metrics on demand is too use pretty new standard described in:

https://www.w3.org/TR/server-timing/

combined it with for example Chrome Developers Tools from version 65. More practically with Python Flask app:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/python

from flask import Flask,request,make_response

app = Flask(__name__)

@app.route("/")
def index():
    response = make_response()
    if request.cookies.get('profiler'):
        response.headers['Server-Timing'] = 'task1;desc="Task 1";dur=1500,'+\
                                            'task2;desc="Task 2";dur=110.5'
    return response

and here is the result:

servertiming


Comments