Skip to content

Commit 1c76780

Browse files
authored
Merge pull request GoogleCloudPlatform#8480 from GoogleCloudPlatform/python-error-reporting-migration
migrate code from googleapis/python-error-reporting
2 parents d73bcf6 + 9c8970f commit 1c76780

7 files changed

Lines changed: 78 additions & 3 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
/dns/**/* @GoogleCloudPlatform/python-samples-reviewers
4040
/endpoints/**/* @GoogleCloudPlatform/python-samples-reviewers
4141
/eventarc/**/* @GoogleCloudPlatform/aap-dpes @GoogleCloudPlatform/python-samples-reviewers
42+
/error_reporting/**/* @GoogleCloudPlatform/python-samples-reviewers
4243
/firestore/**/* @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/python-samples-reviewers
4344
/functions/**/* @GoogleCloudPlatform/aap-dpes @GoogleCloudPlatform/python-samples-reviewers
4445
/functions/spanner/* @GoogleCloudPlatform/api-spanner-python @GoogleCloudPlatform/python-samples-reviewers

.github/blunderbuss.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ assign_prs_by:
156156
- 'api: iot'
157157
to:
158158
- GoogleCloudPlatform/api-iot
159+
- labels:
160+
- 'api: clouderrorreporting'
161+
to:
162+
- GoogleCloudPlatform/python-samples-reviewers
159163
- labels:
160164
- 'api: talent'
161165
to:

error_reporting/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2022 Google, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# [START error_reporting_quickstart]
19+
# [START error_reporting_setup_python]
20+
def simulate_error():
21+
from google.cloud import error_reporting
22+
23+
client = error_reporting.Client()
24+
try:
25+
# simulate calling a method that's not defined
26+
raise NameError
27+
except Exception:
28+
client.report_exception()
29+
# [END error_reporting_setup_python]
30+
# [END error_reporting_quickstart]
31+
32+
33+
# [START error_reporting_manual]
34+
# [START error_reporting_setup_python_manual]
35+
def report_manual_error():
36+
from google.cloud import error_reporting
37+
38+
client = error_reporting.Client()
39+
client.report("An error has occurred.")
40+
# [END error_reporting_setup_python_manual]
41+
# [END error_reporting_manual]
42+
43+
44+
if __name__ == '__main__':
45+
simulate_error()
46+
report_manual_error()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2022 Google, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import report_exception
18+
19+
20+
def test_error_sends():
21+
report_exception.simulate_error()
22+
23+
24+
def test_manual_error_sends():
25+
report_exception.report_manual_error()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest==7.2.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
google-cloud-error-reporting==1.6.3

0 commit comments

Comments
 (0)