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

logging write() calls metadata every time #353

@wyardley

Description

@wyardley

Environment details

  • OS: Alpine Linux 3.6-3.8
  • Node.js version: 8.12
  • npm version: 6.4.1
  • @google-cloud/logging version: current

Steps to reproduce

  1. Make lots of logging write calls
  2. getGKEDescriptor() is called every time
    export async function getGKEDescriptor() {
    // Stackdriver Logging Monitored Resource for 'container' requires
    // cluster_name and namespace_id fields. Note that these *need* to be
    // snake_case. The namespace_id is not easily available from inside the
    // container, but we can get the namespace_name. Logging has been using the
    // namespace_name in place of namespace_id for a while now. Log correlation
    // with metrics may not necessarily work however.
    //
    const resp = await gcpMetadata.instance('attributes/cluster-name');
    which creates two or more DNS requests for each log write, as well as http request(s) to metadata, e.g.,
01:01:49.538637 IP 10.53.5.5.53309 > 10.53.57.8.domain: 60715+ A? metadata.google.internal.google.internal. (58)
        0x0000:  4500 0056 141a 4000 3f11 d506 0a35 0505  E..V..@.?....5..
        0x0010:  0a35 3908 d03d 0035 0042 68af ed2b 0100  .59..=.5.Bh..+..
        0x0020:  0001 0000 0000 0000 086d 6574 6164 6174  .........metadat
        0x0030:  6106 676f 6f67 6c65 0869 6e74 6572 6e61  a.google.interna
        0x0040:  6c06 676f 6f67 6c65 0869 6e74 6572 6e61  l.google.interna
        0x0050:  6c00 0001 0001                           l.....
01:01:49.538657 IP 10.53.5.5.53309 > 10.53.57.8.domain: 61057+ AAAA? metadata.google.internal.google.internal. (58)
        0x0000:  4500 0056 141b 4000 3f11 d505 0a35 0505  E..V..@.?....5..
        0x0010:  0a35 3908 d03d 0035 0042 673e ee81 0100  .59..=.5.Bg>....
        0x0020:  0001 0000 0000 0000 086d 6574 6164 6174  .........metadat
        0x0030:  6106 676f 6f67 6c65 0869 6e74 6572 6e61  a.google.interna
        0x0040:  6c06 676f 6f67 6c65 0869 6e74 6572 6e61  l.google.interna
        0x0050:  6c00 001c 0001                           l.....
[pid 1627782] write(36, "GET /computeMetadata/v1/instance/attributes/cluster-name HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nMetadata-Flavor: Google\r\nUser-Agent: axios/0.18.0\r\nHost: metadata.google.internal\r\nConnection: close\r\n\r\n", 214) = 214

Presumably the project, cluster name, etc., are unlikely to change, so it would seem more efficient to get / cache this information when the library is instantiated somehow? I'm not sure if https://www.npmjs.com/package/@google-cloud/logging-winston does things any differently. We do have a wrapper around this which I believe does at least some buffering, but still, this creates a lot of overhead.

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: loggingIssues related to the googleapis/nodejs-logging API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to 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