forked from JosephPatrickCabanilla/support-engineer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apm_flask.py
32 lines (25 loc) · 868 Bytes
/
apm_flask.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask
import logging
import sys
from ddtrace import tracer
from ddtrace.contrib.flask import TraceMiddleware
app = Flask(__name__, static_folder='../public/', static_url_path='')
traced_app = TraceMiddleware(app, tracer, service="my-app", distributed_tracing=True)
# Have flask use stdout as the logger
main_logger = logging.getLogger()
main_logger.setLevel(logging.DEBUG)
c = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
c.setFormatter(formatter)
main_logger.addHandler(c)
@app.route('/')
def api_entry():
return 'Entrypoint to the Application'
@app.route('/api/apm')
def apm_endpoint():
return 'Getting APM Started'
@app.route('/api/trace')
def trace_endpoint():
return 'Posting Traces'
if __name__ == '__main__':
app.run(host='0.0.0.0', port='5050')