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 ⇒ String
Find default project_id from
ERROR_REPORTING_RPOJECT
,GOOGLE_CLOUD_PROJECT
,GCLOUD_PROJECT
environment varaibles, or query from GCE meta service. -
.default_service_name ⇒ String
Find default service_name from
ERROR_REPORTING_SERVICE
,GAE_SERVICE
environment Variables, or just "ruby". -
.default_service_version ⇒ String
Find default service_version from
ERROR_REPORTING_VERSION
orGAE_VERSION
environment varaibles.
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 ⇒ String
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 ⇒ String
Find default project_id from ERROR_REPORTING_RPOJECT
,
GOOGLE_CLOUD_PROJECT
, GCLOUD_PROJECT
environment varaibles, or
query from GCE meta service.
53 54 55 56 57 |
# File 'lib/google/cloud/error_reporting/project.rb', line 53 def self.default_project ENV["ERROR_REPORTING_PROJECT"] || ENV["GOOGLE_CLOUD_PROJECT"] || Google::Cloud.env.project_id end |
.default_service_name ⇒ String
Find default service_name from ERROR_REPORTING_SERVICE
,
GAE_SERVICE
environment Variables, or just "ruby".
65 66 67 68 69 |
# File 'lib/google/cloud/error_reporting/project.rb', line 65 def self.default_service_name ENV["ERROR_REPORTING_SERVICE"] || Google::Cloud.env.app_engine_service_id || "ruby" end |
.default_service_version ⇒ String
Find default service_version from ERROR_REPORTING_VERSION
or
GAE_VERSION
environment varaibles.
77 78 79 80 |
# File 'lib/google/cloud/error_reporting/project.rb', line 77 def self.default_service_version ENV["ERROR_REPORTING_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.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/google/cloud/error_reporting/project.rb', line 207 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 ⇒ String
Get the name of current project_id from underneath gRPC Service object.
105 106 107 |
# File 'lib/google/cloud/error_reporting/project.rb', line 105 def project service.project end |
#report(*args, &block) ⇒ Object
Report a ErrorEvent to Stackdriver Error Reporting service.
121 122 123 |
# File 'lib/google/cloud/error_reporting/project.rb', line 121 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.
149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/google/cloud/error_reporting/project.rb', line 149 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 |