Skip to content

Commit

Permalink
do_stuff returns response, so we don't need _
Browse files Browse the repository at this point in the history
  • Loading branch information
jtl-novatec committed May 9, 2024
1 parent 180d60d commit cecd986
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 43 deletions.
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)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def get_user():
def do_stuff():
time.sleep(0.1)
url = "http://echo:6000/"
_response = requests.get(url)
response = requests.get(url)
return response


@app.route("/")
Expand Down
1 change: 1 addition & 0 deletions labs/collector/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def do_stuff():
response = requests.get(url)
print(response.json())
logging.info(str(response.json()))
return response

@tracer.start_as_current_span("index")
@app.route("/")
Expand Down
1 change: 1 addition & 0 deletions labs/collector/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def do_stuff():
response = requests.get(url)
print(response.json())
logging.info(str(response.json()))
return response

@tracer.start_as_current_span("index")
@app.route("/")
Expand Down
3 changes: 2 additions & 1 deletion labs/manual-instrumentation-logs/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def get_user():
def do_stuff():
time.sleep(0.1)
url = "http://echo:6000/"
_response = requests.get(url)
response = requests.get(url)
return response


@app.route("/")
Expand Down
1 change: 1 addition & 0 deletions labs/manual-instrumentation-logs/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def do_stuff():
url = "http://echo:6000/"
response = requests.get(url)
logging.info(response.json())
return response


@app.route("/")
Expand Down
3 changes: 2 additions & 1 deletion labs/manual-instrumentation-metrics/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def get_user():
def do_stuff():
time.sleep(0.1)
url = "http://echo:6000/"
_response = requests.get(url)
response = requests.get(url)
return response


@app.route("/")
Expand Down
3 changes: 2 additions & 1 deletion labs/manual-instrumentation-metrics/solution/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def get_user():
def do_stuff():
time.sleep(0.1)
url = "http://echo:6000/"
_response = requests.get(url)
response = requests.get(url)
return response


@app.route("/")
Expand Down
1 change: 1 addition & 0 deletions labs/manual-instrumentation-traces/initial/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def do_stuff():
time.sleep(0.1)
url = "http://echo:6000/"
response = requests.get(url)
return response


@app.route("/")
Expand Down
11 changes: 9 additions & 2 deletions labs/manual-instrumentation-traces/solution/src/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pyright: reportMissingTypeStubs=false, reportUnknownParameterType=false, reportMissingParameterType=false, reportUnknownArgumentType=false

import time
import json

import requests
from client import ChaosClient, FakerClient
Expand Down Expand Up @@ -47,8 +48,14 @@ def do_stuff():

time.sleep(.1)
url = "http://echo:6000/"
_response = requests.get(url, headers=headers)

response = requests.get(url, headers=headers)

# debug
print("Headers included in outbound request:")
print(json.dumps(response.json()["request"]["headers"], indent=2))

return response

@app.route('/')
@tracer.start_as_current_span("index")
def index():
Expand Down

0 comments on commit cecd986

Please sign in to comment.