Added basic tracing
This commit is contained in:
parent
3d423c71c6
commit
4e3efb7295
@ -16,4 +16,9 @@ py-healthcheck
|
|||||||
Flask-InfluxDB
|
Flask-InfluxDB
|
||||||
tzdata
|
tzdata
|
||||||
tzlocal
|
tzlocal
|
||||||
apscheduler~=3.7.0
|
apscheduler~=3.7.0
|
||||||
|
|
||||||
|
opentracing~=2.4.0
|
||||||
|
jaeger-client
|
||||||
|
requests-opentracing
|
||||||
|
Flask-Opentracing
|
15
src/app.py
15
src/app.py
@ -19,6 +19,10 @@ from apscheduler.schedulers.background import BackgroundScheduler
|
|||||||
from magic_amqp import magic_amqp
|
from magic_amqp import magic_amqp
|
||||||
from error_handlers import register_all_error_handlers
|
from error_handlers import register_all_error_handlers
|
||||||
|
|
||||||
|
import jaeger_client
|
||||||
|
import opentracing
|
||||||
|
from flask_opentracing import FlaskTracing
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Main Flask RESTful API
|
Main Flask RESTful API
|
||||||
"""
|
"""
|
||||||
@ -32,7 +36,7 @@ if Config.SENTRY_DSN:
|
|||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn=Config.SENTRY_DSN,
|
dsn=Config.SENTRY_DSN,
|
||||||
integrations=[FlaskIntegration(), SqlalchemyIntegration()],
|
integrations=[FlaskIntegration(), SqlalchemyIntegration()],
|
||||||
traces_sample_rate=1.0,
|
traces_sample_rate=0.0,
|
||||||
send_default_pii=True,
|
send_default_pii=True,
|
||||||
release=Config.RELEASE_ID,
|
release=Config.RELEASE_ID,
|
||||||
environment=Config.RELEASEMODE,
|
environment=Config.RELEASEMODE,
|
||||||
@ -66,6 +70,15 @@ def init_db():
|
|||||||
influx_db.database.create(Config.INFLUXDB_DATABASE)
|
influx_db.database.create(Config.INFLUXDB_DATABASE)
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
|
||||||
|
# Setup tracing
|
||||||
|
def initialize_tracer():
|
||||||
|
app.logger.info("Initializing jaeger...")
|
||||||
|
jaeger_cfg = jaeger_client.Config(config={}, service_name='input-service', validate=True)
|
||||||
|
tracer = jaeger_cfg.initialize_tracer()
|
||||||
|
return tracer
|
||||||
|
|
||||||
|
|
||||||
|
tracing = FlaskTracing(initialize_tracer, True, app)
|
||||||
|
|
||||||
api.add_resource(SampleResource, "/sample")
|
api.add_resource(SampleResource, "/sample")
|
||||||
api.add_resource(SampleParameterResource, '/sample/<tag>')
|
api.add_resource(SampleParameterResource, '/sample/<tag>')
|
||||||
|
Loading…
Reference in New Issue
Block a user