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

Add time and timeEnd logs to the code #1364

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@
* region_tag:bigtable_api_table_readstream
*/
createReadStream(opts?: GetRowsOptions) {
console.time('before-gapic');
const options = opts || {};
const maxRetries = is.number(this.maxRetries) ? this.maxRetries! : 10;
let activeRequestStream: AbortableDuplex | null;
Expand Down Expand Up @@ -810,7 +811,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 814 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 814 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down Expand Up @@ -943,6 +944,7 @@

rowStream
.on('error', (error: ServiceError) => {
console.log('some error');
rowStreamUnpipe(rowStream, userStream);
activeRequestStream = null;
if (IGNORED_STATUS_CODES.has(error.code)) {
Expand All @@ -969,12 +971,14 @@
userStream.emit('error', error);
}
})
.on('data', _ => {

Check warning on line 974 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used
// Reset error count after a successful read so the backoff
// time won't keep increasing when as stream had multiple errors
numConsecutiveErrors = 0;
})
.on('end', () => {
console.timeEnd('to-end');
console.time('from-end');
activeRequestStream = null;
});
rowStreamPipe(rowStream, userStream);
Expand Down Expand Up @@ -1427,6 +1431,8 @@
.on('error', callback)
.pipe(
concat((rows: Row[]) => {
console.log(rows);
console.timeEnd('receive-time');
callback(null, rows);
})
);
Expand Down Expand Up @@ -1592,7 +1598,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 1601 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 1601 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down
1 change: 1 addition & 0 deletions src/v2/bigtable_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ export class BigtableClient {
request?: protos.google.bigtable.v2.IReadRowsRequest,
options?: CallOptions
): gax.CancellableStream {
console.timeEnd('before-gapic');
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
Expand Down
4 changes: 4 additions & 0 deletions testproxy/services/read-rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ const readRows = ({clientMap}) =>
const table = getTableInfo(bigtable, tableName);
const rowsOptions = getRowsOptions(readRowsRequest);
try {
console.time('to-end');
console.time('readRows');
const [rows] = await table.getRows(rowsOptions);
console.timeEnd('from-end');
console.timeEnd('readRows');
return {
status: {code: grpc.status.OK, details: []},
rows: rows.map(getRowResponse),
Expand Down