Skip to content

Documentation Fix : logging.log.entry metadata has wrong object format #1996

Description

@eighteyes

Overview

Documentation Object Inconsistencies

Working

https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/0.7.0/logging
Describes the entry metadata.

var resource = {
 type: 'gce_instance',
 labels: {
   zone: 'global',
   instance_id: '3'
 }
};

Breaking

https://googlecloudplatform.github.io/google-cloud-node/#/docs/logging/0.7.0/logging/entry
Wraps it in a resource key.

var metadata = {
  resource: {
    type: 'gce_instance',
    labels: {
      zone: 'global',
      instance_id: '3'
    }
  }
};

Reproduction

 var metadata = {
  resource: {
    type: 'gce_instance',
    labels: {
      zone: 'global',
      instance_id: '3'
    }
  }
};
  var logFn = logging.log('sysout');
  var entry = logFn.entry(metadata, {
     msg: 'abc123'
  });
  logFn.write(entry, cb)

Throws the following protobuf error

Uncaught Error: .google.api.MonitoredResource#resource is not a field: undefined

Resolution

Unwrapping the resource key from the field seems to be key here. This form also exists in the logging.entry doc, but I'm not sure what is intended there.

Activity

  1. added
    priority: p0Highest priority. Critical issue. P0 implies highest priority.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Feb 27, 2017
  2. callmehiphop commented on Mar 2, 2017

    @callmehiphop
    Contributor

    @stephenplusplus based on #1666 I think that the documentation is correct but code is not working as expected. Can you confirm that we did not intentionally revert those changes at some point?

  3. stephenplusplus commented on Mar 3, 2017

    @stephenplusplus
    Contributor

    Yeah, it is meant to work as shown in the After section of #1666.

    @eighteyes I actually get the opposite behavior that you describe from a fresh install of @google-cloud/[email protected]. Can you try un- and re-installing to be sure you're using the latest version?

  4. eighteyes commented on Mar 6, 2017

    @eighteyes
    Author
  5. stephenplusplus commented on Mar 6, 2017

    @stephenplusplus
    Contributor

    Phew 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the Cloud Logging API.priority: p0Highest priority. Critical issue. P0 implies highest priority.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