MyNixOS website logo
Description

Send Error Reports to the Google Error Reporting Service API.

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.

CRANstatus

googleErrorReportingR

This is an R wrapper for the Google Cloud Platform Error Reporting API. It uses the Error Reporting API as defined in the projects.events.report method.

Installation

You can install the development version of googleErrorReportingR from GitHub with:

# install.packages("devtools")
devtools::install_github("ixpantia/googleErrorReportingR")

Usage

Before you start, please set up a file called .Renviron that contains the following line.

PROJECT_ID=<your gcp project id>
ERROR_REPORTING_API_KEY=<your api key>

If you are running a session, then restart your R session so that the environmental variables are read.

You can pass on the project_id and api_key to the function call directely, but since we typically use this many time in one code-base we default to the values in the environmental variables so that instead of:

report_error(project_id, api_key, message)

We can call

report_error(message)

and put the effort in defining the error message at each location in the code that we want to monitor.

the following is a basic example of usage:

library(googleErrorReportingR)

message <- format_error_message()

message$serviceContext$service <- "A demo service"
message$serviceContext$version <- "v0.3.4"

googleErrorReportingR::report_error(message)
#> Response [https://clouderrorreporting.googleapis.com/v1beta1/projects/infraestructura-pruebas/events:report?key=AIzaSyBCaoUQLO64yHmHt7CagO39V0IFGA86hMI]
#>   Date: 2022-08-21 01:57
#>   Status: 200
#>   Content-Type: application/json; charset=UTF-8
#>   Size: 3 B
#> {}

If your project-id and api_key are set up correctly the message above will appear in the Google Error Reporting UI as follows:

Screenshot of the message as listed in the Google Error ReportingUI

Adding details

Note that the message we are sending, once we convert the list to the json body as required by the API, contains all the information elements that we can add to the message.

toJSON(message, auto_unbox = TRUE, pretty = TRUE )
#> {
#>   "message": "Error description",
#>   "serviceContext": {
#>     "service": "A demo service",
#>     "version": "v0.3.4"
#>   },
#>   "context": {
#>     "httpRequest": {
#>       "method": "GET",
#>       "url": "https://example.com",
#>       "userAgent": "",
#>       "referrer": "",
#>       "responseStatusCode": "500",
#>       "remoteIp": "192.178.0.0.1"
#>     },
#>     "user": "UserID",
#>     "reportLocation": {
#>       "filePath": "/",
#>       "lineNumber": 0,
#>       "functionName": "my_function"
#>     }
#>   }
#> }

Please read the vignette for further details on how to configure each and everyone of them.

Roadmap

We are working on the next version of googleErrorReportingR to include the use of the list endpoint.

Metadata

Version

0.0.4

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows