Merge ~suligap/canonical-identity-provider:talisker-statsd into canonical-identity-provider:master

Proposed by Przemysław Suliga
Status: Merged
Approved by: Przemysław Suliga
Approved revision: 896f48aea116c5ad392bb8200424f33634e809f3
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~suligap/canonical-identity-provider:talisker-statsd
Merge into: canonical-identity-provider:master
Prerequisite: ~suligap/canonical-identity-provider:new-style-middleware
Diff against target: 25 lines (+2/-1)
2 files modified
django_project/settings_base.py (+1/-0)
requirements.txt (+1/-1)
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini Approve
Review via email: mp+384617@code.launchpad.net

Commit message

Prepare for talisker's statsd integration

Description of the change

- Bump statsd package version to 3.3.0 (required by talisker for
  configuring the statsd client)
- Add talisker.django.middleware

After this, talisker can be configured using a STATSD_DSN env var to
send out various metrics to statsd. Currently those will be timers and
counters for views; example counter:

    $prefix.wsgi.latency.account-index.GET.200

The middleware is needed for view name introspection, also for the
purposes of creating these metrics:
https://talisker.readthedocs.io/en/latest/django.html#metadata

This also results in an X-View-Name response header being added.
Example:

    X-View-Name: account-index

Enabling the metrics sending part requires adding a proper STATSD_DSN
env var to talisker's execution env. Later more metrics can be added by
switching to use talisker provided `requests` session for example.

Maybe later, we can look into replacing the django_statsd based
PistonRequestTimingMiddleware metrics by these talisker provided ones.
They have a bit different naming structure (but it might be a win just
letting talisker decide here).

This depends on the new style middleware branch: https://code.launchpad.net/~suligap/canonical-identity-provider/+git/canonical-identity-provider/+merge/384550

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/django_project/settings_base.py b/django_project/settings_base.py
2index d131316..3ea4490 100644
3--- a/django_project/settings_base.py
4+++ b/django_project/settings_base.py
5@@ -403,6 +403,7 @@ MIDDLEWARE = [
6 'django.middleware.clickjacking.XFrameOptionsMiddleware',
7 'identityprovider.middleware.useraccount.UserAccountConversionMiddleware',
8 'django.middleware.locale.LocaleMiddleware',
9+ 'talisker.django.middleware',
10 ]
11
12 MONTH_DAY_FORMAT = 'F j'
13diff --git a/requirements.txt b/requirements.txt
14index 60cc1e6..4e895fd 100644
15--- a/requirements.txt
16+++ b/requirements.txt
17@@ -40,7 +40,7 @@ requests-oauthlib==0.4.2
18 saml2idp==0.18
19 six==1.10.0
20 ssoclient==2.1.1
21-statsd==3.1
22+statsd==3.3.0
23 talisker[django,gunicorn,raven]==0.18.0
24 testresources==0.2.7
25 timeline==0.0.4

Subscribers

People subscribed via source and target branches