google-cloud-trace 0.27.1 → 0.27.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 975ed7f4bb02a5e59ce4fca105d238f3ca7dbe1a
4
- data.tar.gz: b4f90c3860ffc78f4629b33e09389acfeb97902e
3
+ metadata.gz: 738619f7020791ff599a950fc987c8e725712e4c
4
+ data.tar.gz: 22a78c9abed2cfc846a41ce294e9227f36c27af7
5
5
  SHA512:
6
- metadata.gz: 03b6604e0d41b91a6c407b21669132d01402e4efef40387b5dcb6d689439f60f99b2fd278ce0aa6e08bf42e1cce58832552edbb2810177ca0c92eb2263d6d5c1
7
- data.tar.gz: '09aa20c57a10bbfffcf47023a7e764556ab6620bb0c68c2ab6fc03943be7bb25ef5028c8ee60222e3018e1a7b5b4037ba06eee346bdd38b096620cf1bf024920'
6
+ metadata.gz: 85b5c5f7960a4af52650d0376480d6e6f7e82bf901e986e19c743e13f25cab8095a5e5d57c06b50fbf8a9c5334aa7cffbe445b09e1e0dde99a134d79f2d63770
7
+ data.tar.gz: 0eed3070b782306da41e78bf9b336023671ff151f77aee648a27c00916f711f760642428a578df61c9d8f6ebb949e4d3fdccb56b610c2e07721ecd9f96aa2ca5
data/README.md CHANGED
@@ -14,48 +14,174 @@ capture traces from all of your VMs, containers, or Google App Engine projects.
14
14
  - [Stackdriver Trace documentation](https://cloud.google.com/trace/docs/)
15
15
 
16
16
  ## Quick Start
17
+
18
+ Install the gem directly:
19
+
17
20
  ```sh
18
21
  $ gem install google-cloud-trace
19
22
  ```
20
23
 
21
- ## Authentication
24
+ Or install through Bundler:
22
25
 
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.
26
+ 1. Add the `google-cloud-cloud` gem to your Gemfile:
27
+
28
+ ```ruby
29
+ gem "google-cloud-cloud"
30
+ ```
31
+
32
+ 2. Use Bundler to install the gem:
33
+
34
+ ```sh
35
+ $ bundle install
36
+ ```
37
+
38
+ Alternatively, check out the [`stackdriver`](../stackdriver) gem that includes
39
+ the `google-cloud-cloud` gem.
40
+
41
+ ## Enable Stackdriver Trace API
29
42
 
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).
43
+ The Stackdriver Trace library needs the [Stackdriver Trace
44
+ API](https://console.cloud.google.com/apis/library/cloudtrace.googleapis.com)
45
+ to be enabled on your Google Cloud project. Make sure it's enabled if not
46
+ already.
32
47
 
33
- ## Example
48
+ ## Tracing on Rack-based frameworks
49
+
50
+ The Stackdriver Trace library for Ruby makes it easy to integrate Stackdriver
51
+ Trace into popular Rack-based Ruby web frameworks such as Ruby on Rails and
52
+ Sinatra. When the library integration is enabled, it automatically traces
53
+ incoming requests in the application.
54
+
55
+ ### With Ruby on Rails
56
+
57
+ You can load the Railtie that comes with the library into your Ruby
58
+ on Rails application by explicitly requiring it during the application startup:
59
+
60
+ ```ruby
61
+ # In config/application.rb
62
+ require "google/cloud/trace/rails"
63
+ ```
64
+
65
+ If you're using the `stackdriver` gem, it automatically loads the Railtie into
66
+ your application when it starts.
67
+
68
+ ### With other Rack-based frameworks
69
+
70
+ Other Rack-based frameworks, such as Sinatra, can use the Rack Middleware
71
+ provided by the library:
34
72
 
35
73
  ```ruby
36
74
  require "google/cloud/trace"
75
+ use Google::Cloud::Trace::Middleware
76
+ ```
37
77
 
38
- trace = Google::Cloud::Trace.new
78
+ ### Adding Custom Trace Spans
79
+
80
+ The Stackdriver Trace Rack Middleware automatically creates a trace record for
81
+ incoming requests. You can add additional custom trace spans within each
82
+ request:
83
+
84
+ ```ruby
85
+ Google::Cloud::Trace.in_span "my_task" do |span|
86
+ # Do stuff...
39
87
 
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}"
88
+ Google::Cloud::Trace.in_span "my_subtask" do |subspan|
89
+ # Do other stuff
90
+ end
43
91
  end
44
92
  ```
45
93
 
46
- ## Rails and Rack Integration
94
+ ### Configuring the library
95
+
96
+ You can customize the behavior of the Stackdriver Trace library for Ruby. See
97
+ the [configuration guide](../stackdriver/configuration.md) for a list of
98
+ possible configuration options.
99
+
100
+ ## Running on Google Cloud Platform
101
+
102
+ The Stackdriver Trace library for Ruby should work without you manually
103
+ providing authentication credentials for instances running on Google Cloud
104
+ Platform, as long as the Stackdriver Trace API access scope is enabled on that
105
+ instance.
106
+
107
+ ### App Engine
108
+
109
+ On Google App Engine, the Stackdriver Trace API access scope is enabled by
110
+ default, and the Stackdriver Trace library for Ruby can be used without
111
+ providing credentials or a project ID
112
+
113
+ ### Container Engine
114
+
115
+ On Google Container Engine, you must explicitly add the `trace.append` OAuth
116
+ scope when creating the cluster:
117
+
118
+ ```sh
119
+ $ gcloud container clusters create example-cluster-name --scopes https://www.googleapis.com/auth/trace.append
120
+ ```
121
+
122
+ ### Compute Engine
123
+
124
+ For Google Compute Engine instances, you need to explicitly enable the
125
+ `trace.append` Stackdriver Trace API access scope for each instance. When
126
+ creating a new instance through the Google Cloud Platform Console, you can do
127
+ this under Identity and API access: Use the Compute Engine default service
128
+ account and select "Allow full access to all Cloud APIs" under Access scopes.
129
+
130
+ To use something other than the Compute Engine default service account see the
131
+ docs for Creating and Enabling Service Accounts for Instances and the Running
132
+ elsewhere section below. The important thing is that the service account you use
133
+ has the Cloud Trace Agent role.
134
+
135
+ ## Running locally and elsewhere
136
+
137
+ To run the Stackdriver Trace outside of Google Cloud Platform, you must supply
138
+ your GCP project ID and appropriate service account credentials directly to the
139
+ Stackdriver Trace. This applies to running the library on your own workstation,
140
+ on your datacenter's computers, or on the VM instances of another cloud
141
+ provider. See the [Authentication section](#authentication) for instructions on
142
+ how to do so.
143
+
144
+ ## Authentication
145
+
146
+ The Instrumentation client and API use Service Account credentials to connect
147
+ to Google Cloud services. When running on Google Cloud Platform environments,
148
+ the credentials will be discovered automatically. When running on other
149
+ environments the Service Account credentials can be specified by providing in
150
+ several ways.
151
+
152
+ The best way to provide authentication information if you're using Ruby on Rails
153
+ is through the Rails configuration interface:
47
154
 
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
155
  ```ruby
51
- require "google/cloud/trace/rails"
156
+ # in config/environments/*.rb
157
+ Rails.application.configure do |config|
158
+ # Shared parameters
159
+ config.google_cloud.project_id = "your-project-id"
160
+ config.google_cloud.keyfile = "/path/to/key.json"
161
+ # Or Stackdriver Trace specific parameters
162
+ config.google_cloud.trace.project_id = "your-project-id"
163
+ config.google_cloud.trace.keyfile = "/path/to/key.json"
164
+ end
52
165
  ```
53
166
 
54
- Alternatively, check out the [stackdriver](../stackdriver) gem, which includes
55
- this library and enables the Railtie by default.
167
+ Other Rack-based applications that are loading the Rack Middleware directly can use
168
+ the configration interface:
169
+
170
+ ```ruby
171
+ require "google/cloud/trace"
172
+ Google::Cloud.configure do |config|
173
+ # Shared parameters
174
+ config.project_id = "your-project-id"
175
+ config.keyfile = "/path/to/key.json"
176
+ # Or Stackdriver Trace specific parameters
177
+ config.trace.project_id = "your-project-id"
178
+ config.trace.keyfile = "/path/to/key.json"
179
+ end
180
+ ```
56
181
 
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).
182
+ This library also supports the other authentication methods provided by the
183
+ `google-cloud-ruby` suite. Instructions and configuration options are covered
184
+ in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-trace/guides/authentication).
59
185
 
60
186
  ## Supported Ruby Versions
61
187
 
@@ -379,6 +379,7 @@ module Google
379
379
  def init_default_config
380
380
  configuration.project_id ||= Cloud.configure.project_id ||
381
381
  Trace::Project.default_project
382
+ configuration.keyfile ||= Cloud.configure.keyfile
382
383
  configuration.capture_stack ||= false
383
384
  end
384
385
 
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Trace
19
- VERSION = "0.27.1".freeze
19
+ VERSION = "0.27.2".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.27.1
4
+ version: 0.27.2
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-09-08 00:00:00.000000000 Z
11
+ date: 2017-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core