Created
February 27, 2018 20:45
-
-
Save graphaelli/d9cb1c59bc1a78459650c9882382c2fb to your computer and use it in GitHub Desktop.
sample elastic apm flask app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import elasticapm | |
from elasticapm.contrib.flask import ElasticAPM | |
from flask import Flask | |
# initialize using environment variables from elasticapm.contrib.flask import ElasticAPM | |
app = Flask(__name__) | |
# configure to use ELASTIC_APM in your application's settings from elasticapm.contrib.flask import ElasticAPM | |
app.config['ELASTIC_APM'] = { | |
# allowed app_name chars: a-z, A-Z, 0-9, -, _, and space from elasticapm.contrib.flask | |
'APP_NAME': 'flask-apm-client', | |
'DEBUG': True, | |
'SERVER_URL': 'http://localhost:8200', | |
'TRACES_SEND_FREQ': 5, | |
'SERVICE_NAME': 'flaskapp', | |
'FLUSH_INTERVAL': 1, # 2.x | |
'MAX_QUEUE_SIZE': 1, # 2.x | |
'TRANSACTIONS_IGNORE_PATTERNS': ['.*healthcheck'] | |
} | |
apm = ElasticAPM(app, logging=True) | |
@app.route('/foo') | |
def foo_route(): | |
return foo() | |
@elasticapm.capture_span() | |
def foo(): | |
return "foo" | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to use the decorator @elasticapm.capture_span() within another class/module after ElasticAPM has been initialized? I have quickly given it a try and it doesn't seem like it, but perhaps you'd be able to tell me otherwise.