Skip to content

Commit

Permalink
feature/added the lastEndpoint info on metric page - added the to_dat…
Browse files Browse the repository at this point in the history
…e to get_metric_last_endpoint
  • Loading branch information
hongwei1 committed Dec 6, 2023
1 parent e31d48d commit 5e3b073
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions apimanager/metrics/static/metrics/js/lastEndpointMetric.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ function getMetricLastEndpoint(){
$.ajax({url: "/metrics/api/last-endpoint", success: function(result){
var content = ""
+result['implemented_by_partial_function']+" took "
+result['duration']+"ms at "
+result['duration']+" ms at "
+result['date']+" "
+result['verb']+" "
+ result['url']

+" ms.";
+ result['url'];
$("#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">getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms. </h5>
<p id ="last_endpoint">getBanks took 43ms at 2023-12-06T11:00:49Z GET /obp/v4.0.0/banks ms. </p>
<div id="metrics-filter">
<h2>{% trans "Filter" %}</h2>
<form action="" method="get">
Expand Down
3 changes: 2 additions & 1 deletion apimanager/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def get_context_data(self, **kwargs):
return context

def get_metric_last_endpoint(request):
urlpath = "/management/metrics?limit=1"
to_date = datetime.datetime.now().strftime(settings.API_DATE_FORMAT_WITH_MILLISECONDS)
urlpath = "/management/metrics?limit=1&to_date="+to_date
api = API(request.session.get('obp'))
last_endpoint_metric={}
try:
Expand Down

0 comments on commit 5e3b073

Please sign in to comment.