forked from ixpantia/googleErrorReportingR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
103 lines (75 loc) · 2.77 KB
/
README.Rmd
File metadata and controls
103 lines (75 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
out.width = "100%"
)
library(jsonlite)
library(lubridate)
```
<!-- badges: start -->
# <a><img src="https://storage.googleapis.com/ixplorer/googleErrorReportingR.svg" align="right" width="30%"></a>
[](https://cran.r-project.org/package=googleErrorReportingR)
<!-- badges: end -->
# 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](https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.events/report)
method.
## Installation
You can install the development version of googleErrorReportingR from
[GitHub](https://github.com/) with:
``` r
# 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:
```{r, eval= FALSE}
report_error(project_id, api_key, message)
```
We can call
```{r, eval= FALSE}
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:
```{r example}
library(googleErrorReportingR)
message <- format_error_message()
message$serviceContext$service <- "A demo service"
message$serviceContext$version <- "v0.3.4"
googleErrorReportingR::report_error(message)
```
If your project-id and api_key are set up correctly the message above will
appear in the Google Error Reporting UI as follows:

## 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.
```{r}
toJSON(message, auto_unbox = TRUE, pretty = TRUE )
```
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.