Skip to content

Commit

Permalink
Merge pull request #8480 from GoogleCloudPlatform/python-error-report…
Browse files Browse the repository at this point in the history
…ing-migration

migrate code from googleapis/python-error-reporting
  • Loading branch information
dandhlee authored Nov 15, 2022
2 parents d73bcf6 + 9c8970f commit 1c76780
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
/dns/**/* @GoogleCloudPlatform/python-samples-reviewers
/endpoints/**/* @GoogleCloudPlatform/python-samples-reviewers
/eventarc/**/* @GoogleCloudPlatform/aap-dpes @GoogleCloudPlatform/python-samples-reviewers
/error_reporting/**/* @GoogleCloudPlatform/python-samples-reviewers
/firestore/**/* @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/python-samples-reviewers
/functions/**/* @GoogleCloudPlatform/aap-dpes @GoogleCloudPlatform/python-samples-reviewers
/functions/spanner/* @GoogleCloudPlatform/api-spanner-python @GoogleCloudPlatform/python-samples-reviewers
Expand Down
4 changes: 4 additions & 0 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ assign_prs_by:
- 'api: iot'
to:
- GoogleCloudPlatform/api-iot
- labels:
- 'api: clouderrorreporting'
to:
- GoogleCloudPlatform/python-samples-reviewers
- labels:
- 'api: talent'
to:
Expand Down
3 changes: 0 additions & 3 deletions error_reporting/README.md

This file was deleted.

46 changes: 46 additions & 0 deletions error_reporting/snippets/report_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
#
# Copyright 2022 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# [START error_reporting_quickstart]
# [START error_reporting_setup_python]
def simulate_error():
from google.cloud import error_reporting

client = error_reporting.Client()
try:
# simulate calling a method that's not defined
raise NameError
except Exception:
client.report_exception()
# [END error_reporting_setup_python]
# [END error_reporting_quickstart]


# [START error_reporting_manual]
# [START error_reporting_setup_python_manual]
def report_manual_error():
from google.cloud import error_reporting

client = error_reporting.Client()
client.report("An error has occurred.")
# [END error_reporting_setup_python_manual]
# [END error_reporting_manual]


if __name__ == '__main__':
simulate_error()
report_manual_error()
25 changes: 25 additions & 0 deletions error_reporting/snippets/report_exception_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
#
# Copyright 2022 Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import report_exception


def test_error_sends():
report_exception.simulate_error()


def test_manual_error_sends():
report_exception.report_manual_error()
1 change: 1 addition & 0 deletions error_reporting/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==7.2.0
1 change: 1 addition & 0 deletions error_reporting/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-cloud-error-reporting==1.6.3

0 comments on commit 1c76780

Please sign in to comment.