Here is a little snippet combining Elastic APM in a flask app and adding some custom context:
import elasticapm
from flask import Flask
from elasticapm.contrib.flask import ElasticAPM
app = Flask(__name__)
app.config['ELASTIC_APM'] = {
'DEBUG': True,
'SERVER_URL': 'http://localhost:8200',
'SERVICE_NAME': 'test-service',
}
apm = ElasticAPM(app)
@app.route('/')
def index():
elasticapm.set_custom_context({'my-context': 123})
return 'OK'
Please let me know what you are missing from this.