Class: Google::Cloud::ErrorReporting::Project
- Inherits:
-
Object
- Object
- Google::Cloud::ErrorReporting::Project
- Defined in:
- lib/google/cloud/error_reporting/project.rb
Overview
Project
Projects are top-level containers in Google Cloud Platform. They store information about billing and authorized users, and they control access to Stackdriver ErrorReporting. Each project has a friendly name and a unique ID. Projects can be created only in the Google Developers Console.
See new
Class Method Summary collapse
-
.default_project_id ⇒ String
(also: default_project)
Find default project_id from the configuration, environment varaibles, or query from GCE meta service.
-
.default_service_name ⇒ String
Find default service_name from the configuration, environment varaibles, or query from GCE meta service, or just "ruby".
-
.default_service_version ⇒ String
Find default service_version from the configuration, environment varaibles, or query from GCE meta service.
Instance Method Summary collapse
-
#error_event(message = nil, service_name: nil, service_version: nil, event_time: nil, user: nil, file_path: nil, line_number: nil, function_name: nil) ⇒ ErrorEvent
Create a new ErrorEvent instance with given parameters.
-
#project_id ⇒ String
(also: #project)
Get the name of current project_id from underneath gRPC Service object.
-
#report(*args, &block) ⇒ Object
Report a ErrorEvent to Stackdriver Error Reporting service.
-
#report_exception(exception, service_name: nil, service_version: nil) {|error_event| ... } ⇒ Object
Create a ErrorEvent from the given exception, and report this ErrorEvent to Stackdriver Error Reporting service.
Class Method Details
.default_project_id ⇒ String Also known as: default_project
Find default project_id from the configuration, environment varaibles, or query from GCE meta service.
51 52 53 54 55 |
# File 'lib/google/cloud/error_reporting/project.rb', line 51 def self.default_project_id Google::Cloud.configure.error_reporting.project_id || Google::Cloud.configure.project_id || Google::Cloud.env.project_id end |
.default_service_name ⇒ String
Find default service_name from the configuration, environment varaibles, or query from GCE meta service, or just "ruby".
66 67 68 69 70 71 |
# File 'lib/google/cloud/error_reporting/project.rb', line 66 def self.default_service_name Google::Cloud.configure.error_reporting.service_name || Google::Cloud.configure.service_name || Google::Cloud.env.app_engine_service_id || "ruby" end |
.default_service_version ⇒ String
Find default service_version from the configuration, environment varaibles, or query from GCE meta service.
79 80 81 82 83 |
# File 'lib/google/cloud/error_reporting/project.rb', line 79 def self.default_service_version Google::Cloud.configure.error_reporting.service_version || Google::Cloud.configure.service_version || Google::Cloud.env.app_engine_service_version end |
Instance Method Details
#error_event(message = nil, service_name: nil, service_version: nil, event_time: nil, user: nil, file_path: nil, line_number: nil, function_name: nil) ⇒ ErrorEvent
Create a new ErrorEvent instance with given parameters.
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/google/cloud/error_reporting/project.rb', line 211 def error_event = nil, service_name: nil, service_version: nil, event_time: nil, user: nil, file_path: nil, line_number: nil, function_name: nil ErrorEvent.new.tap do |e| e. = e.event_time = event_time e.service_name = service_name || self.class.default_service_name e.service_version = service_version || self.class.default_service_version e.user = user e.file_path = file_path e.line_number = line_number e.function_name = function_name end end |
#project_id ⇒ String Also known as: project
Get the name of current project_id from underneath gRPC Service object.
108 109 110 |
# File 'lib/google/cloud/error_reporting/project.rb', line 108 def project_id service.project end |
#report(*args, &block) ⇒ Object
Report a ErrorEvent to Stackdriver Error Reporting service.
125 126 127 |
# File 'lib/google/cloud/error_reporting/project.rb', line 125 def report *args, &block service.report *args, &block end |
#report_exception(exception, service_name: nil, service_version: nil) {|error_event| ... } ⇒ Object
Create a ErrorEvent from the given exception, and report this ErrorEvent to Stackdriver Error Reporting service.
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/google/cloud/error_reporting/project.rb', line 153 def report_exception exception, service_name: nil, service_version: nil error_event = ErrorEvent.from_exception exception error_event.service_name = service_name || self.class.default_service_name error_event.service_version = service_version || self.class.default_service_version yield error_event if block_given? report error_event end |