Commit 95d7a4c3 authored by Nane Kratzke's avatar Nane Kratzke
Browse files

Logging headers

parent 866eec95
from flask import Flask, redirect, request
import requests, os, logging
import requests, os, logging, json
from elasticapm.contrib.flask import ElasticAPM
# A very boring and basic hip-hop-service to demonstrate
# observability via tracing across multiple services.
logging.basicConfig(level=logging.INFO)
service = os.environ.get('HIPHOP', 'hiphop')
tier = int(os.environ.get('TIER', '1'))
app = Flask(__name__)
......@@ -16,12 +18,11 @@ def index():
@app.route('/hip')
def hip():
logging.info(f"Request from: { request.remote_addr }")
logging.info(f"Request from { request.remote_addr } with headers { json.dumps(dict(request.headers)) }")
r = ""
url = f"http://{service}-{tier + 1}/hip"
try:
r = requests.get(url)
r = r.content.decode('utf-8')
r = requests.get(url).content
except Exception as ex:
logging.error(f"Fetching { url } failed ({ ex })")
r = "END"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment