-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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): first_response_latencies and connectivity_error_count metrics #10616
Open
bhshkh
wants to merge
6
commits into
googleapis:main
Choose a base branch
from
bhshkh:feature/cbt-client-side-metrics-01
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+102
−16
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
06b5256
feat(bigtable): Adding first_response_latencies and connectivity_erro…
bhshkh f084993
test(bigtable): Fixing tests
bhshkh 8303f86
Merge branch 'main' into feature/cbt-client-side-metrics-01
bhshkh 39abeaa
refactor(bigtable): Refactoring code
bhshkh 4f35a3f
Merge branch 'main' into feature/cbt-client-side-metrics-01
bhshkh f61c02d
feat(bigtable): Record only on first response
bhshkh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,11 @@ import ( | |
_ "google.golang.org/grpc/balancer/rls" | ||
) | ||
|
||
const prodAddr = "bigtable.googleapis.com:443" | ||
const mtlsProdAddr = "bigtable.mtls.googleapis.com:443" | ||
const ( | ||
prodAddr = "bigtable.googleapis.com:443" | ||
mtlsProdAddr = "bigtable.mtls.googleapis.com:443" | ||
methodNameReadRows = "ReadRows" | ||
) | ||
|
||
// Client is a client for reading and writing data to tables in an instance. | ||
// | ||
|
@@ -353,7 +356,7 @@ func (t *Table) ReadRows(ctx context.Context, arg RowSet, f func(Row) bool, opts | |
func (t *Table) readRows(ctx context.Context, arg RowSet, f func(Row) bool, mt *builtinMetricsTracer, opts ...ReadOption) (err error) { | ||
var prevRowKey string | ||
attrMap := make(map[string]interface{}) | ||
err = gaxInvokeWithRecorder(ctx, mt, "ReadRows", func(ctx context.Context, headerMD, trailerMD *metadata.MD, _ gax.CallSettings) error { | ||
err = gaxInvokeWithRecorder(ctx, mt, methodNameReadRows, func(ctx context.Context, headerMD, trailerMD *metadata.MD, _ gax.CallSettings) error { | ||
req := &btpb.ReadRowsRequest{ | ||
AppProfileId: t.c.appProfile, | ||
} | ||
|
@@ -397,6 +400,7 @@ func (t *Table) readRows(ctx context.Context, arg RowSet, f func(Row) bool, mt * | |
*headerMD, _ = stream.Header() | ||
for { | ||
res, err := stream.Recv() | ||
mt.currOp.setFirstRespTime(time.Now()) | ||
if err == io.EOF { | ||
*trailerMD = stream.Trailer() | ||
break | ||
|
@@ -1552,6 +1556,13 @@ func recordOperationCompletion(mt *builtinMetricsTracer) { | |
// graph will be less confusing | ||
mt.instrumentRetryCount.Add(mt.ctx, mt.currOp.attemptCount-1, metric.WithAttributes(retryCntAttrs...)) | ||
} | ||
|
||
// Record first_reponse_latencies | ||
firstRespLatAttrs, _ := mt.toOtelMetricAttrs(metricNameRetryCount) | ||
if mt.method == methodNameReadRows { | ||
elapsedTimeMs = convertToMs(mt.currOp.firstRespTime.Sub(mt.currOp.startTime)) | ||
mt.instrumentFirstRespLatencies.Record(mt.ctx, elapsedTimeMs, metric.WithAttributes(firstRespLatAttrs...)) | ||
} | ||
} | ||
|
||
// gaxInvokeWithRecorder: | ||
|
@@ -1584,7 +1595,8 @@ func gaxInvokeWithRecorder(ctx context.Context, mt *builtinMetricsTracer, method | |
|
||
// Get location attributes from metadata and set it in tracer | ||
// Ignore get location error since the metric can still be recorded with rest of the attributes | ||
clusterID, zoneID, _ := extractLocation(attemptHeaderMD, attempTrailerMD) | ||
clusterID, zoneID, locationErr := extractLocation(attemptHeaderMD, attempTrailerMD) | ||
mt.currOp.currAttempt.setLocationErr(locationErr) | ||
mt.currOp.currAttempt.setClusterID(clusterID) | ||
mt.currOp.currAttempt.setZoneID(zoneID) | ||
|
||
|
@@ -1615,9 +1627,15 @@ func recordAttemptCompletion(mt *builtinMetricsTracer) { | |
attemptLatAttrs, _ := mt.toOtelMetricAttrs(metricNameAttemptLatencies) | ||
mt.instrumentAttemptLatencies.Record(mt.ctx, elapsedTime, metric.WithAttributes(attemptLatAttrs...)) | ||
|
||
// Record server_latencies | ||
// Record server_latencies and connectivity_error_count | ||
connErrCountAttrs, _ := mt.toOtelMetricAttrs(metricNameConnErrCount) | ||
serverLatAttrs, _ := mt.toOtelMetricAttrs(metricNameServerLatencies) | ||
if mt.currOp.currAttempt.serverLatencyErr == nil { | ||
mt.instrumentServerLatencies.Record(mt.ctx, mt.currOp.currAttempt.serverLatency, metric.WithAttributes(serverLatAttrs...)) | ||
} | ||
if mt.currOp.currAttempt.serverLatencyErr == nil && mt.currOp.currAttempt.locationErr == nil { | ||
mt.instrumentConnErrCount.Add(mt.ctx, 0, metric.WithAttributes(connErrCountAttrs...)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you need to add a zero? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} else { | ||
mt.instrumentConnErrCount.Add(mt.ctx, 1, metric.WithAttributes(connErrCountAttrs...)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when multiple responses are received?
what happens when there are no rows returned?
is the behavior consistent with java?
Does this work across retries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when multiple responses are received?
Updated the code to set only on the first response.