Skip to content

Commit

Permalink
Use the MethodName enum instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljbruce committed Jan 28, 2025
1 parent 66c4ab1 commit e7c5b5f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions common/client-side-metrics-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ export interface OnAttemptCompleteAttributes
export interface OnAttemptCompleteInfo extends AttemptOnlyAttributes {
connectivityErrorCount: number;
}

export enum MethodName {
READ_ROWS = 'readRows',
MUTATE_ROW = 'mutateRow',
CHECK_AND_MUTATE_ROW = 'checkAndMutateRow',
READ_MODIFY_WRITE_ROW = 'readModifyWriteRow',
SAMPLE_ROW_KEYS = 'sampleRowKeys',
MUTATE_ROWS = 'mutateRows',
}
7 changes: 4 additions & 3 deletions src/client-side-metrics/metrics-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import * as fs from 'fs';
import {IMetricsHandler} from './metrics-handler';
import {
AttemptOnlyAttributes,
MethodName,
OnAttemptCompleteInfo,
OnOperationCompleteAttributes,
OperationOnlyAttributes,
Expand Down Expand Up @@ -83,7 +84,7 @@ export class MetricsCollector {
private zone: string | undefined;
private cluster: string | undefined;
private tabularApiSurface: ITabularApiSurface;
private methodName: string;
private methodName: MethodName;
private projectId?: string;
private attemptCount = 0;
private receivedFirstResponse: boolean;
Expand All @@ -96,14 +97,14 @@ export class MetricsCollector {
/**
* @param {ITabularApiSurface} tabularApiSurface Information about the Bigtable table being accessed.
* @param {IMetricsHandler[]} metricsHandlers The metrics handlers used for recording metrics.
* @param {string} methodName The name of the method being traced.
* @param {MethodName} methodName The name of the method being traced.
* @param {string} projectId The id of the project.
* @param {DateProvider} dateProvider A provider for date/time information (for testing).
*/
constructor(
tabularApiSurface: ITabularApiSurface,
metricsHandlers: IMetricsHandler[],
methodName: string,
methodName: MethodName,
projectId?: string,
dateProvider?: DateProvider
) {
Expand Down

0 comments on commit e7c5b5f

Please sign in to comment.