Skip to content

Provide a way to programmatically disable builtin metrics #2373

@flovouin

Description

@flovouin

A screenshot that you have tested with "Try this API".

N/A

What would you like to see in the library?

From what I understand, the feature introduced by #2272 can only be disabled using either the SPANNER_DISABLE_BUILTIN_METRICS or SPANNER_EMULATOR_HOST environment variable.

I'm programmatically creating a client to an emulator, using something like:

const spanner = new Spanner({
  servicePath: 'some-address',
  port: SPANNER_GRPC_PORT,
  projectId: 'demo-some-project',
  sslCreds: grpc.credentials.createInsecure(),
});

This doesn't get detected by the metrics initialisation logic, and I end up with logs like:

Need monitoring metric writer permission on project demo-some-project. Follow https://cloud.google.com/spanner/docs/view-manage-client-side-metrics#access-client-side-metrics to set up permissions
ERROR: Send TimeSeries failed: 7 PERMISSION_DENIED: Permission monitoring.timeSeries.create denied (or the resource may not exist).

I'm not sure if there's a reliable way of determining that the metrics should not be exported based on the configuration I'm passing to Spanner. If there is, then great, but I don't mind passing an explicit parameter like disableBuiltinMetrics: true either.

Describe alternatives you've considered

Using environment variables, which in my case would require manipulating process.env as I'm configuring the client programmatically.

Additional context/notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: spannerIssues related to the googleapis/nodejs-spanner API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions