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

refactor(bigquery/storage/managedwriter): refactor error metrics #8314

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

shollyman
Copy link
Contributor

@shollyman shollyman commented Jul 21, 2023

This is a small refactor to how opencensus metrics are reported when receiving responses from the server.

There's effectively two cases where we consider an error to have occurred on receive:

  • Invoking gRPC Recv() on the connection emitted an error, typically a transport issue

  • The service embedded an error in the response, which is more akin to an application error (failed to commit data, offset mismatch, etc).

This CL ensures we increment the existing AppendResponseError count metric in both causes, and deals with the unlikely scenario where we're unable to tag the report with the status code. When that happens, we simply record the metric uncoded.

Towards: #8311

This is a small refactor to how opencensus metrics are reported when
receiving responses from the server.

There's effectively two cases where we consider an error to have
occurred on receive:

* Invoking gRPC Recv() on the connection emitted an error, typically a
  transport issue

* The service embedded an error in the response, which is more akin to
  an application error (failed to commit data, offset mismatch, etc).

This CL ensures we increment the existing AppendResponseError count
metric in both causes, and deals with the unlikely scenario where we're
unable to tag the report with the status code.  When that happens, we
simply record the metric uncoded.
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: bigquery Issues related to the BigQuery API. labels Jul 21, 2023
@shollyman shollyman marked this pull request as ready for review July 24, 2023 16:42
@shollyman shollyman requested review from a team as code owners July 24, 2023 16:42
@shollyman shollyman requested review from GaoleMeng and alvarowolfx and removed request for GaoleMeng July 24, 2023 16:42
@@ -494,18 +494,29 @@ func connRecvProcessor(ctx context.Context, co *connection, arc storagepb.BigQue
resp, err := arc.Recv()
co.release(nextWrite)
if err != nil {
// The Recv() itself yielded an error. We increment AppendResponseErrors by one, tagged by the status
// code.
status := grpcstatus.Convert(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if status can be nil here as this err is coming from a grpc stream method. Might worth add the extra check

Copy link
Contributor

Choose a reason for hiding this comment

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

an io.EOF will probably cause grpcstatus.Convert to return nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wraps the error as a code.Unknown if it doesn't embed an rpc status error, ex: https://github.com/grpc/grpc-go/blob/faab8736bf73291f92b867d5dae31c927d53d508/status/status.go#L96-L125

@shollyman shollyman added the automerge Merge the pull request once unit tests and other checks pass. label Jul 25, 2023
@gcf-merge-on-green gcf-merge-on-green bot merged commit 04d6264 into googleapis:main Jul 25, 2023
7 checks passed
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jul 25, 2023
@shollyman shollyman deleted the managedwriter-metrics branch July 25, 2023 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants