Title: | Send Error Reports to the Google Error Reporting Service API |
---|---|
Description: | Send error reports to the Google Error Reporting service <https://cloud.google.com/error-reporting/> and view errors and assign error status in the Google Error Reporting user interface. |
Authors: | ixpantia, SRL [cph], Frans van Dunné [cre, aut] , Andrea Vargas [ctb] |
Maintainer: | Frans van Dunné <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.4 |
Built: | 2024-10-28 22:19:01 UTC |
Source: | https://github.com/ixpantia/googleerrorreportingr |
Format messages before sending to Google Error Reporting
config_message(message, req, status_code)
config_message(message, req, status_code)
message |
Error message returned by validation |
req |
Request object used by plumber |
status_code |
Valid HTTP status code |
formatted message
## Not run: your_function_call <- tryCatch( your_function(), error = function(e) { message$message <- as.character(e) googleErrorReportingR::report_error(message) message <- config_message(message, req, "401") stop("Error", call. = FALSE) }) ## End(Not run)
## Not run: your_function_call <- tryCatch( your_function(), error = function(e) { message$message <- as.character(e) googleErrorReportingR::report_error(message) message <- config_message(message, req, "401") stop("Error", call. = FALSE) }) ## End(Not run)
Format Error Message for Google Error Reporting
format_error_message( message = "Error description", service = "My Service", version = "0.0.1", method = "GET", url = "https://example.com", user_agent = "", referrer = "", response_status_code = "500", remote_ip = "192.178.0.0.1", user_id = "UserID", filepath = "/", line_number = 0, function_name = "my_function" )
format_error_message( message = "Error description", service = "My Service", version = "0.0.1", method = "GET", url = "https://example.com", user_agent = "", referrer = "", response_status_code = "500", remote_ip = "192.178.0.0.1", user_id = "UserID", filepath = "/", line_number = 0, function_name = "my_function" )
message |
the error message you want in the logs |
service |
the name of your service |
version |
the version of the service |
method |
the http method used for hte call |
url |
hte unique resource identifier that was called |
user_agent |
the user agente identifier |
referrer |
the referrer to the service |
response_status_code |
http response code |
remote_ip |
remote ip |
user_id |
user id |
filepath |
filepath of the code where the error originates |
line_number |
line number where the error originates |
function_name |
function name where the error originates |
message object, a list to be formated as JSON in the error report body
## Not run: message <- format_error_message() message$serviceContext$service <- "A demo service" message$serviceContext$version <- "v0.3.4" ## End(Not run)
## Not run: message <- format_error_message() message$serviceContext$service <- "A demo service" message$serviceContext$version <- "v0.3.4" ## End(Not run)
Get list of errors from Google Error Reporting
list_errors(project_id, api_key)
list_errors(project_id, api_key)
project_id |
the project ID of your project on GCP |
api_key |
an API key with permissions to write to Google Error Reporting |
No return, we focus on side effect
Report error to Google Error Reporting
report_error(message, project_id = NULL, api_key = NULL)
report_error(message, project_id = NULL, api_key = NULL)
message |
the error report to be written out to the |
project_id |
the project id where you want to monitor the error reports |
api_key |
the google API key with authorisation to write to the Google Error Reporting API |
No return, we focus on side effect
## Not run: report_error(project_id, api_key, message) #If you have set the environmental variables "PROJECT_ID" and #"ERROR_REPORTING_API_KEY" then you can make shorter calls like so report_error(message) ## End(Not run)
## Not run: report_error(project_id, api_key, message) #If you have set the environmental variables "PROJECT_ID" and #"ERROR_REPORTING_API_KEY" then you can make shorter calls like so report_error(message) ## End(Not run)