Skip to content

Conversation

@waprin
Copy link
Contributor

@waprin waprin commented Nov 17, 2016

cc / @steren

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 17, 2016
@daspecster
Copy link
Contributor

@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.


.. code-block:: python
>>> @app.errorhandler(Exception)

This comment was marked as spam.

.. code-block:: python
>>> @app.errorhandler(Exception)
>>> def handle_error(e):

This comment was marked as spam.

>>> @app.errorhandler(Exception)
>>> def handle_error(e):
>>> client = error_reporting.Client()

This comment was marked as spam.


"""Client library for Stackdriver Error Reporting"""

from google.cloud.error_reporting.client import Client, HTTPContext

This comment was marked as spam.

# See the License for the specific language governing permissions and
# limitations under the License.


This comment was marked as spam.

self.assertLess(report_location['lineNumber'], 150)


class TestFlaskHelper(unittest.TestCase):

This comment was marked as spam.


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.


class TestFlaskHelper(unittest.TestCase):

def test_flask_helper(self):

This comment was marked as spam.

self.assertEqual(request.remote_addr, context.remoteIp)


# Fake request so no need to bring in Werkzeug as dependency

This comment was marked as spam.

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.

This comment was marked as spam.

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.

import unittest


class TestFlaskHelper(unittest.TestCase):

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


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.

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.

@waprin waprin force-pushed the flask_errors branch 3 times, most recently from 57b1a0e to 27f7917 Compare November 22, 2016 22:03
@waprin
Copy link
Contributor Author

waprin 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.

import unittest


class TestFlaskHelper(unittest.TestCase):

This comment was marked as spam.

@@ -0,0 +1,6 @@
Error Reporting Client

This comment was marked as spam.

This comment was marked as spam.


.. code-block:: python
>>> from google.cloud.error_reporting.util import build_flask_context

This comment was marked as spam.


"""Client library for Stackdriver Error Reporting"""


This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

deps =
{toxinidir}/../core
{toxinidir}/../logging
{toxinidir}/../logging

This comment was marked as spam.

This comment was marked as spam.

@waprin waprin force-pushed the flask_errors branch 3 times, most recently from d4402c5 to a7e7acc Compare November 23, 2016 20:25
@waprin
Copy link
Contributor Author

waprin commented Dec 1, 2016

@dhermes merge?

@dhermes dhermes merged commit 7b74630 into googleapis:master Dec 1, 2016
@dhermes dhermes added api: clouderrorreporting Issues related to the Error Reporting API. and removed api: clouderrorreporting Issues related to the Error Reporting API. labels Feb 23, 2017
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Add Flask Helper to Error Reporting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: clouderrorreporting Issues related to the Error Reporting API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants