Skip to content

Commit

Permalink
Merge branch 'main' into renovate/actions-setup-node-4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cindy-peng authored Nov 10, 2023
2 parents 224d540 + 555c33e commit 398fd58
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
10 changes: 5 additions & 5 deletions .readme-partials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ body: |-
### Error Reporting
Any `Error` objects you log at severity `error` or higher can automatically be picked up by [Cloud Error Reporting][error-reporting] if you have specified a `serviceContext.service` when instantiating a `LoggingBunyan` instance:
Any `Error` objects you log at severity `error` or higher can automatically be picked up by [Cloud Error Reporting](https://cloud.google.com/error-reporting/) if you have specified a `serviceContext.service` when instantiating a `LoggingBunyan` instance:
```javascript
const loggingBunyan = new LoggingBunyan({
Expand All @@ -76,14 +76,14 @@ body: |-
It is an error to specify a `serviceContext` but not specify `serviceContext.service`.
Make sure to add logs to your [uncaught exception][uncaught] and [unhandled rejection][unhandled] handlers if you want to see those errors too.
Make sure to add logs to your [uncaught exception](https://nodejs.org/api/process.html#process_event_uncaughtexception) and [unhandled rejection](https://nodejs.org/api/process.html#process_event_unhandledrejection) handlers if you want to see those errors too.
You may also want to see the [@google-cloud/error-reporting][@google-cloud/error-reporting] module which provides direct access to the Error Reporting API.
### LogEntry Labels
If the bunyan log record contains a label property where all the values are strings, we automatically promote that
property to be the [`LogEntry.labels`](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry) value rather
property to be the [`LogEntry.labels`](https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.v2#logentry) value rather
than being one of the properties in the `payload` fields. This makes it easier to filter the logs in the UI using the labels.
```javascript
Expand All @@ -94,7 +94,7 @@ body: |-
### Formatting Request Logs
To format your request logs you can provide a `httpRequest` property on the bunyan metadata you provide along with the log message. We will treat this as the [`HttpRequest`][http-request-message] message and Cloud logging will show this as a request log. Example:
To format your request logs you can provide a `httpRequest` property on the bunyan metadata you provide along with the log message. We will treat this as the [`HttpRequest`](https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.type#google.logging.type.HttpRequest) message and Cloud logging will show this as a request log. Example:
![Request Log Example](https://raw.githubusercontent.com/googleapis/nodejs-logging-bunyan/master/doc/images/request-log.png)
Expand All @@ -110,7 +110,7 @@ body: |-
}, req.path);
```
The `httpRequest` property must be a properly formatted [`HttpRequest`][http-request-message] message. (Note: the linked protobuf documentation shows `snake_case` property names, but in JavaScript one needs to provide property names in `camelCase`.)
The `httpRequest` property must be a properly formatted [`HttpRequest`](https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.type#google.logging.type.HttpRequest) message. (Note: the linked protobuf documentation shows `snake_case` property names, but in JavaScript one needs to provide property names in `camelCase`.)
### Correlating Logs with Traces
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

[1]: https://www.npmjs.com/package/nodejs-logging-bunyan?activeTab=versions

## [5.0.1](https://github.com/googleapis/nodejs-logging-bunyan/compare/v5.0.0...v5.0.1) (2023-10-30)


### Bug Fixes

* **deps:** Update dependency @google-cloud/logging to v11 ([d740098](https://github.com/googleapis/nodejs-logging-bunyan/commit/d74009850b316d57a686637f3b0242fa72339000))

## [5.0.0](https://github.com/googleapis/nodejs-logging-bunyan/compare/v4.2.2...v5.0.0) (2023-08-10)


Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ startServer();

### Error Reporting

Any `Error` objects you log at severity `error` or higher can automatically be picked up by [Cloud Error Reporting][error-reporting] if you have specified a `serviceContext.service` when instantiating a `LoggingBunyan` instance:
Any `Error` objects you log at severity `error` or higher can automatically be picked up by [Cloud Error Reporting](https://cloud.google.com/error-reporting/) if you have specified a `serviceContext.service` when instantiating a `LoggingBunyan` instance:

```javascript
const loggingBunyan = new LoggingBunyan({
Expand All @@ -158,14 +158,14 @@ const loggingBunyan = new LoggingBunyan({

It is an error to specify a `serviceContext` but not specify `serviceContext.service`.

Make sure to add logs to your [uncaught exception][uncaught] and [unhandled rejection][unhandled] handlers if you want to see those errors too.
Make sure to add logs to your [uncaught exception](https://nodejs.org/api/process.html#process_event_uncaughtexception) and [unhandled rejection](https://nodejs.org/api/process.html#process_event_unhandledrejection) handlers if you want to see those errors too.

You may also want to see the [@google-cloud/error-reporting][@google-cloud/error-reporting] module which provides direct access to the Error Reporting API.

### LogEntry Labels

If the bunyan log record contains a label property where all the values are strings, we automatically promote that
property to be the [`LogEntry.labels`](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry) value rather
property to be the [`LogEntry.labels`](https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.v2#logentry) value rather
than being one of the properties in the `payload` fields. This makes it easier to filter the logs in the UI using the labels.

```javascript
Expand All @@ -176,7 +176,7 @@ All the label values must be strings for this automatic promotion to work. Other

### Formatting Request Logs

To format your request logs you can provide a `httpRequest` property on the bunyan metadata you provide along with the log message. We will treat this as the [`HttpRequest`][http-request-message] message and Cloud logging will show this as a request log. Example:
To format your request logs you can provide a `httpRequest` property on the bunyan metadata you provide along with the log message. We will treat this as the [`HttpRequest`](https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.type#google.logging.type.HttpRequest) message and Cloud logging will show this as a request log. Example:

![Request Log Example](https://raw.githubusercontent.com/googleapis/nodejs-logging-bunyan/master/doc/images/request-log.png)

Expand All @@ -192,7 +192,7 @@ logger.info({
}, req.path);
```

The `httpRequest` property must be a properly formatted [`HttpRequest`][http-request-message] message. (Note: the linked protobuf documentation shows `snake_case` property names, but in JavaScript one needs to provide property names in `camelCase`.)
The `httpRequest` property must be a properly formatted [`HttpRequest`](https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.type#google.logging.type.HttpRequest) message. (Note: the linked protobuf documentation shows `snake_case` property names, but in JavaScript one needs to provide property names in `camelCase`.)

### Correlating Logs with Traces

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@google-cloud/logging-bunyan",
"description": "Cloud Logging stream for Bunyan",
"version": "5.0.0",
"version": "5.0.1",
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "mocha system-test --timeout 600000"
},
"dependencies": {
"@google-cloud/logging-bunyan": "^5.0.0",
"@google-cloud/logging-bunyan": "^5.0.1",
"bunyan": "^1.8.12",
"express": "^4.16.3",
"yargs": "^16.0.0"
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const LOGGING_SAMPLED_KEY = 'logging.googleapis.com/trace_sampled';
* Using release-please annotations to update DEFAULT_INSTRUMENTATION_VERSION with latest version.
* See https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files
*/
export const NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION = '5.0.0'; // {x-release-please-version}
export const NODEJS_BUNYAN_DEFAULT_LIBRARY_VERSION = '5.0.1'; // {x-release-please-version}

/**
* Gets the current fully qualified trace ID when available from the
Expand Down Expand Up @@ -114,7 +114,8 @@ export function getCurrentTraceFromAgent() {
* automatically, but you may optionally specify a specific monitored
* resource. For more information, see the
* [official documentation]{@link
* https://cloud.google.com/logging/docs/api/reference/rest/v2/MonitoredResource}
* https://cloud.google.com/monitoring/api/ref_v3/rpc/google.api#google.api.MonitoredResource}
*
* @param {object} [options.serviceContext] For logged errors, we provide this
* as the service context. For more information see
* [this guide]{@link
Expand Down Expand Up @@ -283,7 +284,7 @@ export class LoggingBunyan extends Writable {

// If the record contains a httpRequest property, provide it on the entry
// metadata. This allows Stackdriver to use request log formatting.
// https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#HttpRequest
// https://cloud.google.com/logging/docs/reference/v2/rpc/google.logging.type#google.logging.type.HttpRequest
// Note that the httpRequest field must properly validate as a HttpRequest
// proto message, or the log entry would be rejected by the API. We do no
// validation here.
Expand Down

0 comments on commit 398fd58

Please sign in to comment.