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 Error Reporting service.
Google::Cloud::ErrorReporting::ErrorEvent is able to be transformed
into the Google::Cloud::ErrorReporting::V1beta1::ReportedErrorEvent
gRPC structure. Once an error event is reported, the GCP
Error Reporting 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::Cloud::ErrorReporting::V1beta1::ReportedErrorEvent
object.
Instance Method Summary collapse
-
#to_grpc ⇒ Google::Cloud::ErrorReporting::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.
48 49 50 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 48 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.
107 108 109 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 107 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.
117 118 119 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 117 def function_name @function_name end |
#http_method ⇒ Object
The type of HTTP request, such as GET, POST, etc.
71 72 73 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 71 def http_method @http_method end |
#http_referrer ⇒ Object
The referrer information that is provided with the request.
83 84 85 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 83 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.
93 94 95 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 93 def http_remote_ip @http_remote_ip end |
#http_status ⇒ Object
The HTTP response status code for the request.
87 88 89 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 87 def http_status @http_status end |
#http_url ⇒ Object
The URL of the request.
75 76 77 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 75 def http_url @http_url end |
#http_user_agent ⇒ Object
The user agent information that is provided with the request.
79 80 81 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 79 def http_user_agent @http_user_agent end |
#line_number ⇒ Object
1-based. 0 indicates that the line number is unknown.
111 112 113 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 111 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.
55 56 57 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 55 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.
62 63 64 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 62 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.
67 68 69 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 67 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.
102 103 104 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 102 def user @user end |
Class Method Details
.from_exception(exception) ⇒ ErrorEvent
Construct an ErrorEvent object based on a given exception.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 210 def self.from_exception exception backtrace = exception.backtrace = "#{exception.class}: #{exception.}" if !backtrace.nil? && !backtrace.empty? = "#{}\n\t" + backtrace.join("\n\t") file_path, line_number, function_name = backtrace.first.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::Cloud::ErrorReporting::V1beta1::ReportedErrorEvent
object.
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 130 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 ⇒ Google::Cloud::ErrorReporting::V1beta1::ReportedErrorEvent
Convert ErrorEvent object to gRPC struct.
234 235 236 237 238 239 240 241 |
# File 'lib/google/cloud/error_reporting/error_event.rb', line 234 def to_grpc Google::Cloud::ErrorReporting::V1beta1::ReportedErrorEvent.new( event_time: event_time_grpc, message: .to_s, service_context: service_context_grpc, context: error_context_grpc ) end |