google-cloud-trace 0.34.5 → 0.35.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: 011a5cfab97710af36f316d619b812a1c41755cfe6e7da689cc99245d9f87d5a
4
- data.tar.gz: ab8c456a3e59572fde4c5c55c5d7b3fba0b08c5cbef93c0c7da548cab693b7e3
3
+ metadata.gz: 1b28e9c176fadada6b27fe995e7f4052a37c56cdbd8577734cc27941b3995aaf
4
+ data.tar.gz: 59b09025d3b1a4aada7afcc29117c6a971ae99f1f4d0dde91fed5338a1308f00
5
5
  SHA512:
6
- metadata.gz: 583dc40bedd3e8881c5a686d4e6494fb5b7dbdd4f09f30888262d5236cb860bd0ab83d5366f5669fdc4a7ae07431fd07ee74e468572f90aff99c84a9aeb3c767
7
- data.tar.gz: '006180a50fbe58cc62795057dc6523905d617d29c5be6e65a29f94381372f6aeb0593f136bbe97d375cc5fca3216a08df15a1a15d3a9c7712dcc62ed4f35a9c4'
6
+ metadata.gz: 48bd85a3d9e6cfdfe1bf3ecab47374475ebb0277c01cf48f251752e8df772215e2d67bfda3dc10bb1fadbe26ff2c2ed774091ddb3a8f593ac906416561a2b357
7
+ data.tar.gz: 7eae5d1c328748bb591b29838c6f58ff94058249aaf1ea40b679a9be67b4389e98606b0e88f2486aff9967b6714bea04785b7d60a223dd7885a0a971b84ab0b8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Release History
2
2
 
3
+ ### 0.35.0 / 2019-08-23
4
+
5
+ #### Features
6
+
7
+ * Support overriding of service endpoint
8
+
9
+ #### Documentation
10
+
11
+ * Update documentation
12
+
3
13
  ### 0.34.5 / 2019-07-31
4
14
 
5
15
  * Fix max threads setting in thread pools
data/INSTRUMENTATION.md CHANGED
@@ -16,7 +16,7 @@ you want to run on a non Google Cloud environment or you want to customize the
16
16
  default behavior.
17
17
 
18
18
  See the [Configuration
19
- Guide](https://googleapis.dev/ruby/stackdriver/INSTRUMENTATION_CONFIGURATION/latest)
19
+ Guide](https://googleapis.dev/ruby/stackdriver/latest/file.INSTRUMENTATION_CONFIGURATION.html)
20
20
  for full configuration parameters.
21
21
 
22
22
  ## Rails Integration
@@ -29,7 +29,7 @@ require "google/cloud/trace/rails"
29
29
  ```
30
30
 
31
31
  Alternatively, check out the
32
- [stackdriver](https://googleapis.dev/ruby/stackdriver/latest/file.README.html)
32
+ [stackdriver](https://googleapis.dev/ruby/stackdriver/latest)
33
33
  gem, which enables this Railtie by default.
34
34
 
35
35
  ## Rack Integration
@@ -137,6 +137,7 @@ Google::Cloud.configure.add_config! :trace do |config|
137
137
  config.add_field! :scope, nil, match: [String, Array]
138
138
  config.add_field! :timeout, nil, match: Integer
139
139
  config.add_field! :client_config, nil, match: Hash
140
+ config.add_field! :endpoint, nil, match: String
140
141
  config.add_field! :capture_stack, nil, enum: [true, false]
141
142
  config.add_field! :sampler, nil
142
143
  config.add_field! :span_id_generator, nil, match: Proc
@@ -68,6 +68,10 @@ module Google
68
68
  # * `https://www.googleapis.com/auth/cloud-platform`
69
69
  #
70
70
  # @param [Integer] timeout Default timeout to use in requests. Optional.
71
+ # @param [Hash] client_config A hash of values to override the default
72
+ # behavior of the API client. Optional.
73
+ # @param [String] endpoint Override of the endpoint host name. Optional.
74
+ # If the param is nil, uses the default endpoint.
71
75
  # @param [String] project Alias for the `project_id` argument. Deprecated.
72
76
  # @param [String] keyfile Alias for the `credentials` argument.
73
77
  # Deprecated.
@@ -85,17 +89,15 @@ module Google
85
89
  # end
86
90
  #
87
91
  def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
88
- client_config: nil, project: nil, keyfile: nil
92
+ client_config: nil, endpoint: nil, project: nil, keyfile: nil
89
93
  project_id ||= (project || default_project_id)
90
94
  scope ||= configure.scope
91
95
  timeout ||= configure.timeout
92
96
  client_config ||= configure.client_config
97
+ endpoint ||= configure.endpoint
93
98
  credentials ||= (keyfile || default_credentials(scope: scope))
94
99
 
95
- unless credentials.is_a? Google::Auth::Credentials
96
- credentials = Trace::Credentials.new credentials, scope: scope
97
- end
98
-
100
+ credentials = resolve_credentials credentials, scope
99
101
  if credentials.respond_to? :project_id
100
102
  project_id ||= credentials.project_id
101
103
  end
@@ -104,8 +106,8 @@ module Google
104
106
 
105
107
  Trace::Project.new(
106
108
  Trace::Service.new(
107
- project_id, credentials, timeout: timeout,
108
- client_config: client_config
109
+ project_id, credentials,
110
+ host: endpoint, timeout: timeout, client_config: client_config
109
111
  )
110
112
  )
111
113
  end
@@ -128,6 +130,8 @@ module Google
128
130
  # * `timeout` - (Integer) Default timeout to use in requests.
129
131
  # * `client_config` - (Hash) A hash of values to override the default
130
132
  # behavior of the API client.
133
+ # * `endpoint` - (String) Override of the endpoint host name, or `nil`
134
+ # to use the default endpoint.
131
135
  # * `capture_stack` - (Boolean) Whether to capture stack traces for each
132
136
  # span. Default: `false`
133
137
  # * `sampler` - (Proc) A sampler Proc makes the decision whether to record
@@ -173,6 +177,15 @@ module Google
173
177
  Trace::Credentials.default(scope: scope)
174
178
  end
175
179
 
180
+ ##
181
+ # @private Resolve credentials
182
+ def self.resolve_credentials credentials, scope
183
+ unless credentials.is_a? Google::Auth::Credentials
184
+ credentials = Trace::Credentials.new credentials, scope: scope
185
+ end
186
+ credentials
187
+ end
188
+
176
189
  ##
177
190
  # Set the current trace span being measured for the current thread, or
178
191
  # the current trace if no span is currently open. This may be used with
@@ -17,6 +17,7 @@ require "google/cloud/errors"
17
17
  require "google/cloud/trace/version"
18
18
  require "google/cloud/trace/v1"
19
19
  require "google/gax/errors"
20
+ require "uri"
20
21
 
21
22
  module Google
22
23
  module Cloud
@@ -27,29 +28,17 @@ module Google
27
28
  # @private
28
29
  #
29
30
  class Service
30
- ##
31
- # @private
32
- attr_accessor :project
33
-
34
- ##
35
- # @private
36
- attr_accessor :credentials
37
-
38
- ##
39
- # @private
40
- attr_accessor :timeout
41
-
42
- ##
43
- # @private
44
- attr_accessor :client_config
31
+ attr_accessor :project, :credentials, :timeout, :client_config, :host
45
32
 
46
33
  ##
47
34
  # Creates a new Service instance.
48
- def initialize project, credentials, timeout: nil, client_config: nil
35
+ def initialize project, credentials, timeout: nil, client_config: nil,
36
+ host: nil
49
37
  @project = project
50
38
  @credentials = credentials
51
39
  @timeout = timeout
52
40
  @client_config = client_config || {}
41
+ @host = host || V1::TraceServiceClient::SERVICE_ADDRESS
53
42
  end
54
43
 
55
44
  def lowlevel_client
@@ -65,6 +54,8 @@ module Google
65
54
  credentials: credentials,
66
55
  timeout: timeout,
67
56
  client_config: client_config,
57
+ service_address: service_address,
58
+ service_port: service_port,
68
59
  lib_name: "gccl",
69
60
  lib_version: Google::Cloud::Trace::VERSION
70
61
  )
@@ -143,6 +134,16 @@ module Google
143
134
 
144
135
  protected
145
136
 
137
+ def service_address
138
+ return nil if host.nil?
139
+ URI.parse("//#{host}").host
140
+ end
141
+
142
+ def service_port
143
+ return nil if host.nil?
144
+ URI.parse("//#{host}").port
145
+ end
146
+
146
147
  def execute
147
148
  yield
148
149
  rescue Google::Gax::GaxError => e
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Trace
19
- VERSION = "0.34.5".freeze
19
+ VERSION = "0.35.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-trace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.5
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-01 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core