@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.
@@ -1,7 +1,4 @@
1
1
  {
2
- "options": {
3
- "syntax": "proto3"
4
- },
5
2
  "nested": {
6
3
  "google": {
7
4
  "nested": {
@@ -29,6 +26,7 @@
29
26
  }
30
27
  },
31
28
  "FileDescriptorSet": {
29
+ "edition": "proto2",
32
30
  "fields": {
33
31
  "file": {
34
32
  "rule": "repeated",
@@ -38,6 +36,7 @@
38
36
  }
39
37
  },
40
38
  "Edition": {
39
+ "edition": "proto2",
41
40
  "values": {
42
41
  "EDITION_UNKNOWN": 0,
43
42
  "EDITION_PROTO2": 998,
@@ -53,6 +52,7 @@
53
52
  }
54
53
  },
55
54
  "FileDescriptorProto": {
55
+ "edition": "proto2",
56
56
  "fields": {
57
57
  "name": {
58
58
  "type": "string",
@@ -70,18 +70,12 @@
70
70
  "publicDependency": {
71
71
  "rule": "repeated",
72
72
  "type": "int32",
73
- "id": 10,
74
- "options": {
75
- "packed": false
76
- }
73
+ "id": 10
77
74
  },
78
75
  "weakDependency": {
79
76
  "rule": "repeated",
80
77
  "type": "int32",
81
- "id": 11,
82
- "options": {
83
- "packed": false
84
- }
78
+ "id": 11
85
79
  },
86
80
  "messageType": {
87
81
  "rule": "repeated",
@@ -122,6 +116,7 @@
122
116
  }
123
117
  },
124
118
  "DescriptorProto": {
119
+ "edition": "proto2",
125
120
  "fields": {
126
121
  "name": {
127
122
  "type": "string",
@@ -204,6 +199,7 @@
204
199
  }
205
200
  },
206
201
  "ExtensionRangeOptions": {
202
+ "edition": "proto2",
207
203
  "fields": {
208
204
  "uninterpretedOption": {
209
205
  "rule": "repeated",
@@ -277,6 +273,7 @@
277
273
  }
278
274
  },
279
275
  "FieldDescriptorProto": {
276
+ "edition": "proto2",
280
277
  "fields": {
281
278
  "name": {
282
279
  "type": "string",
@@ -356,6 +353,7 @@
356
353
  }
357
354
  },
358
355
  "OneofDescriptorProto": {
356
+ "edition": "proto2",
359
357
  "fields": {
360
358
  "name": {
361
359
  "type": "string",
@@ -368,6 +366,7 @@
368
366
  }
369
367
  },
370
368
  "EnumDescriptorProto": {
369
+ "edition": "proto2",
371
370
  "fields": {
372
371
  "name": {
373
372
  "type": "string",
@@ -409,6 +408,7 @@
409
408
  }
410
409
  },
411
410
  "EnumValueDescriptorProto": {
411
+ "edition": "proto2",
412
412
  "fields": {
413
413
  "name": {
414
414
  "type": "string",
@@ -425,6 +425,7 @@
425
425
  }
426
426
  },
427
427
  "ServiceDescriptorProto": {
428
+ "edition": "proto2",
428
429
  "fields": {
429
430
  "name": {
430
431
  "type": "string",
@@ -442,6 +443,7 @@
442
443
  }
443
444
  },
444
445
  "MethodDescriptorProto": {
446
+ "edition": "proto2",
445
447
  "fields": {
446
448
  "name": {
447
449
  "type": "string",
@@ -476,6 +478,7 @@
476
478
  }
477
479
  },
478
480
  "FileOptions": {
481
+ "edition": "proto2",
479
482
  "fields": {
480
483
  "javaPackage": {
481
484
  "type": "string",
@@ -617,6 +620,7 @@
617
620
  }
618
621
  },
619
622
  "MessageOptions": {
623
+ "edition": "proto2",
620
624
  "fields": {
621
625
  "messageSetWireFormat": {
622
626
  "type": "bool",
@@ -690,6 +694,7 @@
690
694
  ]
691
695
  },
692
696
  "FieldOptions": {
697
+ "edition": "proto2",
693
698
  "fields": {
694
699
  "ctype": {
695
700
  "type": "CType",
@@ -751,10 +756,7 @@
751
756
  "targets": {
752
757
  "rule": "repeated",
753
758
  "type": "OptionTargetType",
754
- "id": 19,
755
- "options": {
756
- "packed": false
757
- }
759
+ "id": 19
758
760
  },
759
761
  "editionDefaults": {
760
762
  "rule": "repeated",
@@ -838,6 +840,7 @@
838
840
  }
839
841
  },
840
842
  "OneofOptions": {
843
+ "edition": "proto2",
841
844
  "fields": {
842
845
  "features": {
843
846
  "type": "FeatureSet",
@@ -857,6 +860,7 @@
857
860
  ]
858
861
  },
859
862
  "EnumOptions": {
863
+ "edition": "proto2",
860
864
  "fields": {
861
865
  "allowAlias": {
862
866
  "type": "bool",
@@ -900,6 +904,7 @@
900
904
  ]
901
905
  },
902
906
  "EnumValueOptions": {
907
+ "edition": "proto2",
903
908
  "fields": {
904
909
  "deprecated": {
905
910
  "type": "bool",
@@ -933,6 +938,7 @@
933
938
  ]
934
939
  },
935
940
  "ServiceOptions": {
941
+ "edition": "proto2",
936
942
  "fields": {
937
943
  "features": {
938
944
  "type": "FeatureSet",
@@ -959,6 +965,7 @@
959
965
  ]
960
966
  },
961
967
  "MethodOptions": {
968
+ "edition": "proto2",
962
969
  "fields": {
963
970
  "deprecated": {
964
971
  "type": "bool",
@@ -1001,6 +1008,7 @@
1001
1008
  }
1002
1009
  },
1003
1010
  "UninterpretedOption": {
1011
+ "edition": "proto2",
1004
1012
  "fields": {
1005
1013
  "name": {
1006
1014
  "rule": "repeated",
@@ -1050,6 +1058,7 @@
1050
1058
  }
1051
1059
  },
1052
1060
  "FeatureSet": {
1061
+ "edition": "proto2",
1053
1062
  "fields": {
1054
1063
  "fieldPresence": {
1055
1064
  "type": "FieldPresence",
@@ -1191,6 +1200,7 @@
1191
1200
  }
1192
1201
  },
1193
1202
  "FeatureSetDefaults": {
1203
+ "edition": "proto2",
1194
1204
  "fields": {
1195
1205
  "defaults": {
1196
1206
  "rule": "repeated",
@@ -1222,6 +1232,7 @@
1222
1232
  }
1223
1233
  },
1224
1234
  "SourceCodeInfo": {
1235
+ "edition": "proto2",
1225
1236
  "fields": {
1226
1237
  "location": {
1227
1238
  "rule": "repeated",
@@ -1235,12 +1246,18 @@
1235
1246
  "path": {
1236
1247
  "rule": "repeated",
1237
1248
  "type": "int32",
1238
- "id": 1
1249
+ "id": 1,
1250
+ "options": {
1251
+ "packed": true
1252
+ }
1239
1253
  },
1240
1254
  "span": {
1241
1255
  "rule": "repeated",
1242
1256
  "type": "int32",
1243
- "id": 2
1257
+ "id": 2,
1258
+ "options": {
1259
+ "packed": true
1260
+ }
1244
1261
  },
1245
1262
  "leadingComments": {
1246
1263
  "type": "string",
@@ -1260,6 +1277,7 @@
1260
1277
  }
1261
1278
  },
1262
1279
  "GeneratedCodeInfo": {
1280
+ "edition": "proto2",
1263
1281
  "fields": {
1264
1282
  "annotation": {
1265
1283
  "rule": "repeated",
@@ -1273,7 +1291,10 @@
1273
1291
  "path": {
1274
1292
  "rule": "repeated",
1275
1293
  "type": "int32",
1276
- "id": 1
1294
+ "id": 1,
1295
+ "options": {
1296
+ "packed": true
1297
+ }
1277
1298
  },
1278
1299
  "sourceFile": {
1279
1300
  "type": "string",
@@ -741,19 +741,23 @@ class Database extends common.GrpcServiceObject {
741
741
  });
742
742
  }
743
743
  getTransaction(optionsOrCallback, callback) {
744
+ var _a;
744
745
  const cb = typeof optionsOrCallback === 'function'
745
746
  ? optionsOrCallback
746
747
  : callback;
747
748
  const options = typeof optionsOrCallback === 'object' && optionsOrCallback
748
749
  ? optionsOrCallback
749
750
  : {};
750
- return (0, instrument_1.startTrace)('Database.getTransaction', this._traceConfig, span => {
751
+ return (0, instrument_1.startTrace)('Database.getTransaction', {
752
+ ...this._traceConfig,
753
+ transactionTag: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
754
+ }, span => {
751
755
  this.pool_.getSession((err, session, transaction) => {
752
- if (options.requestOptions) {
753
- transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
754
- }
755
- transaction === null || transaction === void 0 ? void 0 : transaction.setReadWriteTransactionOptions(options);
756
756
  if (!err) {
757
+ if (options.requestOptions) {
758
+ transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
759
+ }
760
+ transaction === null || transaction === void 0 ? void 0 : transaction.setReadWriteTransactionOptions(options);
757
761
  span.addEvent('Using Session', { 'session.id': session === null || session === void 0 ? void 0 : session.id });
758
762
  transaction._observabilityOptions = this._observabilityOptions;
759
763
  this._releaseOnEnd(session, transaction, span);
@@ -919,11 +923,10 @@ class Database extends common.GrpcServiceObject {
919
923
  const options = typeof optionsOrCallback === 'object'
920
924
  ? optionsOrCallback
921
925
  : {};
922
- const traceConfig = {
923
- sql: query,
926
+ return (0, instrument_1.startTrace)('Database.run', {
927
+ ...query,
924
928
  ...this._traceConfig,
925
- };
926
- return (0, instrument_1.startTrace)('Database.run', traceConfig, span => {
929
+ }, span => {
927
930
  this.runStream(query, options)
928
931
  .on('error', err => {
929
932
  (0, instrument_1.setSpanError)(span, err);
@@ -946,11 +949,12 @@ class Database extends common.GrpcServiceObject {
946
949
  });
947
950
  }
948
951
  runPartitionedUpdate(query, callback) {
949
- const traceConfig = {
950
- sql: query,
952
+ var _a;
953
+ return (0, instrument_1.startTrace)('Database.runPartitionedUpdate', {
954
+ ...query,
951
955
  ...this._traceConfig,
952
- };
953
- return (0, instrument_1.startTrace)('Database.runPartitionedUpdate', traceConfig, span => {
956
+ requestTag: (_a = query === null || query === void 0 ? void 0 : query.requestOptions) === null || _a === void 0 ? void 0 : _a.requestTag,
957
+ }, span => {
954
958
  this.sessionFactory_.getSessionForPartitionedOps((err, session) => {
955
959
  if (err) {
956
960
  (0, instrument_1.setSpanError)(span, err);
@@ -1122,12 +1126,13 @@ class Database extends common.GrpcServiceObject {
1122
1126
  * ```
1123
1127
  */
1124
1128
  runStream(query, options) {
1129
+ var _a;
1125
1130
  const proxyStream = through.obj();
1126
- const traceConfig = {
1127
- sql: query,
1131
+ return (0, instrument_1.startTrace)('Database.runStream', {
1132
+ ...query,
1128
1133
  ...this._traceConfig,
1129
- };
1130
- return (0, instrument_1.startTrace)('Database.runStream', traceConfig, span => {
1134
+ requestTag: (_a = query === null || query === void 0 ? void 0 : query.requestOptions) === null || _a === void 0 ? void 0 : _a.requestTag,
1135
+ }, span => {
1131
1136
  this.sessionFactory_.getSession((err, session) => {
1132
1137
  if (err) {
1133
1138
  (0, instrument_1.setSpanError)(span, err);
@@ -1189,13 +1194,17 @@ class Database extends common.GrpcServiceObject {
1189
1194
  });
1190
1195
  }
1191
1196
  runTransaction(optionsOrRunFn, fn) {
1197
+ var _a;
1192
1198
  const runFn = typeof optionsOrRunFn === 'function'
1193
1199
  ? optionsOrRunFn
1194
1200
  : fn;
1195
1201
  const options = typeof optionsOrRunFn === 'object' && optionsOrRunFn
1196
1202
  ? optionsOrRunFn
1197
1203
  : {};
1198
- (0, instrument_1.startTrace)('Database.runTransaction', this._traceConfig, span => {
1204
+ (0, instrument_1.startTrace)('Database.runTransaction', {
1205
+ ...this._traceConfig,
1206
+ transactionTag: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
1207
+ }, span => {
1199
1208
  this.pool_.getSession((err, session, transaction) => {
1200
1209
  if (err) {
1201
1210
  (0, instrument_1.setSpanError)(span, err);
@@ -1214,6 +1223,7 @@ class Database extends common.GrpcServiceObject {
1214
1223
  return;
1215
1224
  }
1216
1225
  transaction._observabilityOptions = this._observabilityOptions;
1226
+ transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
1217
1227
  transaction.setReadWriteTransactionOptions(options);
1218
1228
  const release = () => {
1219
1229
  this.pool_.release(session);
@@ -1297,6 +1307,7 @@ class Database extends common.GrpcServiceObject {
1297
1307
  * ```
1298
1308
  */
1299
1309
  async runTransactionAsync(optionsOrRunFn, fn) {
1310
+ var _a;
1300
1311
  const runFn = typeof optionsOrRunFn === 'function'
1301
1312
  ? optionsOrRunFn
1302
1313
  : fn;
@@ -1305,7 +1316,10 @@ class Database extends common.GrpcServiceObject {
1305
1316
  : {};
1306
1317
  let sessionId = '';
1307
1318
  const getSession = this.pool_.getSession.bind(this.pool_);
1308
- return (0, instrument_1.startTrace)('Database.runTransactionAsync', this._traceConfig, async (span) => {
1319
+ return (0, instrument_1.startTrace)('Database.runTransactionAsync', {
1320
+ ...this._traceConfig,
1321
+ transactionTag: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
1322
+ }, async (span) => {
1309
1323
  // Loop to retry 'Session not found' errors.
1310
1324
  // (and yes, we like while (true) more than for (;;) here)
1311
1325
  // eslint-disable-next-line no-constant-condition
@@ -1402,8 +1416,12 @@ class Database extends common.GrpcServiceObject {
1402
1416
  * ```
1403
1417
  */
1404
1418
  batchWriteAtLeastOnce(mutationGroups, options) {
1419
+ var _a;
1405
1420
  const proxyStream = through.obj();
1406
- return (0, instrument_1.startTrace)('Database.batchWriteAtLeastOnce', this._traceConfig, span => {
1421
+ return (0, instrument_1.startTrace)('Database.batchWriteAtLeastOnce', {
1422
+ ...this._traceConfig,
1423
+ transactionTag: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
1424
+ }, span => {
1407
1425
  this.pool_.getSession((err, session) => {
1408
1426
  if (err) {
1409
1427
  proxyStream.destroy(err);
@@ -39,6 +39,8 @@ interface traceConfig {
39
39
  sql?: string | SQLStatement;
40
40
  tableName?: string;
41
41
  dbName?: string;
42
+ transactionTag?: string | null;
43
+ requestTag?: string | null;
42
44
  opts?: ObservabilityOptions;
43
45
  }
44
46
  declare const SPAN_NAMESPACE_PREFIX = "CloudSpanner";
@@ -79,27 +79,32 @@ function startTrace(spanNameSuffix, config, cb) {
79
79
  }
80
80
  return getTracer((_a = config.opts) === null || _a === void 0 ? void 0 : _a.tracerProvider).startActiveSpan(SPAN_NAMESPACE_PREFIX + '.' + spanNameSuffix, { kind: api_1.SpanKind.CLIENT }, span => {
81
81
  var _a;
82
- span.setAttribute(semantic_conventions_1.SEMATTRS_DB_SYSTEM, 'spanner');
83
82
  span.setAttribute(semantic_conventions_1.ATTR_OTEL_SCOPE_NAME, TRACER_NAME);
84
83
  span.setAttribute(semantic_conventions_1.ATTR_OTEL_SCOPE_VERSION, TRACER_VERSION);
85
84
  span.setAttribute('gcp.client.service', 'spanner');
86
85
  span.setAttribute('gcp.client.version', TRACER_VERSION);
87
86
  span.setAttribute('gcp.client.repo', 'googleapis/nodejs-spanner');
88
87
  if (config.tableName) {
89
- span.setAttribute(semantic_conventions_1.SEMATTRS_DB_SQL_TABLE, config.tableName);
88
+ span.setAttribute('db.sql.table', config.tableName);
90
89
  }
91
90
  if (config.dbName) {
92
- span.setAttribute(semantic_conventions_1.SEMATTRS_DB_NAME, config.dbName);
91
+ span.setAttribute('db.name', config.dbName);
92
+ }
93
+ if (config.requestTag) {
94
+ span.setAttribute('request.tag', config.requestTag);
95
+ }
96
+ if (config.transactionTag) {
97
+ span.setAttribute('transaction.tag', config.transactionTag);
93
98
  }
94
99
  const allowExtendedTracing = optedInPII || ((_a = config.opts) === null || _a === void 0 ? void 0 : _a.enableExtendedTracing);
95
100
  if (config.sql && allowExtendedTracing) {
96
101
  const sql = config.sql;
97
102
  if (typeof sql === 'string') {
98
- span.setAttribute(semantic_conventions_1.SEMATTRS_DB_STATEMENT, sql);
103
+ span.setAttribute('db.statement', sql);
99
104
  }
100
105
  else {
101
106
  const stmt = sql;
102
- span.setAttribute(semantic_conventions_1.SEMATTRS_DB_STATEMENT, stmt.sql);
107
+ span.setAttribute('db.statement', stmt.sql);
103
108
  }
104
109
  }
105
110
  // If at all the invoked function throws an exception,
@@ -22,6 +22,7 @@ import { Snapshot, Transaction, PartitionedDml, TimestampBounds } from './transa
22
22
  import { google } from '../protos/protos';
23
23
  import { Database } from './database';
24
24
  import { NormalCallback } from './common';
25
+ import { ObservabilityOptions } from './instrument';
25
26
  import { grpc, CallOptions } from 'google-gax';
26
27
  import IRequestOptions = google.spanner.v1.IRequestOptions;
27
28
  export type GetSessionResponse = [Session, r.Response];
@@ -95,6 +96,7 @@ export declare class Session extends common.GrpcServiceObject {
95
96
  commonHeaders_: {
96
97
  [k: string]: string;
97
98
  };
99
+ _observabilityOptions?: ObservabilityOptions;
98
100
  constructor(database: Database, name?: string);
99
101
  /**
100
102
  * Delete a session.
@@ -200,7 +200,8 @@ class Session extends common.GrpcServiceObject {
200
200
  });
201
201
  },
202
202
  });
203
- this.commonHeaders_ = (0, common_1.getCommonHeaders)(this.parent.formattedName_, (_a = database._observabilityOptions) === null || _a === void 0 ? void 0 : _a.enableEndToEndTracing);
203
+ this._observabilityOptions = database._observabilityOptions;
204
+ this.commonHeaders_ = (0, common_1.getCommonHeaders)(this.parent.formattedName_, (_a = this._observabilityOptions) === null || _a === void 0 ? void 0 : _a.enableEndToEndTracing);
204
205
  this.request = database.request;
205
206
  this.requestStream = database.requestStream;
206
207
  if (name) {
@@ -235,10 +235,12 @@ class Table {
235
235
  * @param {function} callback The callback function.
236
236
  */
237
237
  _mutate(method, rows, options = {}, callback) {
238
+ var _a;
238
239
  const traceConfig = {
239
240
  opts: this._observabilityOptions,
240
241
  tableName: this.name,
241
242
  dbName: this.getDBName(),
243
+ transactionTag: (_a = options === null || options === void 0 ? void 0 : options.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag,
242
244
  };
243
245
  (0, instrument_1.startTrace)('Table.' + method, traceConfig, span => {
244
246
  const requestOptions = 'requestOptions' in options ? options.requestOptions : {};
@@ -29,7 +29,7 @@ import { google } from '../protos/protos';
29
29
  import IQueryOptions = google.spanner.v1.ExecuteSqlRequest.IQueryOptions;
30
30
  import IRequestOptions = google.spanner.v1.IRequestOptions;
31
31
  import { Spanner } from '.';
32
- import { ObservabilityOptions } from './instrument';
32
+ import { ObservabilityOptions, traceConfig } from './instrument';
33
33
  import { RunTransactionOptions } from './transaction-runner';
34
34
  export type Rows = Array<Row | Json>;
35
35
  export interface TimestampBounds {
@@ -247,6 +247,7 @@ export declare class Snapshot extends EventEmitter {
247
247
  };
248
248
  requestOptions?: Pick<IRequestOptions, 'transactionTag'>;
249
249
  _observabilityOptions?: ObservabilityOptions;
250
+ _traceConfig: traceConfig;
250
251
  protected _dbName?: string;
251
252
  /**
252
253
  * The transaction ID.