Commit 9cbf8840 authored by Gero Vermaas's avatar Gero Vermaas
Browse files

Resolve "Improve layout of response diff page, and include request if possible"

parent 3bf4dbf9
......@@ -78,7 +78,7 @@ docker-compose file as `GF_SECURITY_ADMIN_PASSWORD`.
Both ElasticSearch as a data source and a basis Dashboard are automatically provisioned, see the `grafana_provisioning` subdirectory.
** Depoyment
** Deployment
Basic deployment is done by the `sls deploy` command. After that the step in `provision_metrics_instance.sh` script must be executed. It will copy provisioning files to the EC2 instance and start the docker-compose.
Notes: sometimes it takes a while before DNS names are resolvable. The last commands in the script may then fail and you can
......
<html>
<head>
<style>
del {
background: red;
}
ins {
background:green;
}
h1 {
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: block;
margin: 0;
color: #d8d9da;
font-size: 18px;
min-height: 55px;
line-height: 55px;
}
body {
font-family: Roboto,Helvetica Neue,Arial,sans-serif;
font-size: 13px;
line-height: 1.5;
color: #d8d9da;
background-color: #161719;
width: 100%;
position: absolute;
}
pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
<script>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Serverless Scientist diff viewer</title>
<style>
del {
background: red;
}
ins {
background:green;
}
code, pre {
color: #ccc;
margin: 10px 0px;
}
this-used-to-be-h1 {
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: block;
margin: 0;
color: #d8d9da;
font-size: 18px;
min-height: 55px;
line-height: 55px;
}
body {
font-family: Roboto,Helvetica Neue,Arial,sans-serif;
/* font-size: 13px; */
line-height: 1.5;
color: #d8d9da;
background-color: #161719;
width: 100%;
position: absolute;
}
fieldset {
background-color: #222;
margin: 20px 0px;
padding: 10px;
}
this-used-to-be-pre {
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
</style>
<script>
/*
* Javascript Diff Algorithm
* By John Resig (http://ejohn.org/)
......@@ -206,18 +223,35 @@ pre {
}
</script>
</head>
<body>
<div id="control">
<h1>Control {{CONTROL_IMPLEMENTATION_NAME}}</h1>
<pre class="prettyprint">{{CONTROL_RESPONSE}}</pre>
</div>
<div id="candidate_responses">
{{CANDIDATE_RESPONSES}}
</head>
<body>
<div class="container">
<h1>Simple Serverless Scientist diff viewer</h1>
<form>
<fieldset>
<h4>Request to control and candidate(s)</h4>
<pre id="request">{{REQUEST_PAYLOAD}}</pre>
</fieldset>
<fieldset>
<h4>Control: {{CONTROL_IMPLEMENTATION_NAME}}</h4>
<pre id="control" class="">{{CONTROL_RESPONSE}}</pre>
</fieldset>
<fieldset>
{{CANDIDATE_RESPONSES}}
</fieldset>
</form>
</div>
</body>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<!--
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
-->
</body>
</html>
\ No newline at end of file
......@@ -49,8 +49,9 @@ def lambda_handler(event, context):
metrics = scientist_utils.extract_metrics_from_log(response["LogResult"])
metrics["response_time"] = duration
# Report results of control
# Report results of candidate
run_result = {}
run_result["request_payload"] = event["payload"]
run_result["run_id"] = event["run_id"]
run_result["run_type"] = "candidate"
run_result["implementation_name"] = candidate_details["name"]
......
......@@ -34,6 +34,7 @@ class RunResultsStore:
"received_response": run_result["received_response"],
"run_metrics": run_result["metrics"],
"comparators": run_result["comparators"],
"request_payload": run_result["request_payload"],
}
)
......
......@@ -280,6 +280,7 @@ def lambda_handler(event, response_url):
# has been invoked and does not add latency.
experiment_run["run_id"] = get_run_id()
control_run_result["run_id"] = experiment_run["run_id"]
control_run_result["request_payload"] = experiment_run["payload"]
scientist_duration = int((time.time() - start) * 1000)
metrics_publisher = MetricsPubisher()
......
......@@ -257,6 +257,7 @@ resources:
- received_response
- run_metrics
- comparators
- request_payload
ProjectionType: INCLUDE
CounterDbTable:
Type: 'AWS::DynamoDB::Table'
......
......@@ -32,6 +32,7 @@ def lambda_handler(event, context):
if run_result["run_type"] == "control":
control_response = run_result["received_response"]
control_implementation_name = run_result["implementation_name"]
request_payload = run_result["request_payload"]
else:
candidate_to_compare = {}
candidate_to_compare["run_type"] = run_result["run_type"]
......@@ -41,11 +42,12 @@ def lambda_handler(event, context):
]
candidates_to_compare.append(candidate_to_compare)
LOGGER.info("candidates_to_compare: %s", candidates_to_compare)
candidate_responses_html = ""
with open("./diff.html.tmpl", "r") as content_file:
with open("./diff.tmpl.html", "r") as content_file:
template = content_file.read()
template = template.replace(
"{{REQUEST_PAYLOAD}}", json.dumps(request_payload, sort_keys=True, indent=4)
)
template = template.replace(
"{{CONTROL_RESPONSE}}",
json.dumps(control_response, sort_keys=True, indent=4),
......@@ -53,13 +55,14 @@ def lambda_handler(event, context):
template = template.replace(
"{{CONTROL_IMPLEMENTATION_NAME}}", control_implementation_name
)
for candidate_to_compare in candidates_to_compare:
candidate_response = json_to_base64_string(
candidate_to_compare["received_response"]
)
candidate_responses_html += f"""
<h1>Candidate: {candidate_to_compare["implementation_name"]}</h1>
<pre class="prettyprint" id="candidate-{candidate_to_compare["implementation_name"]}"></pre>
<h4>Candidate: {candidate_to_compare["implementation_name"]}</h4>
<pre class="" id="candidate-{candidate_to_compare["implementation_name"]}"></pre>
<script>
document.getElementById("candidate-{candidate_to_compare["implementation_name"]}").innerHTML = diffString(
atob("{json_to_base64_string(control_response)}"),
......
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