feature/added the lastEndpoint info on metric page - tweaked the page content

This commit is contained in:
Hongwei 2023-12-06 12:02:11 +01:00
parent d196ae7868
commit e31d48dbe7
3 changed files with 12 additions and 10 deletions

View File

@ -4,12 +4,13 @@ $(document).ready(function($) {
function getMetricLastEndpoint(){
$.ajax({url: "/metrics/api/last-endpoint", success: function(result){
var content = "Last call: "
+result['app_name']+" "
var content = ""
+result['implemented_by_partial_function']+" took "
+result['duration']+"ms at "
+result['date']+" "
+result['verb']+" "
+ result['implemented_by_partial_function']
+" costed "
+result['duration']
+ result['url']
+" ms.";
$("#last_endpoint").text(content);
setTimeout(function(){getMetricLastEndpoint();}, 5000); // will call function to update time every 5 seconds

View File

@ -14,7 +14,7 @@
{{ form.media }} {# Form required JS and CSS #}
{% endblock %}
<h1>{% trans "API Metrics" %}</h1>
<h5 id ="last_endpoint">Last call: API Manager getMetrics costed 294 ms</h5>
<h5 id ="last_endpoint">getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms. </h5>
<div id="metrics-filter">
<h2>{% trans "Filter" %}</h2>
<form action="" method="get">

View File

@ -209,10 +209,11 @@ def get_metric_last_endpoint(request):
try:
metric = api.get(urlpath)['metrics'][0]
last_endpoint_metric={
'app_name':metric['app_name'],
'verb': metric['verb'],
'implemented_by_partial_function': metric['implemented_by_partial_function'],
'duration': metric['duration']
'implemented_by_partial_function':metric['implemented_by_partial_function'],
'duration': metric['duration'],
'date': metric['date'],
'verb': metric['verb'],
'url': metric['url']
}
except Exception as err:
LOGGER.exception('error_once_only - Error Message: {}'.format(err))