Uh oh!
There was an error while loading. Please reload this page.
Add Flask Helper to Error Reporting - #2751
Conversation
daspecster
commented
Nov 18, 2016
@waprin was this ready for review? I know there are no assignees, but there's also no "Don't merge" label. |
| >>> client = error_reporting.Client() | ||
| >>> client.report_exception( | ||
| >>> http_context=build_flask_context(request)) | ||
| >>> # rest of error response code here |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| .. code-block:: python | ||
| >>> @app.errorhandler(Exception) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| .. code-block:: python | ||
| >>> @app.errorhandler(Exception) | ||
| >>> def handle_error(e): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| >>> @app.errorhandler(Exception) | ||
| >>> def handle_error(e): | ||
| >>> client = error_reporting.Client() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| """Client library for Stackdriver Error Reporting""" | ||
| from google.cloud.error_reporting.client import Client, HTTPContext |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertLess(report_location['lineNumber'], 150) | ||
| class TestFlaskHelper(unittest.TestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_flask_helper(self): | ||
| from google.cloud.error_reporting import build_flask_context | ||
| request = _Request('http://google.com', 'GET', |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| class TestFlaskHelper(unittest.TestCase): | ||
| def test_flask_helper(self): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertEqual(request.remote_addr, context.remoteIp) | ||
| # Fake request so no need to bring in Werkzeug as dependency |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| from google.cloud.error_reporting.client import HTTPContext | ||
| def build_flask_context(request): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| referrer=request.referrer, | ||
| remote_ip=request.remote_addr) | ||
| from google.cloud.error_reporting.client import Client | ||
| from google.cloud.error_reporting.client import HTTPContext |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| import unittest | ||
| class TestFlaskHelper(unittest.TestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_flask_helper(self): | ||
| from google.cloud.error_reporting.util import build_flask_context | ||
| user_agent = _UserAgent('Google Cloud Unit Tests Agent') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| class TestFlaskHelper(unittest.TestCase): | ||
| def test_flask_helper(self): | ||
| from google.cloud.error_reporting.util import build_flask_context |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
57b1a0e to
27f7917Comparewaprin
commented
Nov 22, 2016
@dhermes ping whenever is convenient. hit most review comments but wasn't sure about test class naming conventions, looked at a few and didn't seen an obvious consistency I was breaking. |
| from google.cloud.error_reporting.client import HTTPContext | ||
| def build_flask_context(request): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| import unittest | ||
| class TestFlaskHelper(unittest.TestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| @@ -0,0 +1,6 @@ | |||
| Error Reporting Client | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| .. code-block:: python | ||
| >>> from google.cloud.error_reporting.util import build_flask_context |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| """Client library for Stackdriver Error Reporting""" | ||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| deps = | ||
| {toxinidir}/../core | ||
| {toxinidir}/../logging | ||
| {toxinidir}/../logging |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
d4402c5 to
a7e7accComparewaprin
commented
Dec 1, 2016
@dhermes merge? |
Add Flask Helper to Error Reporting
cc / @steren