Created
March 18, 2020 13:01
-
-
Save david-botelho-mariano/b3c4cb5d748050d0939a434e6f4e7f4f to your computer and use it in GitHub Desktop.
codigo fonte do servidor flask
This file contains hidden or 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
from flask import Flask | |
from elasticapm.contrib.flask import ElasticAPM | |
from elasticapm.handlers.logging import LoggingHandler | |
import time | |
import os | |
#importacao de bibliotecas | |
app = Flask(__name__) | |
#intancia o flask | |
apm = ElasticAPM(app, server_url='http://apm-server:8200', service_name='servico-flask', logging=True) | |
#intancia o apm agent | |
@app.route("/") | |
def index(): | |
#API que traz o ID do container em execucao | |
apm.capture_message('retorno index') | |
hostname = os.uname()[1] | |
return 'Container Hostname: ' + hostname + '\n' | |
@app.route("/lag") | |
#exemplo de API que demora 20 segundos para simular lag | |
def lag(): | |
time.sleep(20) | |
apm.capture_message('retorno lag') | |
return 'lagging' | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port='5000') | |
#inicia o servidor na porta 5000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment