google-cloud-spanner 1.13.1 → 1.14.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bba4c8dab3ed8067ad0e2d59049021c7a5fce7d87fd1ed0f20226314fd8a214
4
- data.tar.gz: '08033542e0725a4eb7424291a02ae6f1cc1495d1a407d91d84d95d8b23fe02a1'
3
+ metadata.gz: 68e910df98ae5fce8c055a045ec853ff60dfa2d8d2de3d625cad423a17a48fbf
4
+ data.tar.gz: 8eb916b7a90df206630629a9b9be3e4f83a3f3dbc10df56e346647bd5008578a
5
5
  SHA512:
6
- metadata.gz: 5a839007b3e28db0b4d206af5249410d506ada44956bce6ff899ed1c6e18cd9445a5b7e6930e80fc6ee7c7d930d87ddb4d3375b3a213371a2f42bd857788ac41
7
- data.tar.gz: 410e358dd4451e98f3527ee027f19b14e5b8306924176a2fe6bdb2469f116c1b0110ecde7280abbc7ae35368ed57253113f27b64ac2b88053bc5abd4bb270d0c
6
+ metadata.gz: 8d58bf9e158e9aabe3a05366e3a68be9d07d3f864a7a799f80127f2e72b78340db6fd984fe48eb2e64cb593825b70eef2da5753fae819b3108f42052e24eb315
7
+ data.tar.gz: 1e1e8d72cdb03be22f10a5ff47c4a268927033986e9b1f6cae41872c8a5482c8d3eb61f6bac8ecb034903beab0f725d5cd38951b23593b9c9fc9d6dbe993c528
@@ -1,5 +1,15 @@
1
1
  # Release History
2
2
 
3
+ ### 1.14.0 / 2020-02-18
4
+
5
+ #### Features
6
+
7
+ * allow custom lib name and version for telemetry purpose ([#4762](https://www.github.com/googleapis/google-cloud-ruby/issues/4762))
8
+ * allow custom lib name and version for telemetry purpose
9
+ * format docs
10
+ * added custom lib name and version prefix
11
+ * update test cases for lib name and version
12
+
3
13
  ### 1.13.1 / 2020-01-22
4
14
 
5
15
  #### Documentation
@@ -45,6 +45,20 @@ module Google
45
45
  # @param [Integer] timeout Default timeout to use in requests. Optional.
46
46
  # @param [Hash] client_config A hash of values to override the default
47
47
  # behavior of the API client. Optional.
48
+ # @param [String] lib_name Library name. This will be added as a prefix
49
+ # to the API call tracking header `x-goog-api-client` with provided
50
+ # lib version for telemetry. Optional. For example prefix looks like
51
+ # `spanner-activerecord/0.0.1 gccl/1.13.1`. Here,
52
+ # `spanner-activerecord/0.0.1` is provided custom library name and
53
+ # version and `gccl/1.13.1` represents the Cloud Spanner Ruby library
54
+ # with version.
55
+ # @param [String] lib_version Library version. This will be added as a
56
+ # prefix to the API call tracking header `x-goog-api-client` with
57
+ # provided lib name for telemetry. Optional. For example prefix look like
58
+ # `spanner-activerecord/0.0.1 gccl/1.13.1`. Here,
59
+ # `spanner-activerecord/0.0.1` is provided custom library name and
60
+ # version and `gccl/1.13.1` represents the Cloud Spanner Ruby library
61
+ # with version.
48
62
  #
49
63
  # @return [Google::Cloud::Spanner::Project]
50
64
  #
@@ -61,10 +75,13 @@ module Google
61
75
  # platform_scope = "https://www.googleapis.com/auth/cloud-platform"
62
76
  # spanner = gcloud.spanner scope: platform_scope
63
77
  #
64
- def spanner scope: nil, timeout: nil, client_config: nil
78
+ def spanner scope: nil, timeout: nil, client_config: nil, lib_name: nil,
79
+ lib_version: nil
65
80
  Google::Cloud.spanner @project, @keyfile, scope: scope,
66
81
  timeout: (timeout || @timeout),
67
- client_config: client_config
82
+ client_config: client_config,
83
+ lib_name: lib_name,
84
+ lib_version: lib_version
68
85
  end
69
86
 
70
87
  ##
@@ -92,6 +109,20 @@ module Google
92
109
  # @param [Integer] timeout Default timeout to use in requests. Optional.
93
110
  # @param [Hash] client_config A hash of values to override the default
94
111
  # behavior of the API client. Optional.
112
+ # @param [String] lib_name Library name. This will be added as a prefix
113
+ # to the API call tracking header `x-goog-api-client` with provided
114
+ # lib version for telemetry. Optional. For example prefix looks like
115
+ # `spanner-activerecord/0.0.1 gccl/1.13.1`. Here,
116
+ # `spanner-activerecord/0.0.1` is provided custom library name and
117
+ # version and `gccl/1.13.1` represents the Cloud Spanner Ruby library
118
+ # with version.
119
+ # @param [String] lib_version Library version. This will be added as a
120
+ # prefix to the API call tracking header `x-goog-api-client` with
121
+ # provided lib name for telemetry. Optional. For example prefix look like
122
+ # `spanner-activerecord/0.0.1 gccl/1.13.1`. Here,
123
+ # `spanner-activerecord/0.0.1` is provided custom library name and
124
+ # version and `gccl/1.13.1` represents the Cloud Spanner Ruby library
125
+ # with version.
95
126
  #
96
127
  # @return [Google::Cloud::Spanner::Project]
97
128
  #
@@ -101,12 +132,14 @@ module Google
101
132
  # spanner = Google::Cloud.spanner
102
133
  #
103
134
  def self.spanner project_id = nil, credentials = nil, scope: nil,
104
- timeout: nil, client_config: nil
135
+ timeout: nil, client_config: nil, lib_name: nil,
136
+ lib_version: nil
105
137
  require "google/cloud/spanner"
106
138
  Google::Cloud::Spanner.new project_id: project_id,
107
139
  credentials: credentials,
108
140
  scope: scope, timeout: timeout,
109
- client_config: client_config
141
+ client_config: client_config,
142
+ lib_name: lib_name, lib_version: lib_version
110
143
  end
111
144
  end
112
145
  end
@@ -137,4 +170,6 @@ Google::Cloud.configure.add_config! :spanner do |config|
137
170
  config.add_field! :client_config, nil, match: Hash
138
171
  config.add_field! :endpoint, nil, match: String
139
172
  config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
173
+ config.add_field! :lib_name, nil, match: String, allow_nil: true
174
+ config.add_field! :lib_version, nil, match: String, allow_nil: true
140
175
  end
@@ -34,7 +34,7 @@ module Google
34
34
  # See {file:OVERVIEW.md Spanner Overview}.
35
35
  #
36
36
  module Spanner
37
- # rubocop:disable Metrics/MethodLength
37
+ # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
38
38
 
39
39
  ##
40
40
  # Creates a new object for connecting to the Spanner service.
@@ -68,6 +68,20 @@ module Google
68
68
  # Deprecated.
69
69
  # @param [String] emulator_host Spanner emulator host. Optional.
70
70
  # If the param is nil, uses the value of the `emulator_host` config.
71
+ # @param [String] lib_name Library name. This will be added as a prefix
72
+ # to the API call tracking header `x-goog-api-client` with provided
73
+ # lib version for telemetry. Optional. For example prefix looks like
74
+ # `spanner-activerecord/0.0.1 gccl/1.13.1`. Here,
75
+ # `spanner-activerecord/0.0.1` is provided custom library name and
76
+ # version and `gccl/1.13.1` represents the Cloud Spanner Ruby library
77
+ # with version.
78
+ # @param [String] lib_version Library version. This will be added as a
79
+ # prefix to the API call tracking header `x-goog-api-client` with
80
+ # provided lib name for telemetry. Optional. For example prefix look like
81
+ # `spanner-activerecord/0.0.1 gccl/1.13.1`. Here,
82
+ # `spanner-activerecord/0.0.1` is provided custom library name and
83
+ # version and `gccl/1.13.1` represents the Cloud Spanner Ruby library
84
+ # with version.
71
85
  #
72
86
  # @return [Google::Cloud::Spanner::Project]
73
87
  #
@@ -78,7 +92,7 @@ module Google
78
92
  #
79
93
  def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
80
94
  client_config: nil, endpoint: nil, project: nil, keyfile: nil,
81
- emulator_host: nil
95
+ emulator_host: nil, lib_name: nil, lib_version: nil
82
96
  project_id ||= (project || default_project_id)
83
97
  scope ||= configure.scope
84
98
  timeout ||= configure.timeout
@@ -86,6 +100,8 @@ module Google
86
100
  endpoint ||= configure.endpoint
87
101
  credentials ||= (keyfile || default_credentials(scope: scope))
88
102
  emulator_host ||= configure.emulator_host
103
+ lib_name ||= configure.lib_name
104
+ lib_version ||= configure.lib_version
89
105
 
90
106
  if emulator_host
91
107
  credentials = :this_channel_is_insecure
@@ -106,12 +122,13 @@ module Google
106
122
  Spanner::Project.new(
107
123
  Spanner::Service.new(
108
124
  project_id, credentials,
109
- host: endpoint, timeout: timeout, client_config: client_config
125
+ host: endpoint, timeout: timeout, client_config: client_config,
126
+ lib_name: lib_name, lib_version: lib_version
110
127
  )
111
128
  )
112
129
  end
113
130
 
114
- # rubocop:enable Metrics/MethodLength
131
+ # rubocop:enable Metrics/MethodLength,Metrics/AbcSize
115
132
 
116
133
  ##
117
134
  # Configure the Google Cloud Spanner library.
@@ -133,6 +150,12 @@ module Google
133
150
  # to use the default endpoint.
134
151
  # * `emulator_host` - (String) Host name of the emulator. Defaults to
135
152
  # `ENV["SPANNER_EMULATOR_HOST"]`.
153
+ # * `lib_name` - (String) Override the lib name , or `nil`
154
+ # to use the default lib name without prefix in agent tracking
155
+ # header.
156
+ # * `lib_version` - (String) Override the lib version , or `nil`
157
+ # to use the default version lib name without prefix in agent
158
+ # tracking header.
136
159
  #
137
160
  # @return [Google::Cloud::Config] The configuration object the
138
161
  # Google::Cloud::Spanner library uses.
@@ -29,17 +29,20 @@ module Google
29
29
  # @private Represents the gRPC Spanner service, including all the API
30
30
  # methods.
31
31
  class Service
32
- attr_accessor :project, :credentials, :timeout, :client_config, :host
32
+ attr_accessor :project, :credentials, :timeout, :client_config, :host,
33
+ :lib_name, :lib_version
33
34
 
34
35
  ##
35
36
  # Creates a new Service instance.
36
37
  def initialize project, credentials, host: nil, timeout: nil,
37
- client_config: nil
38
+ client_config: nil, lib_name: nil, lib_version: nil
38
39
  @project = project
39
40
  @credentials = credentials
40
41
  @host = host || V1::SpannerClient::SERVICE_ADDRESS
41
42
  @timeout = timeout
42
43
  @client_config = client_config || {}
44
+ @lib_name = lib_name
45
+ @lib_version = lib_version
43
46
  end
44
47
 
45
48
  def channel
@@ -67,7 +70,7 @@ module Google
67
70
  client_config: client_config,
68
71
  service_address: service_address,
69
72
  service_port: service_port,
70
- lib_name: "gccl",
73
+ lib_name: lib_name_with_prefix,
71
74
  lib_version: Google::Cloud::Spanner::VERSION
72
75
  )
73
76
  end
@@ -82,7 +85,7 @@ module Google
82
85
  client_config: client_config,
83
86
  service_address: service_address,
84
87
  service_port: service_port,
85
- lib_name: "gccl",
88
+ lib_name: lib_name_with_prefix,
86
89
  lib_version: Google::Cloud::Spanner::VERSION
87
90
  )
88
91
  end
@@ -97,7 +100,7 @@ module Google
97
100
  client_config: client_config,
98
101
  service_address: service_address,
99
102
  service_port: service_port,
100
- lib_name: "gccl",
103
+ lib_name: lib_name_with_prefix,
101
104
  lib_version: Google::Cloud::Spanner::VERSION
102
105
  )
103
106
  end
@@ -459,6 +462,14 @@ module Google
459
462
  URI.parse("//#{host}").port
460
463
  end
461
464
 
465
+ def lib_name_with_prefix
466
+ return "gccl" if [nil, "gccl"].include? lib_name
467
+
468
+ value = lib_name.dup
469
+ value << "/#{lib_version}" if lib_version
470
+ value << " gccl"
471
+ end
472
+
462
473
  def default_options_from_session session_name
463
474
  default_prefix = session_name.split("/sessions/").first
464
475
  Google::Gax::CallOptions.new kwargs: \
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Spanner
19
- VERSION = "1.13.1".freeze
19
+ VERSION = "1.14.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-spanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-01-23 00:00:00.000000000 Z
12
+ date: 2020-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core