-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add Flask Helper to Error Reporting #2751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@waprin was this ready for review? I know there are no assignees, but there's also no "Don't merge" label. |
docs/error-reporting-usage.rst
Outdated
| >>> 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.
docs/error-reporting-usage.rst
Outdated
|
|
||
| .. code-block:: python | ||
| >>> @app.errorhandler(Exception) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/error-reporting-usage.rst
Outdated
| .. 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.
docs/error-reporting-usage.rst
Outdated
| >>> @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.
|
|
||
| """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.
| # 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.
| 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.
|
|
||
| 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.
|
|
||
| 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.
| 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.
| 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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
| import unittest | ||
|
|
||
|
|
||
| class TestFlaskHelper(unittest.TestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| 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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
57b1a0e to
27f7917
Compare
|
@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.
| import unittest | ||
|
|
||
|
|
||
| class TestFlaskHelper(unittest.TestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/error-reporting-util.rst
Outdated
| @@ -0,0 +1,6 @@ | |||
| Error Reporting Client | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/error-reporting-usage.rst
Outdated
|
|
||
| .. 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.
|
|
||
| """Client library for Stackdriver Error Reporting""" | ||
|
|
||
|
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
error_reporting/tox.ini
Outdated
| deps = | ||
| {toxinidir}/../core | ||
| {toxinidir}/../logging | ||
| {toxinidir}/../logging |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
d4402c5 to
a7e7acc
Compare
|
@dhermes merge? |
Add Flask Helper to Error Reporting
cc / @steren