feat(bigtable): add Cloud Bigtable client uptime gauge metric#14653
feat(bigtable): add Cloud Bigtable client uptime gauge metric#14653mgarolera wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new client uptime metric (uptime) as an Int64ObservableGauge and adds support for exporting Gauge[int64] and Gauge[float64] metrics to Cloud Monitoring. Feedback suggests ensuring that the StartTime of the TimeInterval is set equal to the EndTime for gauge metrics to comply with Cloud Monitoring API requirements. Additionally, a defensive check should be added to ensure tf.startTime is initialized before observing the uptime metric.
69ed0cd to
86bc9bc
Compare
| ) | ||
|
|
||
| const ( | ||
| bigtableResourceType = "bigtable_client_raw" |
There was a problem hiding this comment.
I think this needs a bit more work. All the metrics exported from this exporter goes to bigtable_client_raw which maps to BigtableTable target instead of BigtableClient target, which is different from the internal metric definition.
There was a problem hiding this comment.
This metric should be exported similar to client startup time.
this will use the cloud.BigtableClient schema.
There was a problem hiding this comment.
Ah yes. I think we should move the definition of this metric to otel_metrics, something like:
otelMeterProvider := metric.NewMeterProvider(meterOpts...) // existing code
startTime := time.Now()
_, err := meter.Int64ObservableGauge(
"uptime",
metric.WithDescription("Time since the Bigtable client was created."),
metric.WithUnit("s"),
metric.WithInt64Callback(func(_ context.Context, o metric.Int64Observer) error {
o.Observe(int64(time.Since(startTime).Seconds()))
return nil
}),
)
86bc9bc to
7b90cb2
Compare
Register the client uptime metric directly on the otelMeterProvider in newOtelMetricsContext instead of metrics.go. This ensures that the metric is exported using the bigtable_client Monitored Resource (cloud.BigtableClient) instead of the fallback/legacy bigtable_client_raw, aligning with the internal metric definition. Keep fallback registration in metrics.go for cases when otelMeterProvider is nil.
Add reporting for CBT client uptime to help with observability and troubleshooting