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.

log.write removed option.resource.labels #1167

@redso-mankit

Description

@redso-mankit

Environment details

  • OS: Mac
  • Node.js version: v14.18.0
  • npm version: 6.14.15
  • @google-cloud/logging version: 9.6.1

Steps to reproduce

Using resource in options log.write(entry, { resource: { foo: 'bar' } })

const { Logging } = require('@google-cloud/logging');

const projectId = 'test';
const logName = 'request_log';

const metadata = {
  severity: 'INFO',
  labels: {
    foo: 'bar',
  },
};
const message = 'this is log message'

const logging = new Logging({ projectId: 'test' });
const log = logging.log(logName);
const entry = log.entry(metadata, message);

const resource = {
  type: 'k8s_container',
  labels: {
    pod_name: 'api',
    project_id: projectId,
    location: 'asia-east2-a',
    cluster_name: 'development',
    namespace_name: 'dev',
    container_name: 'api-xxxxxxxxxx-yyyyy'
  }
}

log.write(entry, { resource });

the provided resource becomes { type: 'k8s_container', labels: {} }

seems snakecaseKeys in utils/log-common.ts removed the correct labels

await log.getOrSetResource({
  resource: {
    type: 'k8s_container',
    labels: {
      pod_name: 'api',
      project_id: 'test',
      location: 'asia-east2-a',
      cluster_name: 'development',
      namespace_name: 'dev',
      container_name: 'api-xxxxxxxxxx-yyyyy'
    }
  }
})

{ type: 'k8s_container', labels: {} }

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the googleapis/nodejs-logging API.lang: nodejsIssues specific to JavaScript or TypeScript.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