Class: Google::Cloud::ErrorReporting::ErrorEvent
- Inherits:
-
Object
- Object
- Google::Cloud::ErrorReporting::ErrorEvent
- Defined in:
- lib/google/cloud/error_reporting/error_event.rb
Overview
ErrorEvent
An individual error event to report to Stackdriver Error Reporting service.
Google::Cloud::ErrorReporting::ErrorEvent is able to be transformed into Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent gRPC structure. Once an error event is reported, the GCP Stackdriver ErrorReporting service is able to parse the message and backtrace, then group the error events by content.
Instance Attribute Summary collapse
-
#event_time ⇒ Object
Time when the event occurred.
-
#file_path ⇒ Object
The source code filename, which can include a truncated relative path, or a full path from a production machine.
-
#function_name ⇒ Object
Human-readable name of a function or method.
-
#http_method ⇒ Object
The type of HTTP request, such as GET, POST, etc.
-
#http_referrer ⇒ Object
The referrer information that is provided with the request.
-
#http_remote_ip ⇒ Object
The IP address from which the request originated.
-
#http_status ⇒ Object
The HTTP response status code for the request.
-
#http_url ⇒ Object
The URL of the request.
-
#http_user_agent ⇒ Object
The user agent information that is provided with the request.
-
#line_number ⇒ Object
1-based.
-
#message ⇒ Object
A message describing the error.
-
#service_name ⇒ Object
An identifier of the service, such as the name of the executable, job, or Google App Engine service name.
-
#service_version ⇒ Object
Represents the source code version that the developer provided, which could represent a version label or a Git SHA-1 hash, for example.
-
#user ⇒ Object
The user who caused or was affected by the crash.
Class Method Summary collapse
-
.from_exception(exception) ⇒ ErrorEvent
Construct an ErrorEvent object based on a given exception.
-
.from_grpc(grpc) ⇒ ErrorEvent
Build a new ErrorEvent from a Google::Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent object.
Instance Method Summary collapse
-
#to_grpc ⇒ Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent
Convert ErrorEvent object to gRPC struct.
Instance Attribute Details
#event_time ⇒ Object
Time when the event occurred. If not provided, the time when the event was received by the Error Reporting system will be used.
49 50 51 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 49 def event_time @event_time end |
#file_path ⇒ Object
The source code filename, which can include a truncated relative path, or a full path from a production machine.
108 109 110 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 108 def file_path @file_path end |
#function_name ⇒ Object
Human-readable name of a function or method. The value can include optional context like the class or package name. For example, my.package.MyClass.method in case of Java.
118 119 120 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 118 def function_name @function_name end |
#http_method ⇒ Object
The type of HTTP request, such as GET, POST, etc.
72 73 74 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 72 def http_method @http_method end |
#http_referrer ⇒ Object
The referrer information that is provided with the request.
84 85 86 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 84 def http_referrer @http_referrer end |
#http_remote_ip ⇒ Object
The IP address from which the request originated. This can be IPv4, IPv6, or a token which is derived from the IP address, depending on the data that has been provided in the error report.
94 95 96 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 94 def http_remote_ip @http_remote_ip end |
#http_status ⇒ Object
The HTTP response status code for the request.
88 89 90 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 88 def http_status @http_status end |
#http_url ⇒ Object
The URL of the request.
76 77 78 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 76 def http_url @http_url end |
#http_user_agent ⇒ Object
The user agent information that is provided with the request.
80 81 82 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 80 def http_user_agent @http_user_agent end |
#line_number ⇒ Object
1-based. 0 indicates that the line number is unknown.
112 113 114 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 112 def line_number @line_number end |
#message ⇒ Object
A message describing the error. The message can contain an exception stack in one of the supported programming languages and formats. In that case, the message is parsed and detailed exception information is returned when retrieving the error event again.
56 57 58 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 56 def @message end |
#service_name ⇒ Object
An identifier of the service, such as the name of the executable, job, or Google App Engine service name. This field is expected to have a low number of values that are relatively stable over time, as opposed to version, which can be changed whenever new code is deployed.
63 64 65 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 63 def service_name @service_name end |
#service_version ⇒ Object
Represents the source code version that the developer provided, which could represent a version label or a Git SHA-1 hash, for example.
68 69 70 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 68 def service_version @service_version end |
#user ⇒ Object
The user who caused or was affected by the crash. This can be a user ID, an email address, or an arbitrary token that uniquely identifies the user. When sending an error report, leave this field empty if the user was not logged in. In this case the Error Reporting system will use other data, such as remote IP address, to distinguish affected users. See affectedUsersCount in ErrorGroupStats.
103 104 105 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 103 def user @user end |
Class Method Details
.from_exception(exception) ⇒ ErrorEvent
Construct an ErrorEvent object based on a given exception.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 214 def self.from_exception exception backtrace = exception.backtrace = exception. unless backtrace.nil? error_location = backtrace.first = "#{error_location}: #{} (#{exception.class})\n\t" + backtrace.drop(1).join("\n\t") file_path, line_number, function_name = error_location.split(":") function_name = function_name.to_s[/`(.*)'/, 1] end new.tap do |e| e. = e.file_path = file_path e.line_number = line_number.to_i e.function_name = function_name end end |
.from_grpc(grpc) ⇒ ErrorEvent
Build a new ErrorEvent from a Google::Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent object.
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 134 def self.from_grpc grpc return new if grpc.nil? new.tap do |event| event.event_time = grpc.event_time event. = grpc. extract_service_context event, grpc.service_context extract_error_context event, grpc.context end end |
Instance Method Details
#to_grpc ⇒ Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent
Convert ErrorEvent object to gRPC struct.
240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 240 def to_grpc error_event_hash = { event_time: event_time_hash, message: , service_context: service_context_hash, context: error_context_hash }.delete_if { |_, v| v.nil? } grpc_class = Devtools::Clouderrorreporting::V1beta1::ReportedErrorEvent grpc_class.decode_json error_event_hash.to_json end |