Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions handwritten/spanner/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ import {
RequestCallback,
ResourceCallback,
Schema,
CLOUD_RESOURCE_HEADER,
addLeaderAwareRoutingHeader,
getCommonHeaders,
} from './common';
import {finished, Duplex, Readable, Transform} from 'stream';
import {PreciseDate} from '@google-cloud/precise-date';
Expand Down Expand Up @@ -490,10 +490,10 @@ class Database extends common.GrpcServiceObject {
this._clientId = instance._nthClientId;
}
this._observabilityOptions = instance._observabilityOptions;
this.commonHeaders_ = getCommonHeaders(
this.formattedName_,
this._observabilityOptions?.enableEndToEndTracing,
);
this.commonHeaders_ = {
...instance.commonHeaders_,
[CLOUD_RESOURCE_HEADER]: this.formattedName_,
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.requestStream = instance.requestStream as any;
Expand Down
10 changes: 5 additions & 5 deletions handwritten/spanner/src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
NormalCallback,
ResourceCallback,
PagedOptionsWithFilter,
getCommonHeaders,
CLOUD_RESOURCE_HEADER,
} from './common';
import {Duplex} from 'stream';
import {SessionPoolOptions, SessionPool} from './session-pool';
Expand Down Expand Up @@ -239,10 +239,10 @@ class Instance extends common.GrpcServiceObject {
this.requestStream = spanner.requestStream.bind(spanner);
this.databases_ = new Map<string, Database>();
this._observabilityOptions = spanner._observabilityOptions;
this.commonHeaders_ = getCommonHeaders(
this.formattedName_,
this._observabilityOptions?.enableEndToEndTracing,
);
this.commonHeaders_ = {
...spanner.commonHeaders_,
[CLOUD_RESOURCE_HEADER]: this.formattedName_,
};
}

/**
Expand Down
11 changes: 2 additions & 9 deletions handwritten/spanner/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ import {
CreateSessionOptions,
} from './database';
import {ServiceObjectConfig} from '@google-cloud/common';
import {
NormalCallback,
addLeaderAwareRoutingHeader,
getCommonHeaders,
} from './common';
import {NormalCallback, addLeaderAwareRoutingHeader} from './common';
import {ObservabilityOptions} from './instrument';
import {grpc, CallOptions} from 'google-gax';
import IRequestOptions = google.spanner.v1.IRequestOptions;
Expand Down Expand Up @@ -261,10 +257,7 @@ export class Session extends common.GrpcServiceObject {
} as {} as ServiceObjectConfig);

this._observabilityOptions = database._observabilityOptions;
this.commonHeaders_ = getCommonHeaders(
(this.parent as Database).formattedName_,
this._observabilityOptions?.enableEndToEndTracing,
);
this.commonHeaders_ = {...database.commonHeaders_};
this.request = database.request;
this.requestStream = database.requestStream;

Expand Down
11 changes: 2 additions & 9 deletions handwritten/spanner/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ import {Session} from './session';
import {Key} from './table';
import {Span} from './instrument';
import {google as spannerClient} from '../protos/protos';
import {
NormalCallback,
addLeaderAwareRoutingHeader,
getCommonHeaders,
} from './common';
import {NormalCallback, addLeaderAwareRoutingHeader} from './common';
import {google} from '../protos/protos';
import IsolationLevel = google.spanner.v1.TransactionOptions.IsolationLevel;
import IAny = google.protobuf.IAny;
Expand Down Expand Up @@ -374,10 +370,7 @@ export class Snapshot extends EventEmitter {
this._waitingRequests = [];
this._inlineBeginStarted = false;
this._observabilityOptions = session._observabilityOptions;
this.commonHeaders_ = getCommonHeaders(
this._dbName,
this._observabilityOptions?.enableEndToEndTracing,
);
this.commonHeaders_ = {...session.commonHeaders_};
this._traceConfig = {
opts: this._observabilityOptions,
dbName: this._dbName,
Expand Down
3 changes: 3 additions & 0 deletions handwritten/spanner/test/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ describe('Database', () => {
formattedName_: 'instance-name',
databases_: new Map(),
parent: SPANNER,
commonHeaders_: {
[AFE_SERVER_TIMING_HEADER]: 'true',
},
Comment thread
surbhigarg92 marked this conversation as resolved.
} as {} as Instance;

const NAME = 'table-name';
Expand Down
3 changes: 3 additions & 0 deletions handwritten/spanner/test/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ describe('Instance', () => {
projectId: 'project-id',
instances_: new Map(),
projectFormattedName_: 'projects/project-id',
commonHeaders_: {
[AFE_SERVER_TIMING_HEADER]: 'true',
},
Comment thread
surbhigarg92 marked this conversation as resolved.
} as {} as Spanner;

const NAME = 'instance-name';
Expand Down
4 changes: 4 additions & 0 deletions handwritten/spanner/test/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ describe('Session', () => {
request: () => {},
formattedName_: 'formatted-database-name',
parent: INSTANCE,
commonHeaders_: {
[CLOUD_RESOURCE_HEADER]: 'formatted-database-name',
[AFE_SERVER_TIMING_HEADER]: 'true',
},
Comment thread
surbhigarg92 marked this conversation as resolved.
};

const NAME = 'session-name';
Expand Down
4 changes: 4 additions & 0 deletions handwritten/spanner/test/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ describe('Transaction', () => {
formattedName_: SESSION_NAME,
request: REQUEST,
requestStream: REQUEST_STREAM,
commonHeaders_: {
[CLOUD_RESOURCE_HEADER]: 'formatted-database-name',
[AFE_SERVER_TIMING_HEADER]: 'true',
},
Comment thread
surbhigarg92 marked this conversation as resolved.
};

const PARTIAL_RESULT_STREAM = sandbox.stub();
Expand Down
Loading