English | 中文 | 한국어 |
依赖 | 版本 | 杂项 |
---|---|---|
python | 3+ | (async must 3.7.1+) |
collector-agent | installed ? |
$ pip install pinpointPy==1.3.1
include middleware
app = Flask(__name__)
app.wsgi_app = PinPointMiddleWare(app,app.wsgi_app)
append into django middleware
settings.py
MIDDLEWARE = [
'pinpointPy.Django.DjangoMiddleWare',
...
]
在 app/main.py 中添加 pinpoint 的配置:
# pinpoint
##############################################
from starlette_context.middleware import ContextMiddleware
from starlette_context import context, plugins
from pinpointPy import set_agent
from pinpointPy.Fastapi import asyn_monkey_patch_for_pinpoint
from starlette.middleware import Middleware
from pinpointPy.Fastapi import PinPointMiddleWare
middleware = [
Middleware(ContextMiddleware),
Middleware(PinPointMiddleWare)
]
asyn_monkey_patch_for_pinpoint()
set_agent("fastapi-redis", "fastapi-redis", 'tcp:10.34.130.152:9999', -1, True)
##############################################
Add pinpoint_tween middleware
config = Configurator(settings=settings, root_factory="conduit.auth.RootFactory")
config.add_tween('pinpoint.pyramid.tween.pinpoint_tween')
Example pinpoint-in-pyramid
Loading pinpint.Bottle before application run
Example pinpoint-in-bottle
Todo….
Add pinpoint middleware
Example py-web
Add pinpoint middleware
Example py-web2
# enable auto-interceptor plugins
monkey_patch_for_pinpoint()
# set pinpoint related environment
set_agent("flask-agent","FLASK-AGENT",'tcp:dev-collector:9999',-1)
- | TPR(ms) | RPS(#/sec) |
---|---|---|
pinpoint-py | 4.487 | 445.73 |
- | 4.498 | 444.69 |
- | 4.526 | 441.88 |
pure | 4.440 | 450.44 |
- | 4.479 | 446.51 |
- | 4.425 | 451.96 |
Result | +0.05ms | -1% |
TPR: time per request
RPS: requests per second