Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: Add plumbing PR for client side metrics to support the open telemetry instruments #1569

Open
wants to merge 298 commits into
base: main
Choose a base branch
from

Conversation

danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented Feb 18, 2025

Summary:

In this PR we introduce all the plumbing that runs the operations from the point where the metrics handler receives data to the point where the data is sent to the Google Cloud Monitoring dashboard.

The diagram below shows all the pieces added in this PR in green:

2nd plumbing PR

A test stub exists that contains the requests that the metrics collector passes into its metrics handler when a fake method is used. This test stub is used to pass data into the metrics handler in this PR and test the new pipeline that this PR adds.

This is a follow up PR to #1566.

Changes:

package.json: Add the package that contains the MetricServiceClient used for sending data to Google Cloud Monitoring.

src/client-side-metrics/exporter.ts: Add the CloudMonitoringExporter which accepts metrics and then converts them to the right format and sends them to the Google Cloud Monitoring dashboard.

src/client-side-metrics/gcp-metrics-handler.ts: The metrics handler that stores requests in open telemetry instruments and then periodically sends them to its exporter.

system-test/cloud-monitoring-exporter.ts: System tests that write to the google cloud monitoring dashboard with a fixed value passed into the exporter.

system-test/gcp-metrics-handler.ts: A system test that passes fixed values into the gcp-metrics-handler.ts and ensures it properly writes information to the Google Cloud dashboard.

test-common/expected-otel-export-input.ts: Some fixed constants related to values open telemetry provides to the exporter.

test/metrics-collector/gcp-metrics-handler.ts: A test that ensures the GCP Metrics handler passes the right information to the exporter.

test/metrics-collector/metrics-to-request.ts: A test that ensures the method that converts the value the exporter receives to the value that GCM needs is correct.

Next Steps:

  • Add client side metrics collection to read-rows operations
  • Add application blocking latencies and throttling latencies

@danieljbruce
Copy link
Contributor Author

For threads like this it is not letting me comment in the conversation tab

Copy link

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very solid! My only remaining request would be to rename the Metrics interface to Instruments or MetricInstruments, since Metrics has a different meaning in OTel

After that, this should be good to merge

},
},
],
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this one need a unit field, like for the distribution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests that export results to Google Cloud Monitoring succeed at exporting the metrics so I don't think so. If we did have a unit for connectivity_error_count and retry_count then what would it be? These are just counters.

],
labels: resourceLabels,
},
valueType: 'INT64',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is just for isCounterValue, makes sense!

I'd still recommend refactoring this function a bit. Either breaking out counter/distribution into two helper methods, or a single helper if there are enough shared fields to combine them

But that's just a style suggestion

// to 0 then the operation failed. Open telemetry logs errors to the
// console when the resultCallback passes in non-zero code values and
// logs nothing when the code is 0.
const exportResult = {code: 0};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW it is also used a couple times in MetricsExporter, so I still think this would be a good idea. But this is a small nit

* A collection of OpenTelemetry metric instruments used to record
* Bigtable client-side metrics.
*/
interface Metrics {
Copy link

@daniel-sanche daniel-sanche Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be renamed to Instruments or MetricInstruments, since Metrics has a different meaning in OTel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* which will be provided to the exporter in every export call.
*
*/
private getMetrics(projectId: string): Metrics {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getInstruments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Renamed to getInstruments.

instanceId: data.metricsCollectorData.instanceId,
table: data.metricsCollectorData.table,
cluster: data.metricsCollectorData.cluster,
zone: data.metricsCollectorData.zone,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@danieljbruce
Copy link
Contributor Author

Re: #1569 (comment). I think this is the MetricsExporter file? We can change {code: 0} elsewhere in src if you see it in another place, but I can't find one. {code: 0} appears in a lot of tests though.

Copy link

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
api: bigtable Issues related to the googleapis/nodejs-bigtable API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants