class Google::Cloud::ErrorReporting::Service
@private Represents the gRPC Error Reporting service, including all the
API methods.
Attributes
credentials[RW]
host[RW]
mocked_error_reporting[RW]
project[RW]
timeout[RW]
Public Class Methods
new(project, credentials, timeout: nil, host: nil)
click to toggle source
Creates a new Service
instance.
# File lib/google/cloud/error_reporting/service.rb, line 35 def initialize project, credentials, timeout: nil, host: nil @project = project @credentials = credentials @timeout = timeout @host = host end
Public Instance Methods
error_reporting()
click to toggle source
# File lib/google/cloud/error_reporting/service.rb, line 42 def error_reporting return mocked_error_reporting if mocked_error_reporting @error_reporting ||= \ V1beta1::ReportErrorsService::Client.new do |config| config.credentials = credentials if credentials config.timeout = timeout if timeout config.endpoint = host if host config.lib_name = "gccl" config.lib_version = Google::Cloud::ErrorReporting::VERSION end end
report(error_event)
click to toggle source
Report a {Google::Cloud::ErrorReporting::ErrorEvent} to Stackdriver Error Reporting service.
@example
require "google/cloud/error_reporting" error_reporting = Google::Cloud::ErrorReporting.new error_event = error_reporting.error_event "Error Message with Backtrace", event_time: Time.now, service_name: "my_app_name", service_version: "v8", user: "johndoh", file_path: "MyController.rb", line_number: 123, function_name: "index" error_reporting.report error_event
# File lib/google/cloud/error_reporting/service.rb, line 75 def report error_event if error_event.message.nil? || error_event.message.empty? raise ArgumentError, "Cannot report empty message" end error_event_grpc = error_event.to_grpc error_reporting.report_error_event project_name: project_path, event: error_event_grpc end
Protected Instance Methods
project_path()
click to toggle source
# File lib/google/cloud/error_reporting/service.rb, line 87 def project_path V1beta1::ReportErrorsService::Paths.project_path project: project end