Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

redirectToStdout: httpRequest.latency should be a string and not an object #685

@jonaaasl

Description

@jonaaasl

Hi, not sure if this is an issue with this lib or with the nodejs-logging lib, so I'll start here.

When running the library with redirectToStdout: true in a container on GCE the httpRequest serializes the trace-property as an object:
Example:

  "httpRequest": {
    "requestUrl": "/healthcheck",
    "requestMethod": "GET",
    "userAgent": "GoogleHC/1.0",
    "responseSize": 2,
    "status": 200,
    "latency": {
      "seconds": 0,
      "nanos": 1000000
    }
  },

The stackdriver-logging-agent errors out (error message as reported here: GoogleCloudPlatform/fluent-plugin-google-cloud#433) on the httpRequest, since it expects the latency to be a string: https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/blob/master/lib/fluent/plugin/out_google_cloud.rb#L1612.

Reference: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#httprequest (according to this the JSON-representation of the latency is a string, not an object).

If the latency-property on the request log is missing the stackdriver-logging-agent ingests it ok.

Environment details

  • OS: cos-stable-101-17162-40-16 (with gcr.io/stackdriver-agents/stackdriver-logging-agent:1.9.8
    and gem 'fluent-plugin-google-cloud' version '0.12.7')
  • Node.js version: v18.15.0
  • npm version: 9.5.0
  • @google-cloud/logging-bunyan version: 4.2.2

Steps to reproduce

  1. Set up an express-app as documented here: https://cloud.google.com/nodejs/docs/reference/logging-bunyan/latest#using-as-an-express-middleware
  2. Set the options {redirectToStdout: true} as recommended here: https://cloud.google.com/nodejs/docs/reference/logging-bunyan/latest#alternative-way-to-ingest-logs-in-google-cloud-managed-environments
  3. Deploy the app in a COS-container.
  4. Call the app with curl so a request-trace is printed to stdout.
  5. Tail the stackdriver-logging-agent logs - there will be error-logs in the logs due to the latency not being a string.
  6. Inspect the cloud-logging console for the sent messages. The messages containing the latency-property will not be parsed but passed inside the jsonPayload with the trace-property removed to the logging. Messages not containing a trace-property will be parsed properly by the stackdriver-logging-agent.

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the googleapis/nodejs-logging-bunyan API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions