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

Error handling breaks when using rest fallback #3531

Open
jekozyra opened this issue Oct 7, 2022 · 2 comments
Open

Error handling breaks when using rest fallback #3531

jekozyra opened this issue Oct 7, 2022 · 2 comments
Assignees
Labels
api: monitoring Issues related to the Cloud Monitoring API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jekozyra
Copy link

jekozyra commented Oct 7, 2022

We're currently creating our MetricServiceClient using the rest fallback method, since we're building our code with esbuild and using protos does not seem to be supported. However, if the createTimeSeries call fails, the the error is not handled and emitted by the library. Instead, it causes a crash and an unhelpful error message is emitted.

Stacktrace:

⚠  functions: Error: googleProtobufAnyFromProto3JSON: cannot find type google.monitoring.v3.CreateTimeSeriesSummary: Error: no such type: google.monitoring.v3.CreateTimeSeriesSummary
    at googleProtobufAnyFromProto3JSON (/poggio/node_modules/proto3-json-serializer/build/src/any.js:70:15)
    at fromProto3JSONToInternalRepresentation (/poggio/node_modules/proto3-json-serializer/build/src/fromproto3json.js:58:58)
    at /poggio/node_modules/proto3-json-serializer/build/src/fromproto3json.js:105:48
    at Array.map (<anonymous>)
    at fromProto3JSONToInternalRepresentation (/poggio/node_modules/proto3-json-serializer/build/src/fromproto3json.js:105:33)
    at Object.fromProto3JSON (/poggio/node_modules/proto3-json-serializer/build/src/fromproto3json.js:149:26)
    at GoogleErrorDecoder.decodeHTTPError (/poggio/node_modules/@google-cloud/monitoring/node_modules/google-gax/build/src/googleError.js:198:41)
    at Function.parseHttpError (/poggio/node_modules/@google-cloud/monitoring/node_modules/google-gax/build/src/googleError.js:71:37)
    at decodeResponse (/poggio/node_modules/@google-cloud/monitoring/node_modules/google-gax/build/src/fallbackRest.js:69:49)
    at /poggio/node_modules/@google-cloud/monitoring/node_modules/google-gax/build/src/fallbackServiceStub.js:101:42
⚠  Your function was killed because it raised an unhandled error.

This is roughly how we're using the library:

const client = new MetricServiceClient({ fallback: "rest" });
const dataPoint = {
  interval: {
    endTime: {
      seconds: Date.now() / 1000,
    },
  },
  value: {
    int64Value: 1,
  },
};

const requestArgs = {
  name: metricServiceClient().projectPath('project-name'),
  timeSeries: [
    {
      metric: {
        type: 'custom.googleapis.com/connectors/fivetran_sync_start',
        metricKind: 'GAUGE',
        valueType: 'INT64',
        labels: [
            runId: 'abc1234'
        ],
      },
      resource: {
        type: "global",
        labels: {
          project_id: 'project-name',
        },
      },
      points: [dataPoint],
    },
  ],
};
await metricServiceClient().createTimeSeries(requestArgs);

Environment details

  • OS: Ubuntu 18.04
  • Node.js version: 16
  • npm version:
  • @google-cloud/monitoring version: 3.0.2

Steps to reproduce

  1. Create a MetricServiceClient with the rest fallback option, e.g. new MetricServiceClient({ fallback: "rest" })
  2. Do something that causes createTimeSeries to error (in our case, I believe we were exceeding the rate limit).
  3. Instead of an error message (which is what you get if you use the proto fallback), you get the following error: Error: googleProtobufAnyFromProto3JSON: cannot find type google.monitoring.v3.CreateTimeSeriesSummary: Error: no such type: google.monitoring.v3.CreateTimeSeriesSummary.
@jekozyra jekozyra added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Oct 7, 2022
@product-auto-label product-auto-label bot added the api: monitoring Issues related to the Cloud Monitoring API. label Oct 7, 2022
@sofisl sofisl self-assigned this Oct 13, 2022
@sofisl sofisl transferred this issue from googleapis/nodejs-monitoring Nov 10, 2022
@bcoe bcoe assigned alexander-fenster and unassigned sofisl Dec 19, 2022
@alexander-fenster
Copy link
Contributor

This probably means that the monitoring library needs to have more protos included – namely, the CreateTimeSeriesSummary type. I will take a look.

@gauthamchandra
Copy link

Hi, is there any movement on this out of curiosity? We are also running into the same issue on v4.0.0 of the library but not in fallback mode (aka. just new MetricServiceClient())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: monitoring Issues related to the Cloud Monitoring API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants