-
Notifications
You must be signed in to change notification settings - Fork 62
feat: Add client side metrics for readModifyWriteRow calls #1656
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
Changes from 30 commits
87d54c0
26822d8
66569cb
150cd92
febccf7
85e3949
9b7d9dd
3502229
e5bbd03
e3dda80
14a775e
74dbce6
4b9fe1f
f54e794
9b2c50c
ba7a145
7bf964e
d69497b
bcb4cba
21b37fd
84c5c5a
262e8c1
278d3c5
c949dca
5f0d3ae
a2a79f7
2ae3f0a
cd553b2
0be9ba7
f25711c
f6e285d
01853f9
52a6ce7
775fb0c
c18a303
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,10 +181,7 @@ export class OperationMetricsCollector { | |
| }) => { | ||
| this.onStatusMetadataReceived(status); | ||
| }, | ||
| ) | ||
| .on('data', () => { | ||
| this.onResponse(); | ||
| }); | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -285,11 +282,23 @@ export class OperationMetricsCollector { | |
| * @param {grpc.status} finalOperationStatus Information about the completed operation. | ||
| * @param {number} applicationLatency The application latency measurement. | ||
|
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. is this meant to be removed?
Contributor
Author
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. No. Thanks for catching this. |
||
| */ | ||
| onOperationComplete( | ||
| onOperationAndAttemptComplete( | ||
|
||
| finalOperationStatus: grpc.status, | ||
| applicationLatency?: number, | ||
| ) { | ||
| this.onAttemptComplete(finalOperationStatus); | ||
| this.onOperationComplete(finalOperationStatus, applicationLatency); | ||
| } | ||
|
|
||
| /** | ||
| * Called when an operation completes (successfully or unsuccessfully). | ||
| * Records operation latencies, retry counts, and connectivity error counts. | ||
| * @param {grpc.status} finalOperationStatus Information about the completed operation. | ||
| */ | ||
| onOperationComplete( | ||
| finalOperationStatus: grpc.status, | ||
| applicationLatency?: number, | ||
| ) { | ||
| withMetricsDebug(() => { | ||
| checkState(this.state, [ | ||
| MetricsCollectorState.OPERATION_STARTED_ATTEMPT_NOT_IN_PROGRESS, | ||
|
|
@@ -310,7 +319,7 @@ export class OperationMetricsCollector { | |
| client_name: `nodejs-bigtable/${version}`, | ||
| operationLatency: totalMilliseconds, | ||
| retryCount: this.attemptCount - 1, | ||
| firstResponseLatency: this.firstResponseLatency ?? undefined, | ||
| firstResponseLatency: this.firstResponseLatency ?? 0, | ||
| applicationLatency: applicationLatency ?? 0, | ||
| }); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,10 +26,6 @@ import { | |
| } from '../chunktransformer'; | ||
| import {TableUtils} from './table'; | ||
| import {Duplex, PassThrough, Transform} from 'stream'; | ||
| import { | ||
| MethodName, | ||
| StreamingState, | ||
| } from '../client-side-metrics/client-side-metrics-attributes'; | ||
| import {google} from '../../protos/protos'; | ||
| const pumpify = require('pumpify'); | ||
| import {grpc, ServiceError} from 'google-gax'; | ||
|
|
@@ -324,6 +320,10 @@ export function createReadStreamInternal( | |
| gaxOpts, | ||
| retryOpts, | ||
| }); | ||
| requestStream.on('data', () => { | ||
| // This handler is necessary for recording firstResponseLatencies. | ||
| metricsCollector.onResponse(); | ||
| }); | ||
|
|
||
| activeRequestStream = requestStream!; | ||
|
|
||
|
|
@@ -363,6 +363,9 @@ export function createReadStreamInternal( | |
| rowStream = pumpify.obj([requestStream, chunkTransformer, toRowStream]); | ||
|
|
||
| metricsCollector.wrapRequest(requestStream); | ||
| requestStream.on('data', () => { | ||
| metricsCollector.onResponse(); | ||
| }); | ||
|
||
| rowStream | ||
| .on('error', (error: ServiceError) => { | ||
| rowStreamUnpipe(rowStream, userStream); | ||
|
|
@@ -371,7 +374,7 @@ export function createReadStreamInternal( | |
| // We ignore the `cancelled` "error", since we are the ones who cause | ||
| // it when the user calls `.abort()`. | ||
| userStream.end(); | ||
| metricsCollector.onOperationComplete( | ||
| metricsCollector.onOperationAndAttemptComplete( | ||
| error.code, | ||
| userStream.getTotalDurationMs(), | ||
| ); | ||
|
|
@@ -406,7 +409,7 @@ export function createReadStreamInternal( | |
| // | ||
| error.code = grpc.status.CANCELLED; | ||
| } | ||
| metricsCollector.onOperationComplete( | ||
| metricsCollector.onOperationAndAttemptComplete( | ||
| error.code, | ||
| userStream.getTotalDurationMs(), | ||
| ); | ||
|
|
@@ -420,8 +423,7 @@ export function createReadStreamInternal( | |
| }) | ||
| .on('end', () => { | ||
| activeRequestStream = null; | ||
| const applicationLatency = userStream.getTotalDurationMs(); | ||
| metricsCollector.onOperationComplete( | ||
| metricsCollector.onOperationAndAttemptComplete( | ||
| grpc.status.OK, | ||
| userStream.getTotalDurationMs(), | ||
| ); | ||
|
|
||
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.
We only want to collect firstResponseLatency for readRows now so this is no longer needed.