Skip to content

Commit

Permalink
Deployment: Deploy frontend V1 on staging and disable statsd push for…
Browse files Browse the repository at this point in the history
… monitoring setup(Cloud-CV#3587)

* Deploy frontend V1 on staging and disable statsd push

* Flake8 fixes

Co-authored-by: Rishabh Jain <[email protected]>
  • Loading branch information
Ram81 and RishabhJain2018 authored Aug 31, 2021
1 parent 5cf8418 commit 505cdf1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docker-compose-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ services:
NODE_ENV: staging
ports:
- '80:80'
- "443:443"
volumes:
- /code/node_modules
- /code/bower_components
Expand All @@ -68,7 +69,6 @@ services:
NODE_ENV: staging
ports:
- "9999:80"
- "443:443"
volumes:
- /code/node_modules
logging:
Expand Down
43 changes: 22 additions & 21 deletions middleware/statsd/statsd_middleware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time

from django.utils.deprecation import MiddlewareMixin
from monitoring.statsd.metrics import statsd, REQUEST_COUNT_METRIC_NAME, REQUEST_LATENCY_METRIC_NAME
# from monitoring.statsd.metrics import statsd, REQUEST_COUNT_METRIC_NAME, REQUEST_LATENCY_METRIC_NAME


class StatsdMetricsMiddleware(MiddlewareMixin):
Expand All @@ -17,25 +17,26 @@ def get_view_name(self, request):
return view_name

def process_response(self, request, response):
statsd.increment(
REQUEST_COUNT_METRIC_NAME,
tags=[
"service:django_worker",
"method:%s" % request.method,
"view:%s" % self.get_view_name(request),
"status:%s" % str(response.status_code),
],
)

resp_time = (time.time() - request.start_time) * 1000

statsd.histogram(
REQUEST_LATENCY_METRIC_NAME,
resp_time,
tags=[
"service:django_worker",
"view:%s" % self.get_view_name(request),
],
)
# TODO: Enable statsd metric push once production docker setup is ready
# statsd.increment(
# REQUEST_COUNT_METRIC_NAME,
# tags=[
# "service:django_worker",
# "method:%s" % request.method,
# "view:%s" % self.get_view_name(request),
# "status:%s" % str(response.status_code),
# ],
# )

# resp_time = (time.time() - request.start_time) * 1000

# statsd.histogram(
# REQUEST_LATENCY_METRIC_NAME,
# resp_time,
# tags=[
# "service:django_worker",
# "view:%s" % self.get_view_name(request),
# ],
# )

return response
4 changes: 3 additions & 1 deletion monitoring/statsd/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@


def increment_statsd_counter(metric_name, tags, inc_value):
statsd.increment(metric_name, inc_value, tags=tags)
# TODO: Enable statsd metric increment once production docker setup is ready
# statsd.increment(metric_name, inc_value, tags=tags)
return

0 comments on commit 505cdf1

Please sign in to comment.