You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the README file:
* Removed documentation on automatically handling
uncaughtExceptions since that logic no longer exists in the
code.
* Removed the statement saying that this project is not an
official Google project.
* Added clarity to what configuration is needed in different
environments.
* Removed an invalid reference to the Stackdriver Trace agent
for Node.js.
* Did some refactoring to make the documentation easier to read.
Copy file name to clipboardExpand all lines: packages/error-reporting/README.md
+32-25Lines changed: 32 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
-
# Node.js module for Stackdriver Error Reporting
1
+
# Stackdriver Error Reporting for Node.js
2
2
3
3
[![NPM Version][npm-image]][npm-url]
4
4
[![Known Vulnerabilities][snyk-image]][snyk-url]
5
5
6
-
> **This is not an official Google product.** This module is experimental and may not be ready for use.
6
+
> This module is experimental, and should be used by early adopters.
7
7
> This module uses APIs that may be undocumented and are subject to change without notice.
8
8
9
9
This module provides Stackdriver Error Reporting support for Node.js applications.
@@ -16,11 +16,12 @@ applications running in almost any environment. Here's an introductory video:
16
16
## Prerequisites
17
17
18
18
1. Your application needs to use Node.js version 4.x or greater.
19
-
1. You need a [Google Cloud project](https://console.cloud.google.com). Your application can run anywhere, but errors are reported to a particular project.
20
-
1.[Enable the Stackdriver Error Reporting API](https://console.cloud.google.com/apis/api/clouderrorreporting.googleapis.com/overview) for your project.
21
-
1. The module will only send errors when the `NODE_ENV` environment variable is
19
+
2. You need a [Google Cloud project](https://console.cloud.google.com). Your application can run anywhere, but errors are reported to a particular project.
20
+
3.[Enable the Stackdriver Error Reporting API](https://console.cloud.google.com/apis/api/clouderrorreporting.googleapis.com/overview) for your project.
21
+
22
+
**Note:** The module will only send errors when the `NODE_ENV` environment variable is
22
23
set to `production` or the `ignoreEnvironmentCheck` property given in the
23
-
runtime configuration object is set to `true`.
24
+
runtime configuration object is set to `true`. See the [Configuration](#configuration) section for more details.
24
25
25
26
## Quick Start
26
27
@@ -33,7 +34,7 @@ runtime configuration object is set to `true`.
33
34
npm install --save @google-cloud/error-reporting
34
35
```
35
36
36
-
2.**Instrument your application:**
37
+
2.**Require the module:**
37
38
38
39
```js
39
40
// Require the library and initialize the error handler
@@ -45,9 +46,13 @@ var errors = require('@google-cloud/error-reporting')({
45
46
errors.report(newError('Something broke!'));
46
47
```
47
48
48
-
-**One may even catch and report application-wide uncaught errors:**
49
-
-*It is recommended to catch uncaughtExceptions for production-deployed applications.*
50
-
- To read more about uncaught exception handling in Node.js and what it means for your application [please click here](https://nodejs.org/api/process.html#process_event_uncaughtexception).
49
+
3.**View reported errors:**
50
+
51
+
Open Stackdriver Error Reporting at https://console.cloud.google.com/errors to view the reported errors.
52
+
53
+
## Catching and Reporting Application-wide Uncaught Errors
54
+
55
+
*It is recommended to catch `uncaughtExceptions` for production-deployed applications.*
51
56
52
57
```js
53
58
var errors =require('@google-cloud/error-reporting')();
Open Stackdriver Error Reporting at https://console.cloud.google.com/errors to view the reported errors.
67
+
More information about uncaught exception handling in Node.js and what it means for your application can be found [here](https://nodejs.org/api/process.html#process_event_uncaughtexception).
65
68
66
69
## Running on Google Cloud Platform
67
70
71
+
All information in this section assumes that the items in the [Prerequisites](#prerequisites) section above have been completed.
72
+
68
73
### Google App Engine Flexible environment
69
74
70
75
If you are using [Google App Engine flexible environment](https://cloud.google.com/appengine/docs/flexible/), you do not have to do any additional configuration.
@@ -84,14 +89,14 @@ Container Engine nodes need to also be created with the `https://www.googleapis.
84
89
If your application is running outside of Google Cloud Platform, such as locally, on-premise, or on another cloud provider, you can still use Stackdriver Errors.
85
90
86
91
1. You will need to specify your project ID when starting the errors agent.
2. You need to provide service account credentials to your application by using one of the three options below:
91
96
* The recommended way is via [Application Default Credentials][app-default-credentials].
92
97
1.[Create a new JSON service account key][service-account].
93
-
1. Copy the key somewhere your application can access it. Be sure not to expose the key publicly.
94
-
1. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the full path to the key. The trace agent will automatically look for this environment variable.
98
+
2. Copy the key somewhere your application can access it. Be sure not to expose the key publicly.
99
+
3. Set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` to the full path to the key. The Error Reporting library will automatically look for this environment variable.
95
100
* If you are running your application on a development machine or test environment where you are using the [`gcloud` command line tools][gcloud-sdk], and are logged using `gcloud beta auth application-default login`, you already have sufficient credentials, and a service account key is not required.
96
101
* Alternatively, you may set the `keyFilename` or `credentials` configuration field to the full path or contents to the key file, respectively. Setting either of these fields will override either setting `GOOGLE_APPLICATION_CREDENTIALS` or logging in using `gcloud`. For example:
97
102
@@ -110,7 +115,7 @@ When running on Google Cloud Platform, we handle these for you automatically.
110
115
111
116
## Configuration
112
117
113
-
The following code snippet lists all available configuration options. All configuration options are optional.
118
+
The following code snippet lists all available configuration options. Except for the `keyFilename` and `credentials` options, all configuration options are optional. Whether or not the `keyFilename` and `credentials` options are required is outlined in the [Running on Google Cloud Platform](#running-on-google-cloud-platform) section above.
114
119
115
120
```js
116
121
var errors =require('@google-cloud/error-reporting')({
@@ -121,10 +126,9 @@ var errors = require('@google-cloud/error-reporting')({
121
126
// of the value of NODE_ENV
122
127
// defaults to false
123
128
ignoreEnvironmentCheck:false,
124
-
// determines if the library will attempt to report uncaught exceptions
125
-
// defaults to true
126
-
reportUncaughtExceptions:true,
127
129
// determines the logging level internal to the library; levels range 0-5
130
+
// where 0 indicates no logs should be reported and 5 indicates all logs
131
+
// should be reported
128
132
// defaults to 2 (warnings)
129
133
logLevel:2,
130
134
serviceContext: {
@@ -140,13 +144,16 @@ var errors = require('@google-cloud/error-reporting')({
140
144
141
145
```js
142
146
var errors =require('@google-cloud/error-reporting')();
147
+
143
148
// Use the error message builder to custom set all message fields
0 commit comments