Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger breaks on nested objects #1302

Closed
mik115 opened this issue May 10, 2016 · 19 comments
Closed

Logger breaks on nested objects #1302

mik115 opened this issue May 10, 2016 · 19 comments
Assignees
Labels
api: logging Issues related to the Cloud Logging API.

Comments

@mik115
Copy link

mik115 commented May 10, 2016

Hi,
I'm facing a real strange problem:
after updating to 0.32.0 the logging service breaks when a nested object is passed.

es:

   const gcloud = require('gcloud')({
        projectId: 'project_id',
        keyFilename: 'fileKey.json',
    });
    const logging = gcloud.logging();

    const resource = {
         type: 'gae_app',
         labels: {
              module_id: 'Test',
              version_id: '1'
          }
    };

   const log = logging.log('test');

   const entry = log.entry(resource, {
     message: 'messaggio di test',
     data: {
          error: 'no error',
           log: 'test'
      }
   });
   entry.severity = "INFO";
   //code breaks here
   log.write(entry, (err, apiResponse) =>{
       console.log(err, apiResponse);
   });

Thanks in advance

@stephenplusplus stephenplusplus added the api: logging Issues related to the Cloud Logging API. label May 10, 2016
@stephenplusplus
Copy link
Contributor

I'll look right into this, thanks for reporting!

@mik115
Copy link
Author

mik115 commented May 10, 2016

The raised error is:

  /Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2440
                        throw Error(this+"#"+keyOrObj+" is not a field: undefined");
                        ^

Error: .google.protobuf.Value#fields is not a field: undefined
at Error (native)
at MessagePrototype.set (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2440:35)
at MessagePrototype.set (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2434:38)
at Message (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:2363:34)
at ProtoBuf.Reflect.ElementPrototype.verifyValue (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:1877:28)
at new ProtoBuf.Map.Map (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:4894:46)
at ProtoBuf.Reflect.FieldPrototype.verifyValue (/Users/mike/testProject/node_modules/protobufjs/dist/ProtoBuf.js:3427:28)

@stephenplusplus
Copy link
Contributor

PR sent: #1303

Please try it out!

$ npm install --save stephenplusplus/gcloud-node#spp--1302

@mik115
Copy link
Author

mik115 commented May 10, 2016

It works this way!
Great!

@1N50MN14
Copy link

@stephenplusplus didn't this one make it to 0.33.0 on npm? facing the same issue here in my docker container

@stephenplusplus
Copy link
Contributor

It did. Can you paste the code to reproduce and the error?

@1N50MN14
Copy link

1N50MN14 commented May 18, 2016

Yes one sec, ps logging breaks with entries containing boolean fields as well throwing the error:

/src/node_modules/gcloud/node_modules/grpc/node_modules/protobufjs/dist/ProtoBuf.js:2440
                            throw Error(this+"#"+keyOrObj+" is not a field: undefined");
                            ^

Error: .google.protobuf.Value#booleanValue is not a field: undefined

@1N50MN14
Copy link

  bigquery.createDataset(datasetName, function(err, dataset) {
    if (err && err.code !== 409)
      throw err;

    logger.createSink(loggerName, {
      destination: bigquery.dataset(datasetName)
    }, function(err, sink){
      if (err && err.code !== 409)
        throw err;

      console.log('logger service started.');

      log = logger.log('syslogs');

      nc.subscribe('events.logger.error', function(data){
        _syslog(data);
      })
    });

  function _syslog(data)
  {    
    var entry = log.entry({}, data);
    log.write(entry, (err, apiResponse) =>{
           console.log(err, apiResponse);
      });
  }

The data I'm writing looks like this:

{ error: 'Unprocessable Entity',
  message: 'Please check your phone number and try again.',
  code: 422,
  retry: false,
  whoami:
   { image: 'service-sms',
     port: 5000,
     online: true,
     host: '46.101.140.203',
     name: 'sms',
     region: 'local',
     version: '0.0.1',
     dockerhost: '172.17.0.5',
     publichost: '46.101.140.203',
     ports: [ 5000 ] },
  severity: 'INFO',
  origin: 'server',
  method: 'send',
  request: { to: 'xx', text: 'hello world' } }

@stephenplusplus
Copy link
Contributor

Thanks for the details @1N50MN14 -- could you try out #1329?

$ npm install --save stephenplusplus/gcloud-node#spp--1302-2

@1N50MN14
Copy link

Yup, one sec please

@1N50MN14
Copy link

1N50MN14 commented May 18, 2016

It's throwing this error:

/src/node_modules/gcloud/node_modules/grpc/node_modules/protobufjs/dist/ProtoBuf.js:2440
                            throw Error(this+"#"+keyOrObj+" is not a field: undefined");
                            ^

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

(It's also screaming about autoPaginate elsewhere in my code not being a function, wondering if the datastore query API has changed)

@1N50MN14
Copy link

grr sorry my bad sec please

@1N50MN14
Copy link

1N50MN14 commented May 18, 2016

Ok that seemed to have fixed this error! the callback returns error 400 though, I'm not sure why that is

@stephenplusplus
Copy link
Contributor

stephenplusplus commented May 18, 2016

I receive that as well without providing something like the following as the first argument to the entry:

var entry = log.entry({
  type: 'gce_instance',
  labels: {
    zone: 'global',
    instance_id: '3'
  }
}, ...

@1N50MN14
Copy link

yeah that's what I tried to replace, basically I passed my "whoami" object as the resource hence the error I just reported, I will try to place a dummy resource pr your example

@1N50MN14
Copy link

the resource object structure seems to be strict and must contain those specific attributes, I tried to add additional labels that didn't work either; but OK that works for me as I'm storing the "whoami" as a part of the entry

@stephenplusplus
Copy link
Contributor

Cool, thanks for catching this. It's out now under 0.34.0.

@1N50MN14
Copy link

Awesome! Thank you!

Looking at the source of datastore/query.js I see you made some minor modifications there (added info to the cb and got rid of autoPaginate), is this out in 0.34.0 as well?

@stephenplusplus
Copy link
Contributor

Yes, that's included as well. Here are the release notes: https://github.com/GoogleCloudPlatform/gcloud-node/releases/tag/v0.34.0

sofisl pushed a commit that referenced this issue Nov 10, 2022
Source-Link: googleapis/synthtool@b801276
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:ba3f2990fefe465f89834e4c46f847ddb141afa54daa6a1d462928fa679ed143

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
Source-Link: googleapis/synthtool@b801276
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:ba3f2990fefe465f89834e4c46f847ddb141afa54daa6a1d462928fa679ed143

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
Source-Link: googleapis/synthtool@b801276
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:ba3f2990fefe465f89834e4c46f847ddb141afa54daa6a1d462928fa679ed143

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
Source-Link: googleapis/synthtool@b801276
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:ba3f2990fefe465f89834e4c46f847ddb141afa54daa6a1d462928fa679ed143

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: nicain <nicain.seattle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the Cloud Logging API.
Projects
None yet
Development

No branches or pull requests

4 participants