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

feat(bigtable): Client side merics #10046

Merged
merged 23 commits into from
Jul 25, 2024

Conversation

bhshkh
Copy link
Contributor

@bhshkh bhshkh commented Apr 25, 2024

This PR adds support for built-in client side metrics in Go Bigtable client. Metrics will be recorded and exported by default to GCM if not opted out by user.

Major changes in this PR:

  1. ClientConfig - New field MetricsProvider has been added. It can be used to opt out of metrics collection.
  2. metricsTracerFactory - Private field added on client. When a new client is created,
  • if user hasn't provided MetricsProvider option in config, a new meter provider is created with GCM exporter to record and export built-in metrics.
  • if user has provided NoopMetricsProvider in config, metrics will neither be recorded, nor be exported
    During client creation, a new metricsTracerFactory instance will be created, then OTel (Open Telemetry) instruments will be created on meter provider and these instruments will be saved to metricsTracerFactory.
    Whenever any operation is invoked on data client such as ReadRows, a new builtinMetricsTracer will be created using the metricsTracerFactory
  1. bigtable/metric_monitoring_exporter.go file is the GCM (Google Cloud Monitoring) exporter. The code in this file is a modified version ( diff ) of https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/88c799af8373802d659e6efdca387e3a353e8c21/exporter/metric/metric.go :

    • Custom monitored resource type is being used here instead of deriving it from OpenTelemetry resource configuration
    • Metric attributes are being added to monitored resource labels while the original one adds OTel resource attributes to GCM monitored resource
    • Exporter exports only built in metrics to GCM
  2. All the data methods have been modified to include attempt recorder and operation recorder.

Out of all the metrics, this PR adds operation_latencies, attempt_latencies, server_latencies and retry_count. Rest will be added in follow up PRs

Below diagram shows code flow when client is created using NewClient method:
CBT client side metrics (2)

@product-auto-label product-auto-label bot added the api: bigtable Issues related to the Bigtable API. label Apr 25, 2024
@bhshkh bhshkh force-pushed the feature/cbt-client-side-metrics branch from 4ddb6fb to 072ae5d Compare May 20, 2024 18:36
Copy link

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@bhshkh bhshkh closed this May 20, 2024
@bhshkh bhshkh force-pushed the feature/cbt-client-side-metrics branch from 072ae5d to 4d85153 Compare May 20, 2024 19:13
@bhshkh bhshkh reopened this May 20, 2024
@bhshkh bhshkh force-pushed the feature/cbt-client-side-metrics branch 2 times, most recently from 19a434d to 536c4c9 Compare May 26, 2024 19:29
@bhshkh bhshkh closed this May 31, 2024
@bhshkh bhshkh force-pushed the feature/cbt-client-side-metrics branch from 0a65527 to 78f3d9e Compare May 31, 2024 21:17
@bhshkh bhshkh reopened this May 31, 2024
@bhshkh bhshkh marked this pull request as ready for review May 31, 2024 21:45
@bhshkh bhshkh requested review from a team as code owners May 31, 2024 21:45
@bhshkh bhshkh force-pushed the feature/cbt-client-side-metrics branch from 4f51c17 to e6c4fd6 Compare May 31, 2024 21:59
@bhshkh bhshkh enabled auto-merge (squash) May 31, 2024 22:01
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
@bhshkh bhshkh force-pushed the feature/cbt-client-side-metrics branch from a514461 to 0accc87 Compare June 5, 2024 20:23
bigtable/metrics_monitoring_exporter.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics_monitoring_exporter.go Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/integration_test.go Outdated Show resolved Hide resolved
bigtable/integration_test.go Outdated Show resolved Hide resolved
bigtable/metrics.go Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved

clientName = fmt.Sprintf("go-bigtable/%v", internal.Version)

bucketBounds = []float64{0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0, 13.0, 16.0, 20.0, 25.0, 30.0, 40.0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment here explaining what this variable means and why the array of float values are what they are?

bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/bigtable.go Show resolved Hide resolved
bigtable/bigtable.go Outdated Show resolved Hide resolved
return tracerFactory, err
}

func builtInMeterProviderOptions(project string) ([]sdkmetric.Option, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you rename this function and change the builtIn part to something more specific to what it does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed MeterProviderOptions in #10629

bigtable/metrics.go Outdated Show resolved Hide resolved
bigtable/metric_util.go Outdated Show resolved Hide resolved
bigtable/metric_util.go Outdated Show resolved Hide resolved
bigtable/metrics.go Show resolved Hide resolved
// builtinMetricsTracer is created one per operation
// It is used to store metric instruments, attribute values
// and other data required to obtain and record them
type builtinMetricsTracer struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are three different tracers in this file. Could you rename builtinMetricsTracer to something that differentiates it from opTracer and attemptTracer?

Copy link
Contributor

@igorbernstein2 igorbernstein2 left a comment

Choose a reason for hiding this comment

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

LGTM bigtable side

@bhshkh bhshkh merged commit a747f0a into googleapis:main Jul 25, 2024
10 of 12 checks passed
@bhshkh bhshkh deleted the feature/cbt-client-side-metrics branch July 25, 2024 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the Bigtable API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants