Skip to content

Error handling breaks when using rest fallback #3531

Closed

Description

@jekozyra

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.

Activity

  1. added
    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.
    on Oct 7, 2022
  2. self-assigned this
    on Oct 13, 2022
  3. alexander-fenster commented on Apr 25, 2023

    @alexander-fenster
    Contributor

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

  4. gauthamchandra commented on Apr 27, 2024

    @gauthamchandra

    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())

  5. quirogas commented on Oct 26, 2026

    @quirogas
    Contributor

    Already fixed on main: packages/google-cloud-monitoring/protos/protos.json now defines google.monitoring.v3.CreateTimeSeriesSummary, resolving the unhandled proto3-json-serializer type lookup failure in REST fallback mode.

    Thank you @feywind !

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

Metadata

Metadata

Assignees

Labels

api: monitoringIssues related to the Cloud Monitoring API.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