@google-cloud/spanner 7.20.0 → 7.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,8 +150,13 @@ class Snapshot extends events_1.EventEmitter {
150
150
  this._inlineBeginStarted = false;
151
151
  this._observabilityOptions = session._observabilityOptions;
152
152
  this.commonHeaders_ = (0, common_1.getCommonHeaders)(this._dbName, (_a = this._observabilityOptions) === null || _a === void 0 ? void 0 : _a.enableEndToEndTracing);
153
+ this._traceConfig = {
154
+ opts: this._observabilityOptions,
155
+ dbName: this._dbName,
156
+ };
153
157
  }
154
158
  begin(gaxOptionsOrCallback, cb) {
159
+ var _a;
155
160
  const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
156
161
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
157
162
  const session = this.session.formattedName_;
@@ -173,11 +178,10 @@ class Snapshot extends events_1.EventEmitter {
173
178
  this._options.partitionedDml !== undefined)) {
174
179
  (0, common_1.addLeaderAwareRoutingHeader)(headers);
175
180
  }
176
- const traceConfig = {
177
- opts: this._observabilityOptions,
178
- dbName: this._dbName,
179
- };
180
- return (0, instrument_2.startTrace)('Snapshot.begin', traceConfig, span => {
181
+ return (0, instrument_2.startTrace)('Snapshot.begin', {
182
+ transactionTag: (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
183
+ ...this._traceConfig,
184
+ }, span => {
181
185
  span.addEvent('Begin Transaction');
182
186
  this.request({
183
187
  client: 'SpannerClient',
@@ -368,7 +372,7 @@ class Snapshot extends events_1.EventEmitter {
368
372
  * ```
369
373
  */
370
374
  createReadStream(table, request = {}) {
371
- var _a, _b;
375
+ var _a, _b, _c;
372
376
  const { gaxOptions, json, jsonOptions, maxResumeRetries, requestOptions, columnsMetadata, } = request;
373
377
  const keySet = Snapshot.encodeKeySet(request);
374
378
  const transaction = {};
@@ -407,9 +411,10 @@ class Snapshot extends events_1.EventEmitter {
407
411
  (0, common_1.addLeaderAwareRoutingHeader)(headers);
408
412
  }
409
413
  const traceConfig = {
414
+ ...this._traceConfig,
410
415
  tableName: table,
411
- opts: this._observabilityOptions,
412
- dbName: this._dbName,
416
+ transactionTag: (_c = this.requestOptions) === null || _c === void 0 ? void 0 : _c.transactionTag,
417
+ requestTag: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.requestTag,
413
418
  };
414
419
  return (0, instrument_2.startTrace)('Snapshot.createReadStream', traceConfig, span => {
415
420
  var _a;
@@ -551,12 +556,10 @@ class Snapshot extends events_1.EventEmitter {
551
556
  request = requestOrCallback;
552
557
  callback = cb;
553
558
  }
554
- const traceConfig = {
559
+ return (0, instrument_2.startTrace)('Snapshot.read', {
555
560
  tableName: table,
556
- opts: this._observabilityOptions,
557
- dbName: this._dbName,
558
- };
559
- return (0, instrument_2.startTrace)('Snapshot.read', traceConfig, span => {
561
+ ...this._traceConfig,
562
+ }, span => {
560
563
  this.createReadStream(table, request)
561
564
  .on('error', err => {
562
565
  const e = err;
@@ -575,12 +578,10 @@ class Snapshot extends events_1.EventEmitter {
575
578
  const rows = [];
576
579
  let stats;
577
580
  let metadata;
578
- const traceConfig = {
579
- sql: query,
580
- opts: this._observabilityOptions,
581
- dbName: this._dbName,
582
- };
583
- (0, instrument_2.startTrace)('Snapshot.run', traceConfig, span => {
581
+ (0, instrument_2.startTrace)('Snapshot.run', {
582
+ ...query,
583
+ ...this._traceConfig,
584
+ }, span => {
584
585
  return this.runStream(query)
585
586
  .on('error', (err, rows, stats, metadata) => {
586
587
  (0, instrument_2.setSpanError)(span, err);
@@ -703,6 +704,7 @@ class Snapshot extends events_1.EventEmitter {
703
704
  * ```
704
705
  */
705
706
  runStream(query) {
707
+ var _a;
706
708
  if (typeof query === 'string') {
707
709
  query = { sql: query };
708
710
  }
@@ -750,9 +752,10 @@ class Snapshot extends events_1.EventEmitter {
750
752
  (0, common_1.addLeaderAwareRoutingHeader)(headers);
751
753
  }
752
754
  const traceConfig = {
753
- opts: this._observabilityOptions,
754
- dbName: this._dbName,
755
+ transactionTag: (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
756
+ requestTag: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.requestTag,
755
757
  ...query,
758
+ ...this._traceConfig,
756
759
  };
757
760
  return (0, instrument_2.startTrace)('Snapshot.runStream', traceConfig, span => {
758
761
  let attempt = 0;
@@ -1040,15 +1043,16 @@ exports.Snapshot = Snapshot;
1040
1043
  */
1041
1044
  class Dml extends Snapshot {
1042
1045
  runUpdate(query, callback) {
1046
+ var _a, _b;
1043
1047
  if (typeof query === 'string') {
1044
1048
  query = { sql: query };
1045
1049
  }
1046
- const traceConfig = {
1047
- opts: this._observabilityOptions,
1048
- dbName: this._dbName,
1050
+ return (0, instrument_2.startTrace)('Dml.runUpdate', {
1049
1051
  ...query,
1050
- };
1051
- return (0, instrument_2.startTrace)('Dml.runUpdate', traceConfig, span => {
1052
+ ...this._traceConfig,
1053
+ transactionTag: (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
1054
+ requestTag: (_b = query.requestOptions) === null || _b === void 0 ? void 0 : _b.requestTag,
1055
+ }, span => {
1052
1056
  this.run(query, (err, rows, stats) => {
1053
1057
  let rowCount = 0;
1054
1058
  if (stats && stats.rowCount) {
@@ -1164,7 +1168,7 @@ class Transaction extends Dml {
1164
1168
  this.requestOptions = requestOptions;
1165
1169
  }
1166
1170
  batchUpdate(queries, optionsOrCallback, cb) {
1167
- var _a, _b;
1171
+ var _a, _b, _c;
1168
1172
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
1169
1173
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
1170
1174
  const gaxOpts = 'gaxOptions' in options
@@ -1195,9 +1199,10 @@ class Transaction extends Dml {
1195
1199
  else {
1196
1200
  transaction.begin = this._options;
1197
1201
  }
1202
+ const requestOptionsWithTag = this.configureTagOptions(false, (_b = (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag) !== null && _b !== void 0 ? _b : undefined, options.requestOptions);
1198
1203
  const reqOpts = {
1199
1204
  session: this.session.formattedName_,
1200
- requestOptions: this.configureTagOptions(false, (_b = (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag) !== null && _b !== void 0 ? _b : undefined, options.requestOptions),
1205
+ requestOptions: requestOptionsWithTag,
1201
1206
  transaction,
1202
1207
  seqno: this._seqno++,
1203
1208
  statements,
@@ -1208,8 +1213,9 @@ class Transaction extends Dml {
1208
1213
  (0, common_1.addLeaderAwareRoutingHeader)(headers);
1209
1214
  }
1210
1215
  const traceConfig = {
1211
- opts: this._observabilityOptions,
1212
- dbName: this._dbName,
1216
+ ...this._traceConfig,
1217
+ transactionTag: requestOptionsWithTag === null || requestOptionsWithTag === void 0 ? void 0 : requestOptionsWithTag.transactionTag,
1218
+ requestTag: (_c = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _c === void 0 ? void 0 : _c.requestTag,
1213
1219
  };
1214
1220
  return (0, instrument_2.startTrace)('Transaction.batchUpdate', traceConfig, span => {
1215
1221
  this.request({
@@ -1277,6 +1283,7 @@ class Transaction extends Dml {
1277
1283
  this._queuedMutations = mutation;
1278
1284
  }
1279
1285
  commit(optionsOrCallback, cb) {
1286
+ var _a;
1280
1287
  const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
1281
1288
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
1282
1289
  const gaxOpts = 'gaxOptions' in options ? options.gaxOptions : options;
@@ -1284,11 +1291,10 @@ class Transaction extends Dml {
1284
1291
  const session = this.session.formattedName_;
1285
1292
  const requestOptions = options.requestOptions;
1286
1293
  const reqOpts = { mutations, session, requestOptions };
1287
- const traceConfig = {
1288
- opts: this._observabilityOptions,
1289
- dbName: this._dbName,
1290
- };
1291
- return (0, instrument_2.startTrace)('Transaction.commit', traceConfig, span => {
1294
+ return (0, instrument_2.startTrace)('Transaction.commit', {
1295
+ transactionTag: (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
1296
+ ...this._traceConfig,
1297
+ }, span => {
1292
1298
  if (this.id) {
1293
1299
  reqOpts.transactionId = this.id;
1294
1300
  }
@@ -1576,11 +1582,7 @@ class Transaction extends Dml {
1576
1582
  rollback(gaxOptionsOrCallback, cb) {
1577
1583
  const gaxOpts = typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {};
1578
1584
  const callback = typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb;
1579
- const traceConfig = {
1580
- opts: this._observabilityOptions,
1581
- dbName: this._dbName,
1582
- };
1583
- return (0, instrument_2.startTrace)('Transaction.rollback', traceConfig, span => {
1585
+ return (0, instrument_2.startTrace)('Transaction.rollback', this._traceConfig, span => {
1584
1586
  if (!this.id) {
1585
1587
  span.addEvent('Transaction ID is unknown, nothing to rollback.');
1586
1588
  span.end();
@@ -2001,12 +2003,10 @@ class PartitionedDml extends Dml {
2001
2003
  this._options.excludeTxnFromChangeStreams = true;
2002
2004
  }
2003
2005
  runUpdate(query, callback) {
2004
- const traceConfig = {
2005
- sql: query,
2006
- opts: this._observabilityOptions,
2007
- dbName: this._dbName,
2008
- };
2009
- return (0, instrument_2.startTrace)('PartitionedDml.runUpdate', traceConfig, span => {
2006
+ return (0, instrument_2.startTrace)('PartitionedDml.runUpdate', {
2007
+ ...query,
2008
+ ...this._traceConfig,
2009
+ }, span => {
2010
2010
  super.runUpdate(query, (err, count) => {
2011
2011
  if (err) {
2012
2012
  (0, instrument_2.setSpanError)(span, err);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "7.20.0",
4
+ "version": "7.21.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {