google-cloud-trace 0.24.1 → 0.25.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 +4 -4
- data/README.md +75 -26
- data/lib/google/cloud/trace.rb +24 -2
- data/lib/google/cloud/trace/middleware.rb +48 -18
- data/lib/google/cloud/trace/rails.rb +90 -120
- data/lib/google/cloud/trace/trace_record.rb +2 -1
- data/lib/google/cloud/trace/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 537ea43256a80488f659a7b6ed8f41f23f935e13
|
4
|
+
data.tar.gz: 4e0d0e17d29ffac6d6323eaebf2838332f14c072
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b874bb6c50a4b10f634311b69b45055551061b21f75125823edec6f78c181d87a0efb8ae241eb4e47a3fb7c28f259e2b6dc27c47b047332784a0e758505c7e56
|
7
|
+
data.tar.gz: 451c43e68ad1ca3561306c9f4a30a060ce33838d0fff9a11d303065aa0dd2f985bfe57c2c53115d0ab41230900b380ed79a8026d734deac164f809eb6222eb2b
|
data/README.md
CHANGED
@@ -1,45 +1,94 @@
|
|
1
|
-
|
2
|
-
=================================================
|
1
|
+
# google-cloud-trace
|
3
2
|
|
4
|
-
google
|
5
|
-
|
3
|
+
[Stackdriver Trace](https://cloud.google.com/trace/) is a distributed tracing
|
4
|
+
system that collects latency data from your applications and displays it in the
|
5
|
+
Google Cloud Platform Console. You can track how requests propagate through your
|
6
|
+
application and receive detailed near real-time performance insights.
|
7
|
+
Stackdriver Trace automatically analyzes all of your application's traces to
|
8
|
+
generate in-depth latency reports to surface performance degradations, and can
|
9
|
+
capture traces from all of your VMs, containers, or Google App Engine projects.
|
6
10
|
|
11
|
+
- [google-cloud-trace API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-trace/latest)
|
12
|
+
- [google-cloud-trace instrumentation documentation](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-trace/guides/instrumentation)
|
13
|
+
- [google-cloud-trace on RubyGems](https://rubygems.org/gems/google-cloud-trace)
|
14
|
+
- [Stackdriver Trace documentation](https://cloud.google.com/trace/docs/)
|
7
15
|
|
8
|
-
|
9
|
-
|
10
|
-
|
16
|
+
## Quick Start
|
17
|
+
```sh
|
18
|
+
$ gem install google-cloud-trace
|
19
|
+
```
|
11
20
|
|
12
|
-
|
13
|
-
---------------
|
21
|
+
## Authentication
|
14
22
|
|
15
|
-
|
23
|
+
The Instrumentation client and API use Service Account credentials to connect
|
24
|
+
to Google Cloud services. When running on Google Cloud Platform environments,
|
25
|
+
the credentials will be discovered automatically. When running on other
|
26
|
+
environments the Service Account credentials can be specified by providing the
|
27
|
+
path to the JSON file, or the JSON itself, in environment variables or
|
28
|
+
configuration code.
|
16
29
|
|
17
|
-
|
30
|
+
Instructions and configuration options are covered in the
|
31
|
+
[Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-trace/guides/authentication).
|
18
32
|
|
33
|
+
## Example
|
19
34
|
|
20
|
-
|
21
|
-
|
35
|
+
```ruby
|
36
|
+
require "google/cloud/trace"
|
22
37
|
|
23
|
-
|
24
|
-
Once done, you can then run the following command in your terminal:
|
38
|
+
trace = Google::Cloud::Trace.new
|
25
39
|
|
26
|
-
|
40
|
+
result_set = trace.list_traces Time.now - 3600, Time.now
|
41
|
+
result_set.each do |trace_record|
|
42
|
+
puts "Retrieved trace ID: #{trace_record.trace_id}"
|
43
|
+
end
|
44
|
+
```
|
27
45
|
|
28
|
-
|
46
|
+
## Rails and Rack Integration
|
29
47
|
|
30
|
-
|
48
|
+
This library also provides a built-in Railtie for Ruby on Rails integration. To
|
49
|
+
do this, simply add this line to config/application.rb:
|
50
|
+
```ruby
|
51
|
+
require "google/cloud/trace/rails"
|
52
|
+
```
|
31
53
|
|
32
|
-
|
54
|
+
Alternatively, check out the [stackdriver](../stackdriver) gem, which includes
|
55
|
+
this library and enables the Railtie by default.
|
33
56
|
|
34
|
-
|
35
|
-
[
|
57
|
+
For Rack integration and more examples, see the
|
58
|
+
[Instrumentation Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-error_reporting/guides/instrumentation).
|
36
59
|
|
60
|
+
## Supported Ruby Versions
|
37
61
|
|
38
|
-
|
39
|
-
-------------------
|
62
|
+
This library is supported on Ruby 2.0+.
|
40
63
|
|
41
|
-
|
64
|
+
## Versioning
|
42
65
|
|
43
|
-
|
66
|
+
This library follows [Semantic Versioning](http://semver.org/).
|
44
67
|
|
45
|
-
|
68
|
+
It is currently in major version zero (0.y.z), which means that anything may
|
69
|
+
change at any time and the public API should not be considered stable.
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Contributions to this library are always welcome and highly encouraged.
|
74
|
+
|
75
|
+
See the
|
76
|
+
[Contributing Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/contributing)
|
77
|
+
for more information on how to get started.
|
78
|
+
|
79
|
+
Please note that this project is released with a Contributor Code of Conduct. By
|
80
|
+
participating in this project you agree to abide by its terms. See
|
81
|
+
[Code of Conduct](../CODE_OF_CONDUCT.md) for more information.
|
82
|
+
|
83
|
+
## License
|
84
|
+
|
85
|
+
This library is licensed under Apache 2.0. Full license text is available in
|
86
|
+
[LICENSE](LICENSE).
|
87
|
+
|
88
|
+
## Support
|
89
|
+
|
90
|
+
Please
|
91
|
+
[report bugs at the project on Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues).
|
92
|
+
Don't hesitate to
|
93
|
+
[ask questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby)
|
94
|
+
about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
data/lib/google/cloud/trace.rb
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
|
16
|
-
require "stackdriver/core/trace_context"
|
17
16
|
require "google-cloud-trace"
|
18
17
|
require "google/cloud/trace/version"
|
19
18
|
require "google/cloud/trace/credentials"
|
@@ -28,11 +27,12 @@ require "google/cloud/trace/span_kind"
|
|
28
27
|
require "google/cloud/trace/time_sampler"
|
29
28
|
require "google/cloud/trace/trace_record"
|
30
29
|
require "google/cloud/trace/utils"
|
30
|
+
require "stackdriver/core"
|
31
31
|
|
32
32
|
module Google
|
33
33
|
module Cloud
|
34
34
|
##
|
35
|
-
# #
|
35
|
+
# # Trace
|
36
36
|
#
|
37
37
|
# The Stackdriver Trace service collects and stores latency data from your
|
38
38
|
# application and displays it in the Google Cloud Platform Console, giving
|
@@ -191,6 +191,12 @@ module Google
|
|
191
191
|
module Trace
|
192
192
|
THREAD_KEY = :__stackdriver_trace_span__
|
193
193
|
|
194
|
+
# Initialize :error_reporting as a nested Configuration under
|
195
|
+
# Google::Cloud if haven't already
|
196
|
+
unless Google::Cloud.configure.option? :trace
|
197
|
+
Google::Cloud.configure.add_options :trace
|
198
|
+
end
|
199
|
+
|
194
200
|
##
|
195
201
|
# Creates a new object for connecting to the Stackdriver Trace service.
|
196
202
|
# Each call creates a new connection.
|
@@ -335,6 +341,22 @@ module Google
|
|
335
341
|
yield nil
|
336
342
|
end
|
337
343
|
end
|
344
|
+
|
345
|
+
##
|
346
|
+
# Configure the Stackdriver Trace instrumentation Middleware.
|
347
|
+
#
|
348
|
+
# See the [Configuration
|
349
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
|
350
|
+
# for full configuration parameters.
|
351
|
+
#
|
352
|
+
# @return [Stackdriver::Core::Configuration] The configuration object
|
353
|
+
# the Google::Cloud::ErrorReporting module uses.
|
354
|
+
#
|
355
|
+
def self.configure
|
356
|
+
yield Google::Cloud.configure.trace if block_given?
|
357
|
+
|
358
|
+
Google::Cloud.configure.trace
|
359
|
+
end
|
338
360
|
end
|
339
361
|
end
|
340
362
|
end
|
@@ -114,26 +114,23 @@ module Google
|
|
114
114
|
# @param [Rack Application] app Rack application
|
115
115
|
# @param [Google::Cloud::Trace::Service] service The service object.
|
116
116
|
# Optional if running on GCE.
|
117
|
-
# @param [
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
# may be any Proc that implements the sampling contract.
|
117
|
+
# @param [Hash] *kwargs Hash of configuration settings. Used for
|
118
|
+
# backward API compatibility. See the [Configuration
|
119
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
|
120
|
+
# for the prefered way to set configuration parameters.
|
122
121
|
#
|
123
|
-
def initialize app,
|
124
|
-
service: nil,
|
125
|
-
capture_stack: false,
|
126
|
-
sampler: nil,
|
127
|
-
span_id_generator: nil
|
122
|
+
def initialize app, service: nil, **kwargs
|
128
123
|
@app = app
|
129
|
-
|
130
|
-
|
131
|
-
|
124
|
+
|
125
|
+
load_config kwargs
|
126
|
+
|
132
127
|
if service
|
133
128
|
@service = service
|
134
129
|
else
|
135
|
-
project_id =
|
136
|
-
|
130
|
+
project_id = configuration.project_id
|
131
|
+
if project_id
|
132
|
+
@service = Google::Cloud::Trace.new(project: project_id).service
|
133
|
+
end
|
137
134
|
end
|
138
135
|
end
|
139
136
|
|
@@ -172,13 +169,14 @@ module Google
|
|
172
169
|
def get_trace_context env
|
173
170
|
Stackdriver::Core::TraceContext.parse_rack_env(env) do |tc|
|
174
171
|
if tc.sampled?.nil?
|
175
|
-
sampler =
|
172
|
+
sampler = configuration.sampler ||
|
173
|
+
Google::Cloud::Trace::TimeSampler.default
|
176
174
|
sampled = sampler.call env
|
177
175
|
tc = Stackdriver::Core::TraceContext.new \
|
178
176
|
trace_id: tc.trace_id,
|
179
177
|
span_id: tc.span_id,
|
180
178
|
sampled: sampled,
|
181
|
-
capture_stack: sampled &&
|
179
|
+
capture_stack: sampled && configuration.capture_stack
|
182
180
|
end
|
183
181
|
tc
|
184
182
|
end
|
@@ -195,7 +193,7 @@ module Google
|
|
195
193
|
Google::Cloud::Trace::TraceRecord.new \
|
196
194
|
@service.project,
|
197
195
|
trace_context,
|
198
|
-
span_id_generator:
|
196
|
+
span_id_generator: configuration.span_id_generator
|
199
197
|
end
|
200
198
|
|
201
199
|
##
|
@@ -352,6 +350,38 @@ module Google
|
|
352
350
|
end
|
353
351
|
result
|
354
352
|
end
|
353
|
+
|
354
|
+
private
|
355
|
+
|
356
|
+
##
|
357
|
+
# Consolidate configurations from various sources. Also set
|
358
|
+
# instrumentation config parameters to default values if not set
|
359
|
+
# already.
|
360
|
+
#
|
361
|
+
def load_config **kwargs
|
362
|
+
configuration.capture_stack = kwargs[:capture_stack] ||
|
363
|
+
configuration.capture_stack
|
364
|
+
configuration.sampler = kwargs[:sampler] ||
|
365
|
+
configuration.sampler
|
366
|
+
configuration.span_id_generator = kwargs[:span_id_generator] ||
|
367
|
+
configuration.span_id_generator
|
368
|
+
|
369
|
+
init_default_config
|
370
|
+
end
|
371
|
+
|
372
|
+
##
|
373
|
+
# Fallback to default configuration values if not defined already
|
374
|
+
def init_default_config
|
375
|
+
configuration.project_id ||= Cloud.configure.project_id ||
|
376
|
+
Trace::Project.default_project
|
377
|
+
configuration.capture_stack ||= false
|
378
|
+
end
|
379
|
+
|
380
|
+
##
|
381
|
+
# @private Get Google::Cloud::Trace.configure
|
382
|
+
def configuration
|
383
|
+
Google::Cloud::Trace.configure
|
384
|
+
end
|
355
385
|
end
|
356
386
|
end
|
357
387
|
end
|
@@ -43,59 +43,9 @@ module Google
|
|
43
43
|
#
|
44
44
|
# ## Configuration
|
45
45
|
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# config.google_cloud.use_trace = true | false
|
50
|
-
# ```
|
51
|
-
#
|
52
|
-
# Normally, tracing is activated when `RAILS_ENV` is set to `production`
|
53
|
-
# and credentials are available. You can override this and enable tracing
|
54
|
-
# in other environments by setting `use_trace` explicitly.
|
55
|
-
#
|
56
|
-
# ```ruby
|
57
|
-
# config.google_cloud.keyfile = "path/to/file"
|
58
|
-
# ```
|
59
|
-
#
|
60
|
-
# If your application is running on Google Cloud Platform, it will
|
61
|
-
# automatically use credentials available to your project. However, if
|
62
|
-
# you are running an application locally or on a different hosting
|
63
|
-
# provider, you may provide a path to your credentials file using this
|
64
|
-
# configuration.
|
65
|
-
#
|
66
|
-
# ```ruby
|
67
|
-
# config.google_cloud.project_id = "my-project-id"
|
68
|
-
# ```
|
69
|
-
#
|
70
|
-
# If your application is running on Google Cloud Platform, it will
|
71
|
-
# automatically select the project under which it is running. However, if
|
72
|
-
# you are running an application locally or on a different hosting
|
73
|
-
# provider, or if you want to log traces to a different project than you
|
74
|
-
# are using to host your application, you may provide the project ID.
|
75
|
-
#
|
76
|
-
# ```ruby
|
77
|
-
# config.google_cloud.trace.notifications = ["event1", "event2"]
|
78
|
-
# ```
|
79
|
-
#
|
80
|
-
# By default, this Railtie subscribes to ActiveSupport notifications
|
81
|
-
# emitted by ActiveRecord queries, rendering, and emailing functions.
|
82
|
-
# See {DEFAULT_NOTIFICATIONS}. If you want to customize the list of
|
83
|
-
# notification types, edit the notifications configuration.
|
84
|
-
#
|
85
|
-
# ```ruby
|
86
|
-
# config.google_cloud.trace.max_data_length = 1024
|
87
|
-
# ```
|
88
|
-
#
|
89
|
-
# The maximum length of span properties recorded with ActiveSupport
|
90
|
-
# notification events. Any property value larger than this length is
|
91
|
-
# truncated.
|
92
|
-
#
|
93
|
-
# ```ruby
|
94
|
-
# config.google_cloud.trace.capture_stack = true | false
|
95
|
-
# ```
|
96
|
-
#
|
97
|
-
# Whether to capture the call stack with each trace span. Default is
|
98
|
-
# false.
|
46
|
+
# See the [Configuration
|
47
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
|
48
|
+
# on how to configure the Railtie and Middleware.
|
99
49
|
#
|
100
50
|
# ## Measuring custom functionality
|
101
51
|
#
|
@@ -135,67 +85,9 @@ module Google
|
|
135
85
|
Google::Cloud::Trace::Notifications::DEFAULT_MAX_DATA_LENGTH
|
136
86
|
|
137
87
|
initializer "Google.Cloud.Trace" do |app|
|
138
|
-
|
139
|
-
Google::Cloud::Trace::Railtie.init_trace app
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
##
|
144
|
-
# Determine whether to use Stackdriver Trace or not.
|
145
|
-
#
|
146
|
-
# Returns true if valid GCP project_id and keyfile are provided and
|
147
|
-
# either Rails is in "production" environment or
|
148
|
-
# config.google_cloud.use_trace is explicitly true. Otherwise false.
|
149
|
-
#
|
150
|
-
# @param [Rails::Railtie::Configuration] config The
|
151
|
-
# Rails.application.config
|
152
|
-
#
|
153
|
-
# @return [Boolean] Whether to use Stackdriver Trace
|
154
|
-
#
|
155
|
-
def self.use_trace? config
|
156
|
-
gcp_config = config.google_cloud
|
157
|
-
|
158
|
-
# Return false if config.google_cloud.use_trace is
|
159
|
-
# explicitly false
|
160
|
-
return false if gcp_config.key?(:use_trace) &&
|
161
|
-
!gcp_config.use_trace
|
88
|
+
self.class.consolidate_rails_config app.config
|
162
89
|
|
163
|
-
|
164
|
-
# authorize.
|
165
|
-
keyfile = gcp_config.trace.keyfile || gcp_config.keyfile
|
166
|
-
begin
|
167
|
-
Google::Cloud::Trace::Credentials.credentials_with_scope keyfile
|
168
|
-
rescue Exception => e
|
169
|
-
STDOUT.puts "Note: Google::Cloud::Trace is disabled because " \
|
170
|
-
"it failed to authorize with the service. (#{e.message})"
|
171
|
-
return false
|
172
|
-
end
|
173
|
-
|
174
|
-
if project_id(config).to_s.empty?
|
175
|
-
STDOUT.puts "Note: Google::Cloud::Trace is disabled because " \
|
176
|
-
"the project ID could not be determined."
|
177
|
-
return false
|
178
|
-
end
|
179
|
-
|
180
|
-
# Otherwise return true if Rails is running in production or
|
181
|
-
# config.google_cloud.use_trace is explicitly true
|
182
|
-
Rails.env.production? ||
|
183
|
-
(gcp_config.key?(:use_trace) && gcp_config.use_trace)
|
184
|
-
end
|
185
|
-
|
186
|
-
##
|
187
|
-
# Return the effective project ID for this app, given a Rails config.
|
188
|
-
#
|
189
|
-
# @param [Rails::Railtie::Configuration] config The
|
190
|
-
# Rails.application.config
|
191
|
-
# @return [String] The project ID, or nil if not found.
|
192
|
-
#
|
193
|
-
def self.project_id config
|
194
|
-
config.google_cloud.trace.project_id ||
|
195
|
-
config.google_cloud.project_id ||
|
196
|
-
ENV["TRACE_PROJECT"] ||
|
197
|
-
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
198
|
-
Google::Cloud.env.project_id
|
90
|
+
self.class.init_middleware app if Cloud.configure.use_trace
|
199
91
|
end
|
200
92
|
|
201
93
|
##
|
@@ -204,11 +96,10 @@ module Google
|
|
204
96
|
#
|
205
97
|
# @private
|
206
98
|
#
|
207
|
-
def self.
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
keyfile = trace_config.keyfile || gcp_config.keyfile
|
99
|
+
def self.init_middleware app
|
100
|
+
trace_config = Trace.configure
|
101
|
+
project_id = trace_config.project_id
|
102
|
+
keyfile = trace_config.keyfile
|
212
103
|
|
213
104
|
tracer = Google::Cloud::Trace.new project: project_id,
|
214
105
|
keyfile: keyfile
|
@@ -216,8 +107,7 @@ module Google
|
|
216
107
|
app.middleware.insert_before \
|
217
108
|
Rack::Runtime,
|
218
109
|
Google::Cloud::Trace::Middleware,
|
219
|
-
service: tracer.service
|
220
|
-
capture_stack: trace_config.capture_stack
|
110
|
+
service: tracer.service
|
221
111
|
|
222
112
|
trace_config.notifications.each do |type|
|
223
113
|
Google::Cloud::Trace::Notifications.instrument \
|
@@ -226,6 +116,86 @@ module Google
|
|
226
116
|
capture_stack: trace_config.capture_stack
|
227
117
|
end
|
228
118
|
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# @private Consolidate Rails configuration into Trace instrumentation
|
122
|
+
# configuration. Also consolidate the `use_trace` setting by verifying
|
123
|
+
# credentials and Rails environment. The `use_trace` setting will be
|
124
|
+
# true if credentials are valid, and the setting is manually set to
|
125
|
+
# true or Rails is in production environment.
|
126
|
+
#
|
127
|
+
# @param [Rails::Railtie::Configuration] config The
|
128
|
+
# Rails.application.config
|
129
|
+
#
|
130
|
+
def self.consolidate_rails_config config
|
131
|
+
merge_rails_config config
|
132
|
+
|
133
|
+
init_default_config
|
134
|
+
|
135
|
+
# Done if Google::Cloud.configure.use_trace is explicitly false
|
136
|
+
return if Google::Cloud.configure.use_trace == false
|
137
|
+
|
138
|
+
# Verify credentials and set use_error_reporting to false if
|
139
|
+
# credentials are invalid
|
140
|
+
unless valid_credentials? Trace.configure.project_id,
|
141
|
+
Trace.configure.keyfile
|
142
|
+
Cloud.configure.use_trace = false
|
143
|
+
return
|
144
|
+
end
|
145
|
+
|
146
|
+
# Otherwise set use_trace to true if Rails is running in production
|
147
|
+
Google::Cloud.configure.use_trace ||= Rails.env.production?
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# @private Merge Rails configuration into Trace instrumentation
|
152
|
+
# configuration.
|
153
|
+
def self.merge_rails_config rails_config
|
154
|
+
gcp_config = rails_config.google_cloud
|
155
|
+
trace_config = gcp_config.trace
|
156
|
+
|
157
|
+
Cloud.configure.use_trace ||= gcp_config.use_trace
|
158
|
+
Trace.configure do |config|
|
159
|
+
config.project_id ||= trace_config.project_id ||
|
160
|
+
gcp_config.project_id
|
161
|
+
config.keyfile ||= trace_config.keyfile || gcp_config.keyfile
|
162
|
+
config.notifications ||= trace_config.notifications
|
163
|
+
config.max_data_length ||= trace_config.max_data_length
|
164
|
+
config.capture_stack ||= trace_config.capture_stack
|
165
|
+
config.sampler ||= trace_config.sampler
|
166
|
+
config.span_id_generator ||= trace_config.span_id_generator
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# Fallback to default config values if config parameters not provided.
|
172
|
+
def self.init_default_config
|
173
|
+
Trace.configure.project_id ||= Trace::Project.default_project
|
174
|
+
end
|
175
|
+
|
176
|
+
##
|
177
|
+
# @private Verify credentials
|
178
|
+
def self.valid_credentials? project_id, keyfile
|
179
|
+
begin
|
180
|
+
Google::Cloud::Trace::Credentials.credentials_with_scope keyfile
|
181
|
+
rescue Exception => e
|
182
|
+
STDOUT.puts "Note: Google::Cloud::Trace is disabled because " \
|
183
|
+
"it failed to authorize with the service. (#{e.message})"
|
184
|
+
return false
|
185
|
+
end
|
186
|
+
|
187
|
+
if project_id.to_s.empty?
|
188
|
+
STDOUT.puts "Note: Google::Cloud::Trace is disabled because " \
|
189
|
+
"the project ID could not be determined."
|
190
|
+
return false
|
191
|
+
end
|
192
|
+
|
193
|
+
true
|
194
|
+
end
|
195
|
+
|
196
|
+
private_class_method :merge_rails_config,
|
197
|
+
:init_default_config,
|
198
|
+
:valid_credentials?
|
229
199
|
end
|
230
200
|
end
|
231
201
|
end
|
@@ -32,7 +32,8 @@ module Google
|
|
32
32
|
# env = my_get_rack_environment
|
33
33
|
# trace_context = Stackdriver::Core::TraceContext.parse_rack_env env
|
34
34
|
#
|
35
|
-
# trace = Google::Cloud::Trace.new "my-project",
|
35
|
+
# trace = Google::Cloud::Trace::TraceRecord.new "my-project",
|
36
|
+
# trace_context
|
36
37
|
# span = trace.create_span "root_span"
|
37
38
|
# subspan = span.create_span "subspan"
|
38
39
|
#
|
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.
|
4
|
+
version: 0.25.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: 2017-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-core
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: google-gax
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,7 +225,7 @@ files:
|
|
225
225
|
- lib/google/cloud/trace/version.rb
|
226
226
|
- lib/google/devtools/cloudtrace/v1/trace_pb.rb
|
227
227
|
- lib/google/devtools/cloudtrace/v1/trace_services_pb.rb
|
228
|
-
homepage:
|
228
|
+
homepage: https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-trace
|
229
229
|
licenses:
|
230
230
|
- Apache-2.0
|
231
231
|
metadata: {}
|
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
245
|
version: '0'
|
246
246
|
requirements: []
|
247
247
|
rubyforge_project:
|
248
|
-
rubygems_version: 2.6.
|
248
|
+
rubygems_version: 2.6.12
|
249
249
|
signing_key:
|
250
250
|
specification_version: 4
|
251
251
|
summary: Application Instrumentation and API Client library for Stackdriver Trace
|