Created
February 5, 2020 23:33
Star
You must be signed in to star a gist
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
elastic-apm | |
flask | |
requests | |
blinker |
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
import time | |
import requests | |
import elasticapm | |
def main(): | |
sess = requests.Session() | |
for url in ["http://localhost:8080", "http://localhost:8000"]: | |
sess.get(url) | |
time.sleep(1) | |
if __name__ == "__main__": | |
client = elasticapm.Client(service_name="service 1") | |
elasticapm.instrument() | |
client.begin_transaction("main") | |
main() | |
client.end_transaction("main") |
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
import time | |
import requests | |
from flask import Flask | |
import elasticapm | |
from elasticapm.contrib.flask import ElasticAPM | |
app = Flask(__name__) | |
apm = ElasticAPM(app, service_name="service 2a") | |
url = "http://localhost:8888/" | |
@app.route("/") | |
def svc2a(): | |
with elasticapm.capture_span("main"): | |
time.sleep(2) | |
result = requests.get(url) | |
return result.content | |
if __name__ == "__main__": | |
app.run(host="127.0.0.1", port=8080) |
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
import time | |
import requests | |
from flask import Flask | |
import elasticapm | |
from elasticapm.contrib.flask import ElasticAPM | |
app = Flask(__name__) | |
apm = ElasticAPM(app, service_name="service 2b") | |
url = "http://localhost:8888/" | |
@app.route("/") | |
def svc2b(): | |
with elasticapm.capture_span("main"): | |
time.sleep(2) | |
result = requests.get(url) | |
return result.content | |
if __name__ == "__main__": | |
app.run(host="127.0.0.1", port=8000) |
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
import time | |
from flask import Flask | |
import elasticapm | |
from elasticapm.contrib.flask import ElasticAPM | |
app = Flask(__name__) | |
apm = ElasticAPM(app, service_name="service 3") | |
@app.route("/") | |
def hello(): | |
with elasticapm.capture_span("main"): | |
time.sleep(1) # mocks doing something | |
return "hello world" | |
if __name__ == "__main__": | |
app.run(host="127.0.0.1", port=8888) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment