How can I log response body in APM in python

I found the solution here! and accordingly changed my example as follow:

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:7200',
    'SERVICE_NAME': 'test-service',
}
apm = ElasticAPM(app)

@app.route('/')
def hello_world():
    resp = {"msg": "Hello world!"}
    elasticapm.set_custom_context({'body': resp})
    return 'OK'

if __name__ == '__main__':
    app.run()