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 +4 -4
- data/README.md +148 -22
- data/lib/google/cloud/trace/middleware.rb +1 -0
- data/lib/google/cloud/trace/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 738619f7020791ff599a950fc987c8e725712e4c
|
4
|
+
data.tar.gz: 22a78c9abed2cfc846a41ce294e9227f36c27af7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
24
|
+
Or install through Bundler:
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
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
|
-
##
|
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
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
88
|
+
Google::Cloud::Trace.in_span "my_subtask" do |subspan|
|
89
|
+
# Do other stuff
|
90
|
+
end
|
43
91
|
end
|
44
92
|
```
|
45
93
|
|
46
|
-
|
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
|
-
|
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
|
-
|
55
|
-
|
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
|
-
|
58
|
-
|
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
|
|
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.
|
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-
|
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
|