diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b8ca6cb4be0..35aee0d1018 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -38,6 +38,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 diff --git a/.github/blunderbuss.yml b/.github/blunderbuss.yml index 5a26676163b..3a61a7de33a 100644 --- a/.github/blunderbuss.yml +++ b/.github/blunderbuss.yml @@ -152,6 +152,10 @@ assign_prs_by: - 'api: iot' to: - GoogleCloudPlatform/api-iot +- labels: + - 'api: clouderrorreporting' + to: + - GoogleCloudPlatform/python-samples-reviewers - labels: - 'api: talent' to: diff --git a/error_reporting/README.md b/error_reporting/README.md deleted file mode 100644 index 9513aee2cca..00000000000 --- a/error_reporting/README.md +++ /dev/null @@ -1,3 +0,0 @@ -These samples have been moved. - -https://github.com/googleapis/python-error-reporting/tree/main/samples diff --git a/error_reporting/snippets/report_exception.py b/error_reporting/snippets/report_exception.py new file mode 100644 index 00000000000..63f2fdf5ced --- /dev/null +++ b/error_reporting/snippets/report_exception.py @@ -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() diff --git a/error_reporting/snippets/report_exception_test.py b/error_reporting/snippets/report_exception_test.py new file mode 100644 index 00000000000..a1bf408b01a --- /dev/null +++ b/error_reporting/snippets/report_exception_test.py @@ -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() diff --git a/error_reporting/snippets/requirements-test.txt b/error_reporting/snippets/requirements-test.txt new file mode 100644 index 00000000000..49780e03569 --- /dev/null +++ b/error_reporting/snippets/requirements-test.txt @@ -0,0 +1 @@ +pytest==7.2.0 diff --git a/error_reporting/snippets/requirements.txt b/error_reporting/snippets/requirements.txt new file mode 100644 index 00000000000..fd18a2fa936 --- /dev/null +++ b/error_reporting/snippets/requirements.txt @@ -0,0 +1 @@ +google-cloud-error-reporting==1.6.3