| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 import httplib2 | 10 import httplib2 |
| 11 import oauth2client.client | 11 import oauth2client.client |
| 12 | 12 |
| 13 from infra_libs import http_metrics | 13 from infra_libs.ts_mon.common import http_metrics |
| 14 | 14 |
| 15 DEFAULT_SCOPES = ['email'] | 15 DEFAULT_SCOPES = ['email'] |
| 16 | 16 |
| 17 # This is part of the API. | 17 # This is part of the API. |
| 18 # TODO: this is linux-specific, make it multi-platform. | 18 # TODO: this is linux-specific, make it multi-platform. |
| 19 SERVICE_ACCOUNTS_CREDS_ROOT = '/creds/service_accounts' | 19 SERVICE_ACCOUNTS_CREDS_ROOT = '/creds/service_accounts' |
| 20 | 20 |
| 21 | 21 |
| 22 class AuthError(Exception): | 22 class AuthError(Exception): |
| 23 pass | 23 pass |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 duration_msec = (self.time_fn() - start_time) * 1000 | 168 duration_msec = (self.time_fn() - start_time) * 1000 |
| 169 | 169 |
| 170 http_metrics.response_bytes.add(len(content), fields=self.fields) | 170 http_metrics.response_bytes.add(len(content), fields=self.fields) |
| 171 http_metrics.durations.add(duration_msec, fields=self.fields) | 171 http_metrics.durations.add(duration_msec, fields=self.fields) |
| 172 | 172 |
| 173 status_fields = {'status': response.status} | 173 status_fields = {'status': response.status} |
| 174 status_fields.update(self.fields) | 174 status_fields.update(self.fields) |
| 175 http_metrics.response_status.increment(fields=status_fields) | 175 http_metrics.response_status.increment(fields=status_fields) |
| 176 | 176 |
| 177 return response, content | 177 return response, content |
| OLD | NEW |