Skip to content

Commit

Permalink
feature/added the lastEndpoint info on metric page - tweaked the page…
Browse files Browse the repository at this point in the history
… content
  • Loading branch information
hongwei1 committed Dec 6, 2023
1 parent d196ae7 commit e31d48d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions apimanager/metrics/static/metrics/js/lastEndpointMetric.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apimanager/metrics/templates/metrics/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
9 changes: 5 additions & 4 deletions apimanager/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e31d48d

Please sign in to comment.