File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 44
55from flasgger import Swagger
66from flask import Flask
7+ from flask_opentracing import FlaskTracer
8+ from jaeger_client import Config
79
810from project .config import CONFIG
911
4547}
4648
4749
50+ def init_jaeger_tracer (service_name = 'your-app-name' ):
51+ config = Config (config = {
52+ 'sampler' : {'type' : 'const' , 'param' : 1 }
53+ }, service_name = service_name )
54+ return config .initialize_tracer ()
55+
56+
4857class PrefixMiddleware (object ):
4958
5059 def __init__ (self , app , prefix = '' ):
@@ -73,6 +82,9 @@ def create_app():
7382 app .config .from_object (CONFIG [environment ])
7483 app .wsgi_app = PrefixMiddleware (app .wsgi_app , prefix = app .config ["APPLICATION_ROOT" ])
7584
85+ j_tracer = init_jaeger_tracer (app .config ["APP_NAME" ])
86+ FlaskTracer (j_tracer , True , app )
87+
7688 db .init_app (app )
7789
7890 SWAGGER_CONFIG ["specs" ][0 ]["route" ] = SWAGGER_CONFIG ["specs" ][0 ]["route" ].format (
Original file line number Diff line number Diff line change 11flasgger == 0.8.1
22Flask == 0.12.2
3+ Flask-OpenTracing == 0.1.8
34Flask-Script == 2.0.6
45Flask-SQLAlchemy == 2.3.2
56Flask-Testing == 0.7.1
67SQLAlchemy == 1.2.5
7- requests == 2.18.4
8+ requests == 2.18.4
9+ jaeger-client == 3.7.1
You can’t perform that action at this time.
0 commit comments