Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/errorreporting_v1beta1/types/common.py: 98%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

44 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2025 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16from __future__ import annotations 

17 

18from typing import MutableMapping, MutableSequence 

19 

20import proto # type: ignore 

21 

22from google.protobuf import timestamp_pb2 # type: ignore 

23 

24 

25__protobuf__ = proto.module( 

26 package="google.devtools.clouderrorreporting.v1beta1", 

27 manifest={ 

28 "ResolutionStatus", 

29 "ErrorGroup", 

30 "TrackingIssue", 

31 "ErrorEvent", 

32 "ServiceContext", 

33 "ErrorContext", 

34 "HttpRequestContext", 

35 "SourceLocation", 

36 }, 

37) 

38 

39 

40class ResolutionStatus(proto.Enum): 

41 r"""Resolution status of an error group. 

42 

43 Values: 

44 RESOLUTION_STATUS_UNSPECIFIED (0): 

45 Status is unknown. When left unspecified in 

46 requests, it is treated like OPEN. 

47 OPEN (1): 

48 The error group is not being addressed. This 

49 is the default for new groups. It is also used 

50 for errors re-occurring after marked RESOLVED. 

51 ACKNOWLEDGED (2): 

52 Error Group manually acknowledged, it can 

53 have an issue link attached. 

54 RESOLVED (3): 

55 Error Group manually resolved, more events 

56 for this group are not expected to occur. 

57 MUTED (4): 

58 The error group is muted and excluded by 

59 default on group stats requests. 

60 """ 

61 RESOLUTION_STATUS_UNSPECIFIED = 0 

62 OPEN = 1 

63 ACKNOWLEDGED = 2 

64 RESOLVED = 3 

65 MUTED = 4 

66 

67 

68class ErrorGroup(proto.Message): 

69 r"""Description of a group of similar error events. 

70 

71 Attributes: 

72 name (str): 

73 The group resource name. Written as 

74 ``projects/{projectID}/groups/{group_id}`` or 

75 ``projects/{projectID}/locations/{location}/groups/{group_id}`` 

76 

77 Examples: ``projects/my-project-123/groups/my-group``, 

78 ``projects/my-project-123/locations/us-central1/groups/my-group`` 

79 

80 In the group resource name, the ``group_id`` is a unique 

81 identifier for a particular error group. The identifier is 

82 derived from key parts of the error-log content and is 

83 treated as Service Data. For information about how Service 

84 Data is handled, see `Google Cloud Privacy 

85 Notice <https://cloud.google.com/terms/cloud-privacy-notice>`__. 

86 

87 For a list of supported locations, see `Supported 

88 Regions <https://cloud.google.com/logging/docs/region-support>`__. 

89 ``global`` is the default when unspecified. 

90 group_id (str): 

91 An opaque identifier of the group. This field is assigned by 

92 the Error Reporting system and always populated. 

93 

94 In the group resource name, the ``group_id`` is a unique 

95 identifier for a particular error group. The identifier is 

96 derived from key parts of the error-log content and is 

97 treated as Service Data. For information about how Service 

98 Data is handled, see `Google Cloud Privacy 

99 Notice <https://cloud.google.com/terms/cloud-privacy-notice>`__. 

100 tracking_issues (MutableSequence[google.cloud.errorreporting_v1beta1.types.TrackingIssue]): 

101 Associated tracking issues. 

102 resolution_status (google.cloud.errorreporting_v1beta1.types.ResolutionStatus): 

103 Error group's resolution status. 

104 

105 An unspecified resolution status will be 

106 interpreted as OPEN 

107 """ 

108 

109 name: str = proto.Field( 

110 proto.STRING, 

111 number=1, 

112 ) 

113 group_id: str = proto.Field( 

114 proto.STRING, 

115 number=2, 

116 ) 

117 tracking_issues: MutableSequence["TrackingIssue"] = proto.RepeatedField( 

118 proto.MESSAGE, 

119 number=3, 

120 message="TrackingIssue", 

121 ) 

122 resolution_status: "ResolutionStatus" = proto.Field( 

123 proto.ENUM, 

124 number=5, 

125 enum="ResolutionStatus", 

126 ) 

127 

128 

129class TrackingIssue(proto.Message): 

130 r"""Information related to tracking the progress on resolving the 

131 error. 

132 

133 Attributes: 

134 url (str): 

135 A URL pointing to a related entry in an issue tracking 

136 system. Example: 

137 ``https://github.com/user/project/issues/4`` 

138 """ 

139 

140 url: str = proto.Field( 

141 proto.STRING, 

142 number=1, 

143 ) 

144 

145 

146class ErrorEvent(proto.Message): 

147 r"""An error event which is returned by the Error Reporting 

148 system. 

149 

150 Attributes: 

151 event_time (google.protobuf.timestamp_pb2.Timestamp): 

152 Time when the event occurred as provided in 

153 the error report. If the report did not contain 

154 a timestamp, the time the error was received by 

155 the Error Reporting system is used. 

156 service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): 

157 The ``ServiceContext`` for which this error was reported. 

158 message (str): 

159 The stack trace that was reported or logged 

160 by the service. 

161 context (google.cloud.errorreporting_v1beta1.types.ErrorContext): 

162 Data about the context in which the error 

163 occurred. 

164 """ 

165 

166 event_time: timestamp_pb2.Timestamp = proto.Field( 

167 proto.MESSAGE, 

168 number=1, 

169 message=timestamp_pb2.Timestamp, 

170 ) 

171 service_context: "ServiceContext" = proto.Field( 

172 proto.MESSAGE, 

173 number=2, 

174 message="ServiceContext", 

175 ) 

176 message: str = proto.Field( 

177 proto.STRING, 

178 number=3, 

179 ) 

180 context: "ErrorContext" = proto.Field( 

181 proto.MESSAGE, 

182 number=5, 

183 message="ErrorContext", 

184 ) 

185 

186 

187class ServiceContext(proto.Message): 

188 r"""Describes a running service that sends errors. 

189 Its version changes over time and multiple versions can run in 

190 parallel. 

191 

192 Attributes: 

193 service (str): 

194 An identifier of the service, such as the name of the 

195 executable, job, or Google App Engine service name. This 

196 field is expected to have a low number of values that are 

197 relatively stable over time, as opposed to ``version``, 

198 which can be changed whenever new code is deployed. 

199 

200 Contains the service name for error reports extracted from 

201 Google App Engine logs or ``default`` if the App Engine 

202 default service is used. 

203 version (str): 

204 Represents the source code version that the 

205 developer provided, which could represent a 

206 version label or a Git SHA-1 hash, for example. 

207 For App Engine standard environment, the version 

208 is set to the version of the app. 

209 resource_type (str): 

210 Type of the MonitoredResource. List of 

211 possible values: 

212 https://cloud.google.com/monitoring/api/resources 

213 

214 Value is set automatically for incoming errors 

215 and must not be set when reporting errors. 

216 """ 

217 

218 service: str = proto.Field( 

219 proto.STRING, 

220 number=2, 

221 ) 

222 version: str = proto.Field( 

223 proto.STRING, 

224 number=3, 

225 ) 

226 resource_type: str = proto.Field( 

227 proto.STRING, 

228 number=4, 

229 ) 

230 

231 

232class ErrorContext(proto.Message): 

233 r"""A description of the context in which an error occurred. 

234 This data should be provided by the application when reporting 

235 an error, unless the 

236 error report has been generated automatically from Google App 

237 Engine logs. 

238 

239 Attributes: 

240 http_request (google.cloud.errorreporting_v1beta1.types.HttpRequestContext): 

241 The HTTP request which was processed when the 

242 error was triggered. 

243 user (str): 

244 The user who caused or was affected by the crash. This can 

245 be a user ID, an email address, or an arbitrary token that 

246 uniquely identifies the user. When sending an error report, 

247 leave this field empty if the user was not logged in. In 

248 this case the Error Reporting system will use other data, 

249 such as remote IP address, to distinguish affected users. 

250 See ``affected_users_count`` in ``ErrorGroupStats``. 

251 report_location (google.cloud.errorreporting_v1beta1.types.SourceLocation): 

252 The location in the source code where the 

253 decision was made to report the error, usually 

254 the place where it was logged. For a logged 

255 exception this would be the source line where 

256 the exception is logged, usually close to the 

257 place where it was caught. 

258 """ 

259 

260 http_request: "HttpRequestContext" = proto.Field( 

261 proto.MESSAGE, 

262 number=1, 

263 message="HttpRequestContext", 

264 ) 

265 user: str = proto.Field( 

266 proto.STRING, 

267 number=2, 

268 ) 

269 report_location: "SourceLocation" = proto.Field( 

270 proto.MESSAGE, 

271 number=3, 

272 message="SourceLocation", 

273 ) 

274 

275 

276class HttpRequestContext(proto.Message): 

277 r"""HTTP request data that is related to a reported error. 

278 This data should be provided by the application when reporting 

279 an error, unless the 

280 error report has been generated automatically from Google App 

281 Engine logs. 

282 

283 Attributes: 

284 method (str): 

285 The type of HTTP request, such as ``GET``, ``POST``, etc. 

286 url (str): 

287 The URL of the request. 

288 user_agent (str): 

289 The user agent information that is provided 

290 with the request. 

291 referrer (str): 

292 The referrer information that is provided 

293 with the request. 

294 response_status_code (int): 

295 The HTTP response status code for the 

296 request. 

297 remote_ip (str): 

298 The IP address from which the request 

299 originated. This can be IPv4, IPv6, or a token 

300 which is derived from the IP address, depending 

301 on the data that has been provided in the error 

302 report. 

303 """ 

304 

305 method: str = proto.Field( 

306 proto.STRING, 

307 number=1, 

308 ) 

309 url: str = proto.Field( 

310 proto.STRING, 

311 number=2, 

312 ) 

313 user_agent: str = proto.Field( 

314 proto.STRING, 

315 number=3, 

316 ) 

317 referrer: str = proto.Field( 

318 proto.STRING, 

319 number=4, 

320 ) 

321 response_status_code: int = proto.Field( 

322 proto.INT32, 

323 number=5, 

324 ) 

325 remote_ip: str = proto.Field( 

326 proto.STRING, 

327 number=6, 

328 ) 

329 

330 

331class SourceLocation(proto.Message): 

332 r"""Indicates a location in the source code of the service for which 

333 errors are reported. ``functionName`` must be provided by the 

334 application when reporting an error, unless the error report 

335 contains a ``message`` with a supported exception stack trace. All 

336 fields are optional for the later case. 

337 

338 Attributes: 

339 file_path (str): 

340 The source code filename, which can include a 

341 truncated relative path, or a full path from a 

342 production machine. 

343 line_number (int): 

344 1-based. 0 indicates that the line number is 

345 unknown. 

346 function_name (str): 

347 Human-readable name of a function or method. The value can 

348 include optional context like the class or package name. For 

349 example, ``my.package.MyClass.method`` in case of Java. 

350 """ 

351 

352 file_path: str = proto.Field( 

353 proto.STRING, 

354 number=1, 

355 ) 

356 line_number: int = proto.Field( 

357 proto.INT32, 

358 number=2, 

359 ) 

360 function_name: str = proto.Field( 

361 proto.STRING, 

362 number=4, 

363 ) 

364 

365 

366__all__ = tuple(sorted(__protobuf__.manifest))