-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do_stuff returns response, so we don't need _
- Loading branch information
1 parent
180d60d
commit cecd986
Showing
10 changed files
with
59 additions
and
43 deletions.
There are no files selected for viewing
75 changes: 38 additions & 37 deletions
75
labs/automatic-instrumentation/library-instrumentation/initial/src/app.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
# pyright: reportMissingTypeStubs=false, reportUnknownParameterType=false, reportMissingParameterType=false, reportUnknownArgumentType=false, reportUnknownMemberType=false, reportAttributeAccessIssue=false | ||
|
||
import time | ||
|
||
import requests | ||
from client import ChaosClient, FakerClient | ||
from flask import Flask, make_response | ||
|
||
# global variables | ||
app = Flask(__name__) | ||
|
||
@app.route("/users", methods=["GET"]) | ||
def get_user(): | ||
user, status = db.get_user(123) | ||
data = {} | ||
if user is not None: | ||
data = {"id": user.id, "name": user.name, "address": user.address} | ||
response = make_response(data, status) | ||
return response | ||
|
||
|
||
def do_stuff(): | ||
time.sleep(0.1) | ||
url = "http://echo:6000/" | ||
_response = requests.get(url) | ||
|
||
|
||
@app.route("/") | ||
def index(): | ||
do_stuff() | ||
current_time = time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime()) | ||
return f"Hello, World! It's currently {current_time}" | ||
|
||
|
||
if __name__ == "__main__": | ||
db = ChaosClient(client=FakerClient()) | ||
app.run(host="0.0.0.0", debug=True) | ||
# pyright: reportMissingTypeStubs=false, reportUnknownParameterType=false, reportMissingParameterType=false, reportUnknownArgumentType=false, reportUnknownMemberType=false, reportAttributeAccessIssue=false | ||
|
||
import time | ||
|
||
import requests | ||
from client import ChaosClient, FakerClient | ||
from flask import Flask, make_response | ||
|
||
# global variables | ||
app = Flask(__name__) | ||
|
||
@app.route("/users", methods=["GET"]) | ||
def get_user(): | ||
user, status = db.get_user(123) | ||
data = {} | ||
if user is not None: | ||
data = {"id": user.id, "name": user.name, "address": user.address} | ||
response = make_response(data, status) | ||
return response | ||
|
||
|
||
def do_stuff(): | ||
time.sleep(0.1) | ||
url = "http://echo:6000/" | ||
response = requests.get(url) | ||
return response | ||
|
||
|
||
@app.route("/") | ||
def index(): | ||
do_stuff() | ||
current_time = time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime()) | ||
return f"Hello, World! It's currently {current_time}" | ||
|
||
|
||
if __name__ == "__main__": | ||
db = ChaosClient(client=FakerClient()) | ||
app.run(host="0.0.0.0", debug=True) |
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
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
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
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
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
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
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
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
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