google-cloud-debugger 0.32.3 → 0.32.4

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
  SHA256:
3
- metadata.gz: 7059138deab6099684889719b6af36b209492140bc3785b0fe530fce128d9211
4
- data.tar.gz: e2b0dc554a33bf6b435ac24a0f93c6338c9db3a5e46bcf8fe7d9db89e7daca98
3
+ metadata.gz: c8b1380c75bf6566f1a41cdcbd967b7549d5f93e0bc69b65897824c07946fffc
4
+ data.tar.gz: c28da13606c56e600413454b0c2f6df47f947288142747b066a61bc84481c8f2
5
5
  SHA512:
6
- metadata.gz: 7b2299fac639c19c388e84f8e522388a8b175d22a522b1f60ea372102dbfc4a6767b2f6094ba69af40d5dec1e2cbb256655adfdf6474516d3c6a52b12eb6a162
7
- data.tar.gz: efb19ac91c9b94fc6df8ae4af497bc20fb9d3edb96b6b554093e989d2db5ae7b74eb77f34c785f9f280d9db38ef3a91aa2bcb270a1f1014ea90a1e7589338258
6
+ metadata.gz: a18db0dd6ade022ebc0a25068a7dda6813040d495a859f5baf313c76f685c6d43d540796f036bf123cf9aa64d2f6c549c8aebe8efcb7ec437b25fcea0dec0a02
7
+ data.tar.gz: 7c5fa5db5fbeada5e5ea7d2a60d185979d498e9b6ec49d97f179d7a076f5eb4e0e897d017e4151bca10d4e61784f9bbd1a7aa2644194052a8d3ead758d581979
data/AUTHENTICATION.md ADDED
@@ -0,0 +1,178 @@
1
+ # Authentication
2
+
3
+ In general, the google-cloud-debugger library uses [Service
4
+ Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
5
+ credentials to connect to Google Cloud services. When running on Compute Engine
6
+ the credentials will be discovered automatically. When running on other
7
+ environments, the Service Account credentials can be specified by providing the
8
+ path to the [JSON
9
+ keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for
10
+ the account (or the JSON itself) in environment variables. Additionally, Cloud
11
+ SDK credentials can also be discovered automatically, but this is only
12
+ recommended during development.
13
+
14
+ ## Project and Credential Lookup
15
+
16
+ The google-cloud-debugger library aims to make authentication as simple as
17
+ possible, and provides several mechanisms to configure your system without
18
+ providing **Project ID** and **Service Account Credentials** directly in code.
19
+
20
+ **Project ID** is discovered in the following order:
21
+
22
+ 1. Specify project ID in method arguments
23
+ 2. Specify project ID in configuration
24
+ 3. Discover project ID in environment variables
25
+ 4. Discover GCE project ID
26
+
27
+ **Credentials** are discovered in the following order:
28
+
29
+ 1. Specify credentials in method arguments
30
+ 2. Specify credentials in configuration
31
+ 3. Discover credentials path in environment variables
32
+ 4. Discover credentials JSON in environment variables
33
+ 5. Discover credentials file in the Cloud SDK's path
34
+ 6. Discover GCE credentials
35
+
36
+ ### Google Cloud Platform environments
37
+
38
+ While running on Google Cloud Platform environments such as Google Compute
39
+ Engine, Google App Engine and Google Kubernetes Engine, no extra work is needed.
40
+ The **Project ID** and **Credentials** and are discovered automatically. Code
41
+ should be written as if already authenticated. Just be sure when you [set up the
42
+ GCE instance][gce-how-to], you add the correct scopes for the APIs you want to
43
+ access. For example:
44
+
45
+ * **All APIs**
46
+ * `https://www.googleapis.com/auth/cloud-platform`
47
+ * `https://www.googleapis.com/auth/cloud-platform.read-only`
48
+ * **BigQuery**
49
+ * `https://www.googleapis.com/auth/bigquery`
50
+ * `https://www.googleapis.com/auth/bigquery.insertdata`
51
+ * **Compute Engine**
52
+ * `https://www.googleapis.com/auth/compute`
53
+ * **Datastore**
54
+ * `https://www.googleapis.com/auth/datastore`
55
+ * `https://www.googleapis.com/auth/userinfo.email`
56
+ * **DNS**
57
+ * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
58
+ * **Pub/Sub**
59
+ * `https://www.googleapis.com/auth/pubsub`
60
+ * **Storage**
61
+ * `https://www.googleapis.com/auth/devstorage.full_control`
62
+ * `https://www.googleapis.com/auth/devstorage.read_only`
63
+ * `https://www.googleapis.com/auth/devstorage.read_write`
64
+
65
+ ### Environment Variables
66
+
67
+ The **Project ID** and **Credentials JSON** can be placed in environment
68
+ variables instead of declaring them directly in code. Each service has its own
69
+ environment variable, allowing for different service accounts to be used for
70
+ different services. (See the READMEs for the individual service gems for
71
+ details.) The path to the **Credentials JSON** file can be stored in the
72
+ environment variable, or the **Credentials JSON** itself can be stored for
73
+ environments such as Docker containers where writing files is difficult or not
74
+ encouraged.
75
+
76
+ The environment variables that Debugger checks for project ID are:
77
+
78
+ 1. `DEBUGGER_PROJECT`
79
+ 2. `GOOGLE_CLOUD_PROJECT`
80
+
81
+ The environment variables that Debugger checks for credentials are configured on {Google::Cloud::Debugger::V2::Credentials}:
82
+
83
+ 1. `DEBUGGER_CREDENTIALS` - Path to JSON file, or JSON contents
84
+ 2. `DEBUGGER_KEYFILE` - Path to JSON file, or JSON contents
85
+ 3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
86
+ 4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
87
+ 5. `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
88
+
89
+ ```ruby
90
+ require "google/cloud/debugger"
91
+
92
+ ENV["DEBUGGER_PROJECT"] = "my-project-id"
93
+ ENV["DEBUGGER_CREDENTIALS"] = "path/to/keyfile.json"
94
+
95
+ debugger = Google::Cloud::Debugger.new
96
+ ```
97
+
98
+ ### Configuration
99
+
100
+ The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
101
+
102
+ ```ruby
103
+ require "google/cloud/debugger"
104
+
105
+ Google::Cloud::Debugger.configure do |config|
106
+ config.project_id = "my-project-id"
107
+ config.credentials = "path/to/keyfile.json"
108
+ end
109
+
110
+ debugger = Google::Cloud::Debugger.new
111
+ ```
112
+
113
+ ### Cloud SDK
114
+
115
+ This option allows for an easy way to authenticate during development. If
116
+ credentials are not provided in code or in environment variables, then Cloud SDK
117
+ credentials are discovered.
118
+
119
+ To configure your system for this, simply:
120
+
121
+ 1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
122
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
123
+ 3. Write code as if already authenticated.
124
+
125
+ **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
126
+ *should* only be used during development.
127
+
128
+ [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
129
+ [dev-console]: https://console.cloud.google.com/project
130
+
131
+ [enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
132
+
133
+ [create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
134
+ [create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
135
+ [reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
136
+
137
+ ## Creating a Service Account
138
+
139
+ Google Cloud requires a **Project ID** and **Service Account Credentials** to
140
+ connect to the APIs. You will use the **Project ID** and **JSON key file** to
141
+ connect to most services with google-cloud-debugger.
142
+
143
+ If you are not running this client on Google Compute Engine, you need a Google
144
+ Developers service account.
145
+
146
+ 1. Visit the [Google Developers Console][dev-console].
147
+ 1. Create a new project or click on an existing project.
148
+ 1. Activate the slide-out navigation tray and select **API Manager**. From
149
+ here, you will enable the APIs that your application requires.
150
+
151
+ ![Enable the APIs that your application requires][enable-apis]
152
+
153
+ *Note: You may need to enable billing in order to use these services.*
154
+
155
+ 1. Select **Credentials** from the side navigation.
156
+
157
+ You should see a screen like one of the following.
158
+
159
+ ![Create a new service account][create-new-service-account]
160
+
161
+ ![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
162
+
163
+ Find the "Add credentials" drop down and select "Service account" to be
164
+ guided through downloading a new JSON key file.
165
+
166
+ If you want to re-use an existing service account, you can easily generate a
167
+ new key file. Just select the account you wish to re-use, and click "Generate
168
+ new JSON key":
169
+
170
+ ![Re-use an existing service account][reuse-service-account]
171
+
172
+ The key file you download will be used by this library to authenticate API
173
+ requests and should be stored in a secure location.
174
+
175
+ ## Troubleshooting
176
+
177
+ If you're having trouble authenticating you can ask for help by following the
178
+ {file:TROUBLESHOOTING.md Troubleshooting Guide}.
data/CHANGELOG.md ADDED
@@ -0,0 +1,95 @@
1
+ # Release History
2
+
3
+ ### 0.32.4 / 2018-09-12
4
+
5
+ * Add missing documentation files to package.
6
+
7
+ ### 0.32.3 / 2018-09-10
8
+
9
+ * Update documentation.
10
+
11
+ ### 0.32.2 / 2018-08-21
12
+
13
+ * Update documentation.
14
+
15
+ ### 0.32.1 / 2018-07-05
16
+
17
+ * Fix issue when disabling Stackdriver components with Rails.env.production.
18
+ * Add documentation for enabling gRPC logging.
19
+
20
+ ### 0.32.0 / 2018-05-24
21
+
22
+ * Delay starting the debugger agent until the first request to ensure it
23
+ happens after workers are forked. Should prevent grpc from malfunctioning in
24
+ this case.
25
+
26
+ ### 0.31.0 / 2018-02-27
27
+
28
+ * Use Google Cloud Shared Configuration.
29
+ * Fix for mutation detection using Ruby 2.5.
30
+ * Support disabling mutation detection in debugger evaluation.
31
+
32
+ ### 0.30.0 / 2017-12-19
33
+
34
+ * Update google-gax dependency to 1.0.
35
+
36
+ ### 0.29.1 / 2017-11-15
37
+
38
+ * Fix credentials verification bug in Railtie.
39
+
40
+ ### 0.29.0 / 2017-11-14
41
+
42
+ * Add `Google::Cloud::Debugger::Credentials` class.
43
+ * Rename constructor arguments to `project_id` and `credentials`.
44
+ (The previous arguments `project` and `keyfile` are still supported.)
45
+ * Document `Google::Auth::Credentials` as `credentials` value.
46
+ * Add Debugger Agent Design Document.
47
+ * Updated `google-gax` (`grpc`, `google-protobuf`), `googleauth` dependencies.
48
+
49
+ ### 0.28.2 / 2017-09-28
50
+
51
+ * Improve Breakpoint tracer performance by not tracking C function calls in file tracing.
52
+ * Add a backoff behavior in the debuggee registration to reduce spamming requests when registrations fail.
53
+
54
+ ### 0.28.1 / 2017-09-08
55
+
56
+ * Print captured exception from asynchronous worker threads.
57
+
58
+ ### 0.28.0 / 2017-08-25
59
+
60
+ * Support single file Rack-based applications.
61
+ * Support none-Rack-based Ruby applications.
62
+ * API Breaking Change:
63
+ * `module_name` initialization parameter renamed to `service_name`
64
+ * `module_version` initialization parameter renamed to `module_version`
65
+
66
+ ### 0.27.0 / 2017-08-07
67
+
68
+ * Optimize breakpoint evaluation memory usage by adopting shared variable table.
69
+ * Update breakpoint to error state if the breakpoint is set at an invalid position or
70
+ if condition evaluation fail with an error.
71
+ * Set errored variable evaluation to error state.
72
+ * Restrict the amount of time spent on evaluating breakpoints within each rack application request.
73
+ * Restrict total memory usage on collecting variables within each breakpoint evaluation. Prioritize
74
+ memory allocation to user defined variables over local variables.
75
+
76
+ ### 0.26.1 / 2017-07-11
77
+
78
+ * stackdriver-core 1.2.0 release
79
+
80
+ ### 0.26.0 / 2017-07-11
81
+
82
+ * Update GAPIC configuration to exclude `UNAVAILABLE` errors from automatic retry.
83
+
84
+ ### 0.25.0 / 2017-05-25
85
+
86
+ * Introduce new `Google::Cloud::Debugger.configure` instrumentation configuration interface.
87
+
88
+ ### 0.24.1 / 2017-04-07
89
+
90
+ * Fixed Google::Cloud::Debugger::Railtie initialization on non-GCP environments
91
+ to not interfere with Rails startup
92
+
93
+ ### 0.24.0 / 2017-04-06
94
+
95
+ * First release
@@ -0,0 +1,40 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct.
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or reject
24
+ comments, commits, code, wiki edits, issues, and other contributions that are
25
+ not aligned to this Code of Conduct. By adopting this Code of Conduct, project
26
+ maintainers commit themselves to fairly and consistently applying these
27
+ principles to every aspect of managing this project. Project maintainers who do
28
+ not follow or enforce the Code of Conduct may be permanently removed from the
29
+ project team.
30
+
31
+ This code of conduct applies both within project spaces and in public spaces
32
+ when an individual is representing the project or its community.
33
+
34
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
35
+ reported by opening an issue or contacting one or more of the project
36
+ maintainers.
37
+
38
+ This Code of Conduct is adapted from the [Contributor
39
+ Covenant](http://contributor-covenant.org), version 1.2.0, available at
40
+ [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,188 @@
1
+ # Contributing to Google Cloud Debugger
2
+
3
+ 1. **Sign one of the contributor license agreements below.**
4
+ 2. Fork the repo, develop and test your code changes.
5
+ 3. Send a pull request.
6
+
7
+ ## Contributor License Agreements
8
+
9
+ Before we can accept your pull requests you'll need to sign a Contributor
10
+ License Agreement (CLA):
11
+
12
+ - **If you are an individual writing original source code** and **you own the
13
+ intellectual property**, then you'll need to sign an [individual
14
+ CLA](https://developers.google.com/open-source/cla/individual).
15
+ - **If you work for a company that wants to allow you to contribute your work**,
16
+ then you'll need to sign a [corporate
17
+ CLA](https://developers.google.com/open-source/cla/corporate).
18
+
19
+ You can sign these electronically (just scroll to the bottom). After that, we'll
20
+ be able to accept your pull requests.
21
+
22
+ ## Setup
23
+
24
+ In order to use the google-cloud-debugger console and run the project's tests,
25
+ there is a small amount of setup:
26
+
27
+ 1. Install Ruby. google-cloud-debugger requires Ruby 2.3+. You may choose to
28
+ manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
+ [rbenv](https://github.com/rbenv/rbenv), or
30
+ [chruby](https://github.com/postmodern/chruby).
31
+
32
+ 2. Install [Bundler](http://bundler.io/).
33
+
34
+ ```sh
35
+ $ gem install bundler
36
+ ```
37
+
38
+ 3. Install the top-level project dependencies.
39
+
40
+ ```sh
41
+ $ bundle install
42
+ ```
43
+
44
+ 4. Install the Debugger dependencies.
45
+
46
+ ```sh
47
+ $ cd google-cloud-debugger/
48
+ $ bundle exec rake bundleupdate
49
+ ```
50
+
51
+ ## Console
52
+
53
+ In order to run code interactively, you can automatically load
54
+ google-cloud-debugger and its dependencies in IRB. This requires that your
55
+ developer environment has already been configured by following the steps
56
+ described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
57
+ can be created with:
58
+
59
+ ```sh
60
+ $ cd google-cloud-debugger/
61
+ $ bundle exec rake console
62
+ ```
63
+
64
+ ## Debugger Tests
65
+
66
+ Tests are very important part of google-cloud-debugger. All contributions
67
+ should include tests that ensure the contributed code behaves as expected.
68
+
69
+ To run the unit tests, documentation tests, and code style checks together for a
70
+ package:
71
+
72
+ ``` sh
73
+ $ cd google-cloud-debugger/
74
+ $ bundle exec rake ci
75
+ ```
76
+
77
+ To run the command above, plus all acceptance tests, use `rake ci:acceptance` or
78
+ its handy alias, `rake ci:a`.
79
+
80
+ ### Debugger Unit Tests
81
+
82
+
83
+ The project uses the [minitest](https://github.com/seattlerb/minitest) library,
84
+ including [specs](https://github.com/seattlerb/minitest#specs),
85
+ [mocks](https://github.com/seattlerb/minitest#mocks) and
86
+ [minitest-autotest](https://github.com/seattlerb/minitest-autotest).
87
+
88
+ To run the Debugger unit tests:
89
+
90
+ ``` sh
91
+ $ cd google-cloud-debugger/
92
+ $ bundle exec rake test
93
+ ```
94
+
95
+ ### Debugger Documentation Tests
96
+
97
+ The project tests the code examples in the gem's
98
+ [YARD](https://github.com/lsegal/yard)-based documentation.
99
+
100
+ The example testing functions in a way that is very similar to unit testing, and
101
+ in fact the library providing it,
102
+ [yard-doctest](https://github.com/p0deje/yard-doctest), is based on the
103
+ project's unit test library, [minitest](https://github.com/seattlerb/minitest).
104
+
105
+ To run the Debugger documentation tests:
106
+
107
+ ``` sh
108
+ $ cd google-cloud-debugger/
109
+ $ bundle exec rake doctest
110
+ ```
111
+
112
+ If you add, remove or modify documentation examples when working on a pull
113
+ request, you may need to update the setup for the tests. The stubs and mocks
114
+ required to run the tests are located in `support/doctest_helper.rb`. Please
115
+ note that much of the setup is matched by the title of the
116
+ [`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag.
117
+ If you alter an example's title, you may encounter breaking tests.
118
+
119
+ ### Debugger Acceptance Tests
120
+
121
+ The Debugger acceptance tests interact with the live service API. Follow the
122
+ instructions in the {file:AUTHENTICATION.md Authentication guide} for enabling
123
+ the Debugger API. Occasionally, some API features may not yet be generally
124
+ available, making it difficult for some contributors to successfully run the
125
+ entire acceptance test suite. However, please ensure that you do successfully
126
+ run acceptance tests for any code areas covered by your pull request.
127
+
128
+ To run the acceptance tests, first create and configure a project in the Google
129
+ Developers Console, as described in the {file:AUTHENTICATION.md Authentication
130
+ guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
131
+ the KEYFILE location on your system.
132
+
133
+ Before you can run the Debugger acceptance tests, you must first create indexes
134
+ used in the tests.
135
+
136
+ #### Running the Debugger acceptance tests
137
+
138
+ To run the Debugger acceptance tests:
139
+
140
+ ``` sh
141
+ $ cd google-cloud-debugger/
142
+ $ bundle exec rake acceptance[\\{my-project-id},\\{/path/to/keyfile.json}]
143
+ ```
144
+
145
+ Or, if you prefer you can store the values in the `GCLOUD_TEST_PROJECT` and
146
+ `GCLOUD_TEST_KEYFILE` environment variables:
147
+
148
+ ``` sh
149
+ $ cd google-cloud-debugger/
150
+ $ export GCLOUD_TEST_PROJECT=\\{my-project-id}
151
+ $ export GCLOUD_TEST_KEYFILE=\\{/path/to/keyfile.json}
152
+ $ bundle exec rake acceptance
153
+ ```
154
+
155
+ If you want to use a different project and credentials for acceptance tests, you
156
+ can use the more specific `DEBUGGER_TEST_PROJECT` and `DEBUGGER_TEST_KEYFILE`
157
+ environment variables:
158
+
159
+ ``` sh
160
+ $ cd google-cloud-debugger/
161
+ $ export DEBUGGER_TEST_PROJECT=\\{my-project-id}
162
+ $ export DEBUGGER_TEST_KEYFILE=\\{/path/to/keyfile.json}
163
+ $ bundle exec rake acceptance
164
+ ```
165
+
166
+ ## Coding Style
167
+
168
+ Please follow the established coding style in the library. The style is is
169
+ largely based on [The Ruby Style
170
+ Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based
171
+ on seattle-style:
172
+
173
+ * Avoid parenthesis when possible, including in method definitions.
174
+ * Always use double quotes strings. ([Option
175
+ B](https://github.com/bbatsov/ruby-style-guide#strings))
176
+
177
+ You can check your code against these rules by running Rubocop like so:
178
+
179
+ ```sh
180
+ $ cd google-cloud-debugger/
181
+ $ bundle exec rake rubocop
182
+ ```
183
+
184
+ ## Code of Conduct
185
+
186
+ Please note that this project is released with a Contributor Code of Conduct. By
187
+ participating in this project you agree to abide by its terms. See
188
+ {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
@@ -0,0 +1,115 @@
1
+ # Stackdriver Debugger Instrumentation
2
+
3
+ Stackdriver Debugger is a feature of the Google Cloud Platform that lets
4
+ you inspect the state of an application at any code location without using
5
+ logging statements and without stopping or slowing down your applications.
6
+ Your users are not impacted during debugging. Using the production
7
+ debugger you can capture the local variables and call stack and link it
8
+ back to a specific line location in your source code. You can use this to
9
+ analyze the production state of your application and understand the
10
+ behavior of your code in production.
11
+
12
+ For general information about Stackdriver Debugger, read [Stackdriver
13
+ Debugger Documentation](https://cloud.google.com/debugger/docs/).
14
+
15
+ The Stackdriver Debugger Ruby library, `google-cloud-debugger`, provides an
16
+ easy-to-use debugger instrumentation that reports state data, such as
17
+ value of program variables and the call stack, to Stackdriver Debugger
18
+ when the code at a breakpoint location is executed in your Ruby
19
+ application. See the [instrumenting your app](#instrumenting-your-app)
20
+ section for how to debug your application, in both development and production.
21
+
22
+ ## Instrumenting Your App
23
+
24
+ This instrumentation library provides the following features to help you
25
+ debug your applications in production:
26
+
27
+ * Automatic application registration. It facilitates multiple running
28
+ instances of same version of application when hosted in production.
29
+ * A background debugger agent that runs side-by-side with your
30
+ application that automatically collects state data when code is
31
+ executed at breakpoint locations.
32
+ * A Rack middleware and Railtie that automatically manages the debugger
33
+ agent for Ruby on Rails and other Rack-based Ruby applications.
34
+
35
+ When this library is configured in your running application, and the
36
+ source code and breakpoints are setup through the Google Cloud Console,
37
+ You'll be able to
38
+ [interact](https://cloud.google.com/debugger/docs/debugging) with your
39
+ application in real time through the [Stackdriver Debugger
40
+ UI](https://console.cloud.google.com/debug?_ga=1.84295834.280814654.1476313407).
41
+ This library also integrates with Google App Engine Flexible to make debuggee
42
+ application configuration more seemless.
43
+
44
+ Note that when no breakpoints are created, the debugger agent consumes
45
+ very little resource and has no interference with the running application.
46
+ Once breakpoints are created and depends on where the breakpoints are
47
+ located, the debugger agent may add a little latency onto each request.
48
+ The application performance will be back to normal after all breakpoints
49
+ are finished being evaluated. Be aware the more breakpoints are created,
50
+ or the harder to reach the breakpoints, the more resource the debugger
51
+ agent would need to consume.
52
+
53
+ ### Configuration
54
+
55
+ The default configuration enables Stackdriver instrumentation features to run on
56
+ Google Cloud Platform. You can easily configure the instrumentation library if
57
+ you want to run on a non Google Cloud environment or you want to customize
58
+ the default behavior.
59
+
60
+ See the
61
+ [Configuration Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/stackdriver/guides/instrumentation_configuration)
62
+ for full configuration parameters.
63
+
64
+ ### Using instrumentation with Ruby on Rails
65
+
66
+ To install application instrumentation in your Ruby on Rails app, add this
67
+ gem, `google-cloud-debugger`, to your Gemfile and update your bundle. Then
68
+ add the following line to your `config/application.rb` file:
69
+
70
+ ```ruby
71
+ require "google/cloud/debugger/rails"
72
+ ```
73
+
74
+ This will load a Railtie that automatically integrates with the Rails
75
+ framework by injecting a Rack middleware.
76
+
77
+ ### Using instrumentation with Sinatra
78
+
79
+ To install application instrumentation in your Sinatra app, add this gem,
80
+ `google-cloud-debugger`, to your Gemfile and update your bundle. Then add
81
+ the following lines to your main application Ruby file:
82
+
83
+ ```ruby
84
+ require "google/cloud/debugger"
85
+ use Google::Cloud::Debugger::Middleware
86
+ ```
87
+
88
+ This will install the debugger middleware in your application.
89
+
90
+ ### Using instrumentation with other Rack-based frameworks
91
+
92
+ To install application instrumentation in an app using another Rack-based
93
+ web framework, add this gem, `google-cloud-debugger`, to your Gemfile and
94
+ update your bundle. Then add install the debugger middleware in your
95
+ middleware stack. In most cases, this means adding these lines to your
96
+ `config.ru` Rack configuration file:
97
+
98
+ ```ruby
99
+ require "google/cloud/debugger"
100
+ use Google::Cloud::Debugger::Middleware
101
+ ```
102
+
103
+ Some web frameworks have an alternate mechanism for modifying the
104
+ middleware stack. Consult your web framework's documentation for more
105
+ information.
106
+
107
+ ### The Stackdriver diagnostics suite
108
+
109
+ The debugger library is part of the Stackdriver diagnostics suite, which
110
+ also includes error reporting, log analysis, and tracing analysis. If you
111
+ include the `stackdriver` gem in your Gemfile, this debugger library will
112
+ be included automatically. In addition, if you include the `stackdriver`
113
+ gem in an application using Ruby On Rails, the Railties will be installed
114
+ automatically. See the documentation for the "stackdriver" gem
115
+ for more details.
data/LOGGING.md ADDED
@@ -0,0 +1,32 @@
1
+ # Enabling gRPC Logging
2
+
3
+ To enable logging for this library, set the logger for the underlying
4
+ [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
5
+ that you set may be a Ruby stdlib
6
+ [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
7
+ shown below, or a
8
+ [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger)
9
+ that will write logs to [Stackdriver
10
+ Logging](https://cloud.google.com/logging/). See
11
+ [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
12
+ and the gRPC
13
+ [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
14
+ for additional information.
15
+
16
+ Configuring a Ruby stdlib logger:
17
+
18
+ ```ruby
19
+ require "logger"
20
+
21
+ module MyLogger
22
+ LOGGER = Logger.new $stderr, level: Logger::WARN
23
+ def logger
24
+ LOGGER
25
+ end
26
+ end
27
+
28
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
29
+ module GRPC
30
+ extend MyLogger
31
+ end
32
+ ```
data/OVERVIEW.md ADDED
@@ -0,0 +1,297 @@
1
+ # Stackdriver Debugger
2
+
3
+ Stackdriver Debugger is a feature of the Google Cloud Platform that lets you
4
+ inspect the state of an application at any code location without using logging
5
+ statements and without stopping or slowing down your applications. Your users
6
+ are not impacted during debugging. Using the production debugger you can capture
7
+ the local variables and call stack and link it back to a specific line location
8
+ in your source code. You can use this to analyze the production state of your
9
+ application and understand the behavior of your code in production.
10
+
11
+ For general information about Stackdriver Debugger, read [Stackdriver Debugger
12
+ Documentation](https://cloud.google.com/debugger/docs/).
13
+
14
+ The Stackdriver Debugger Ruby library, `google-cloud-debugger`, provides:
15
+
16
+ * Easy-to-use debugger instrumentation that reports state data, such as value of
17
+ program variables and the call stack, to Stackdriver Debugger when the code at
18
+ a breakpoint location is executed in your Ruby application. See the
19
+ [instrumenting your app](#instrumenting-your-app) section for how to debug
20
+ your application, in both development and production.
21
+ * An idiomatic Ruby API for registerying debuggee application, and querying or
22
+ manipulating breakpoints in registered Ruby debuggee application. See
23
+ [Debugger API](#stackdriver-debugger-api) section for an introduction to
24
+ Stackdriver Debugger API.
25
+
26
+ ## Instrumenting Your App
27
+
28
+ This instrumentation library provides the following features to help you debug
29
+ your applications in production:
30
+
31
+ * Automatic application registration. It facilitates multiple running instances
32
+ of same version of application when hosted in production.
33
+ * A background debugger agent that runs side-by-side with your application that
34
+ automatically collects state data when code is executed at breakpoint
35
+ locations.
36
+ * A Rack middleware and Railtie that automatically manages the debugger agent
37
+ for Ruby on Rails and other Rack-based Ruby applications.
38
+
39
+ When this library is configured in your running application, and the source code
40
+ and breakpoints are setup through the Google Cloud Console, You'll be able to
41
+ [interact](https://cloud.google.com/debugger/docs/debugging) with your
42
+ application in real time through the [Stackdriver Debugger
43
+ UI](https://console.cloud.google.com/debug?_ga=1.84295834.280814654.1476313407).
44
+ This library also integrates with Google App Engine Flexible to make debuggee
45
+ application configuration more seemless.
46
+
47
+ Note that when no breakpoints are created, the debugger agent consumes very
48
+ little resource and has no interference with the running application. Once
49
+ breakpoints are created and depends on where the breakpoints are located, the
50
+ debugger agent may add a little latency onto each request. The application
51
+ performance will be back to normal after all breakpoints are finished being
52
+ evaluated. Be aware the more breakpoints are created, or the harder to reach the
53
+ breakpoints, the more resource the debugger agent would need to consume.
54
+
55
+ ### Using instrumentation with Ruby on Rails
56
+
57
+ To install application instrumentation in your Ruby on Rails app, add this gem,
58
+ `google-cloud-debugger`, to your Gemfile and update your bundle. Then add the
59
+ following line to your `config/application.rb` file:
60
+
61
+ ```ruby
62
+ require "google/cloud/debugger/rails"
63
+ ```
64
+
65
+ This will load a Railtie that automatically integrates with the Rails framework
66
+ by injecting a Rack middleware. The Railtie also takes in the following Rails
67
+ configuration as parameter of the debugger agent initialization:
68
+
69
+ ```ruby
70
+ # Explicitly enable or disable Stackdriver Debugger Agent
71
+ config.google_cloud.use_debugger = true
72
+ # Shared Google Cloud Platform project identifier
73
+ config.google_cloud.project_id = "gcloud-project"
74
+ # Google Cloud Platform project identifier for Stackdriver Debugger only
75
+ config.google_cloud.debugger.project_id = "debugger-project"
76
+ # Shared Google Cloud authentication json file
77
+ config.google_cloud.keyfile = "/path/to/keyfile.json"
78
+ # Google Cloud authentication json file for Stackdriver Debugger only
79
+ config.google_cloud.debugger.keyfile = "/path/to/debugger/keyfile.json"
80
+ # Stackdriver Debugger Agent service name identifier
81
+ config.google_cloud.debugger.service_name = "my-ruby-app"
82
+ # Stackdriver Debugger Agent service version identifier
83
+ config.google_cloud.debugger.service_version = "v1"
84
+ ```
85
+
86
+ See the {Google::Cloud::Debugger::Railtie} class for more information.
87
+
88
+ ### Using instrumentation with Sinatra
89
+
90
+ To install application instrumentation in your Sinatra app, add this gem,
91
+ `google-cloud-debugger`, to your Gemfile and update your bundle. Then add the
92
+ following lines to your main application Ruby file:
93
+
94
+ ```ruby
95
+ require "google/cloud/debugger"
96
+ use Google::Cloud::Debugger::Middleware
97
+ ```
98
+
99
+ This will install the debugger middleware in your application.
100
+
101
+ Configuration parameters may also be passed in as arguments to Middleware.
102
+
103
+ ```ruby
104
+ require "google/cloud/debugger"
105
+ use Google::Cloud::Debugger::Middleware project: "debugger-project-id",
106
+ keyfile: "/path/to/keyfile.json",
107
+ service_name: "my-ruby-app",
108
+ service_version: "v1"
109
+ ```
110
+
111
+ ### Using instrumentation with other Rack-based frameworks
112
+
113
+ To install application instrumentation in an app using another Rack-based web
114
+ framework, add this gem, `google-cloud-debugger`, to your Gemfile and update
115
+ your bundle. Then add install the debugger middleware in your middleware stack.
116
+ In most cases, this means adding these lines to your `config.ru` Rack
117
+ configuration file:
118
+
119
+ ```ruby
120
+ require "google/cloud/debugger"
121
+ use Google::Cloud::Debugger::Middleware
122
+ ```
123
+
124
+ Some web frameworks have an alternate mechanism for modifying the middleware
125
+ stack. Consult your web framework's documentation for more information.
126
+
127
+ ### The Stackdriver diagnostics suite
128
+
129
+ The debugger library is part of the Stackdriver diagnostics suite, which also
130
+ includes error reporting, log analysis, and tracing analysis. If you include the
131
+ `stackdriver` gem in your Gemfile, this debugger library will be included
132
+ automatically. In addition, if you include the `stackdriver` gem in an
133
+ application using Ruby On Rails, the Railties will be installed automatically.
134
+ See the documentation for the "stackdriver" gem for more details.
135
+
136
+ ## Stackdriver Debugger API
137
+
138
+ This library also includes an easy to use Ruby client for the Stackdriver
139
+ Debugger API. This API provides calls to register debuggee application, as well
140
+ as creating or modifying breakpoints.
141
+
142
+ For further information on the Debugger API, see
143
+ {Google::Cloud::Debugger::Project}
144
+
145
+ ### Registering debuggee application
146
+
147
+ ```ruby
148
+ require "google/cloud/debugger/v2"
149
+
150
+ Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
151
+ Debuggee = Google::Devtools::Clouddebugger::V2::Debuggee
152
+
153
+ controller2_client = Controller2Client.new
154
+ debuggee = Debuggee.new
155
+ response = controller2_client.register_debuggee(debuggee)
156
+ debuggee_id = response.debuggee.id
157
+ ```
158
+ See [Stackdriver Debugger Debuggee
159
+ doc](https://cloud.google.com/debugger/api/reference/rpc/google.devtools.clouddebugger.v2#google.devtools.clouddebugger.v2.Debuggee)
160
+ on fields necessary for registerying a debuggee.
161
+
162
+ Upon successful registration, the response debuggee object will contain a
163
+ debuggee_id that's later needed to interact with the other Stackdriver Debugger
164
+ API.
165
+
166
+ See {Google::Cloud::Debugger::V2::Controller2Client} for details.
167
+
168
+ ### List Active Breakpoints
169
+
170
+ ```ruby
171
+ require "google/cloud/debugger/v2"
172
+
173
+ Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
174
+ controller2_client = Controller2Client.new
175
+
176
+ debuggee_id = ''
177
+ response = controller2_client.list_active_breakpoints(debuggee_id)
178
+ breakpoints = response.breakpoints
179
+ ```
180
+
181
+ See {Google::Cloud::Debugger::V2::Controller2Client} for details.
182
+
183
+ ### Update Active Breakpoint
184
+
185
+ Users can send custom snapshots for active breakpoints using this API.
186
+
187
+ ```ruby
188
+ require "google/cloud/debugger/v2"
189
+
190
+ Breakpoint = Google::Devtools::Clouddebugger::V2::Breakpoint
191
+ Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
192
+
193
+ controller2_client = Controller2Client.new
194
+ debuggee_id = ''
195
+ breakpoint = Breakpoint.new
196
+ response =
197
+ controller2_client.update_active_breakpoint(debuggee_id, breakpoint)
198
+ ```
199
+
200
+ See [Stackdriver Debugger Breakpoint
201
+ doc](https://cloud.google.com/debugger/api/reference/rpc/google.devtools.clouddebugger.v2#google.devtools.clouddebugger.v2.Breakpoint)
202
+ for all available fields for breakpoint.
203
+
204
+ See {Google::Cloud::Debugger::V2::Controller2Client} for details.
205
+
206
+ ### Set Breakpoint
207
+
208
+ ```ruby
209
+ require "google/cloud/debugger/v2"
210
+
211
+ Breakpoint = Google::Devtools::Clouddebugger::V2::Breakpoint
212
+ Debugger2Client = Google::Cloud::Debugger::V2::Debugger2Client
213
+
214
+ debugger2_client = Debugger2Client.new
215
+ debuggee_id = ''
216
+ breakpoint = Breakpoint.new
217
+ client_version = ''
218
+ response = debugger2_client.set_breakpoint(
219
+ debuggee_id, breakpoint, client_version)
220
+ ```
221
+
222
+ See [Stackdriver Debugger Breakpoint
223
+ doc](https://cloud.google.com/debugger/api/reference/rpc/google.devtools.clouddebugger.v2#google.devtools.clouddebugger.v2.Breakpoint)
224
+ for fields needed to specify breakpoint location.
225
+
226
+ See {Google::Cloud::Debugger::V2::Debugger2Client} for details.
227
+
228
+ ### Get Breakpoint
229
+
230
+ ```ruby
231
+ require "google/cloud/debugger/v2"
232
+
233
+ Debugger2Client = Google::Cloud::Debugger::V2::Debugger2Client
234
+
235
+ debugger2_client = Debugger2Client.new
236
+ debuggee_id = ''
237
+ breakpoint_id = ''
238
+ client_version = ''
239
+ response = debugger2_client.get_breakpoint(
240
+ debuggee_id, breakpoint_id, client_version)
241
+ ```
242
+
243
+ See {Google::Cloud::Debugger::V2::Debugger2Client} for details.
244
+
245
+ ### Delete Breakpoint
246
+
247
+ ```ruby
248
+ require "google/cloud/debugger/v2"
249
+
250
+ Debugger2Client = Google::Cloud::Debugger::V2::Debugger2Client
251
+
252
+ debugger2_client = Debugger2Client.new
253
+ debuggee_id = ''
254
+ breakpoint_id = ''
255
+ client_version = ''
256
+ debugger2_client.delete_breakpoint(
257
+ debuggee_id, breakpoint_id, client_version)
258
+ ```
259
+
260
+ See {Google::Cloud::Debugger::V2::Debugger2Client} for details.
261
+
262
+ ### List Breakpoints
263
+
264
+ ```ruby
265
+ require "google/cloud/debugger/v2"
266
+
267
+ Debugger2Client = Google::Cloud::Debugger::V2::Debugger2Client
268
+
269
+ Debugger2Client = Google::Cloud::Debugger::V2::Debugger2Client
270
+
271
+ debugger2_client = Debugger2Client.new
272
+ debuggee_id = ''
273
+ client_version = ''
274
+ response = debugger2_client.list_breakpoints(debuggee_id, client_version)
275
+ ```
276
+
277
+ See {Google::Cloud::Debugger::V2::Debugger2Client} for details.
278
+
279
+ ### List Debuggees
280
+
281
+ ```ruby
282
+ require "google/cloud/debugger/v2"
283
+
284
+ Debugger2Client = Google::Cloud::Debugger::V2::Debugger2Client
285
+
286
+ debugger2_client = Debugger2Client.new
287
+ project = ''
288
+ client_version = ''
289
+ response = debugger2_client.list_debuggees(project, client_version)
290
+ ```
291
+
292
+ See {Google::Cloud::Debugger::V2::Debugger2Client} for details.
293
+
294
+ ## Additional information
295
+
296
+ Stackdriver Debugger can be configured to use gRPC's logging. To learn more, see
297
+ the {file:LOGGING.md Logging guide}.
@@ -0,0 +1,37 @@
1
+ # Troubleshooting
2
+
3
+ ## Where can I get more help?
4
+
5
+ ### Ask the Community
6
+
7
+ If you have a question about how to use a Google Cloud client library in your
8
+ project or are stuck in the Developer's console and don't know where to turn,
9
+ it's possible your questions have already been addressed by the community.
10
+
11
+ First, check out the appropriate tags on StackOverflow:
12
+ - [`google-cloud-platform+ruby+debugger`][so-ruby]
13
+
14
+ Next, try searching through the issues on GitHub:
15
+
16
+ - [`api:debugger` issues][gh-search-ruby]
17
+
18
+ Still nothing?
19
+
20
+ ### Ask the Developers
21
+
22
+ If you're experiencing a bug with the code, or have an idea for how it can be
23
+ improved, *please* create a new issue on GitHub so we can talk about it.
24
+
25
+ - [New issue][gh-ruby]
26
+
27
+ Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
28
+ can use the "ruby" channel for general Ruby questions, or use the
29
+ "google-cloud-ruby" channel if you have questions about this gem in particular.
30
+
31
+ [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+debugger
32
+
33
+ [gh-search-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues?q=label%3A%22api%3A+debugger%22
34
+
35
+ [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
36
+
37
+ [slack-ruby]: https://gcp-slack.appspot.com/
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Debugger
19
- VERSION = "0.32.3".freeze
19
+ VERSION = "0.32.4".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-debugger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.3
4
+ version: 0.32.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heng Xiong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-10 00:00:00.000000000 Z
11
+ date: 2018-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: binding_of_caller
@@ -271,8 +271,15 @@ extensions:
271
271
  extra_rdoc_files: []
272
272
  files:
273
273
  - ".yardopts"
274
+ - AUTHENTICATION.md
275
+ - CHANGELOG.md
276
+ - CODE_OF_CONDUCT.md
277
+ - CONTRIBUTING.md
278
+ - INSTRUMENTATION.md
274
279
  - LICENSE
275
- - README.md
280
+ - LOGGING.md
281
+ - OVERVIEW.md
282
+ - TROUBLESHOOTING.md
276
283
  - ext/google/cloud/debugger/debugger_c/debugger.c
277
284
  - ext/google/cloud/debugger/debugger_c/debugger.h
278
285
  - ext/google/cloud/debugger/debugger_c/evaluator.c
data/README.md DELETED
@@ -1,286 +0,0 @@
1
- # google-cloud-debugger
2
-
3
- [Stackdriver Debugger](https://cloud.google.com/debugger/) lets you inspect the
4
- state of a running application at any code location in real time, without
5
- stopping or slowing down the application, and without modifying the code to add
6
- logging statements. You can use Stackdriver Debugger with any deployment of
7
- your application, including test, development, and production. The Ruby
8
- debugger adds minimal request latency, typically less than 50ms, and only when
9
- application state is captured. In most cases, this is not noticeable by users.
10
-
11
- - [google-cloud-debugger documentation](http://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-debugger/latest)
12
- - [google-cloud-debugger on RubyGems](https://rubygems.org/gems/google-cloud-debugger)
13
- - [Stackdriver Debugger documentation](https://cloud.google.com/debugger/docs/)
14
-
15
- ## Quick Start
16
-
17
- ### Installing the gem
18
-
19
- Add the `google-cloud-debugger` gem to your Gemfile:
20
-
21
- ```ruby
22
- gem "google-cloud-debugger"
23
- ```
24
-
25
- Alternatively, consider installing the [`stackdriver`](../stackdriver) gem. It
26
- includes the `google-cloud-debugger` gem as a dependency, and automatically
27
- initializes it for some application frameworks.
28
-
29
- ### Initializing the Debugger
30
-
31
- The Stackdriver Debugger library provides a Debugger agent that helps create
32
- breakpoints in your running applications. It then collects application snapshot
33
- data and transmits it to the Stackdriver Debugger service for you to view on
34
- the Google Cloud Console. The library also comes with a Railtie and a Rack
35
- Middleware to help control the Debugger agent in popular Rack based frameworks,
36
- such as Ruby on Rails and Sinatra.
37
-
38
- #### Setup with Ruby on Rails
39
-
40
- You can load the Railtie that comes with the library into your Ruby
41
- on Rails application by explicitly requiring it during the application startup:
42
-
43
- ```ruby
44
- # In config/application.rb
45
- require "google/cloud/debugger/rails"
46
- ```
47
-
48
- If you're using the `stackdriver` gem, it automatically loads the Railtie into
49
- your application when it starts.
50
-
51
- #### Setup with other Rack-based frameworks
52
-
53
- Other Rack-based frameworks, such as Sinatra, can use the Rack Middleware
54
- provided by the library:
55
-
56
- ```ruby
57
- require "google/cloud/debugger"
58
- use Google::Cloud::Debugger::Middleware
59
- ```
60
-
61
- #### Setup without a Rack-based framework
62
-
63
- Non-rack-based applications can start the agent explicitly during the
64
- initialization code:
65
-
66
- ```ruby
67
- require "google/cloud/debugger"
68
- Google::Cloud::Debugger.new.start
69
- ```
70
-
71
- ### Connecting to the Debugger
72
-
73
- You can set breakpoints and view snapshots using the Google Cloud Console.
74
- If your app is hosted on Google Cloud (such as on Google App Engine, Google
75
- Kubernetes Engine, or Google Compute Engine), you can use the same project.
76
- Otherwise, if your application is hosted elsewhere, create a new project on
77
- [Google Cloud](https://console.cloud.google.com/).
78
-
79
- Make sure the
80
- [Stackdriver Debugger API](https://console.cloud.google.com/apis/library/clouddebugger.googleapis.com)
81
- is enabled on your Google Cloud project.
82
-
83
- To connect to the Stackdriver Debugger service, the agent needs to be
84
- authenticated. If your application is hosted on Google Cloud Platform, much of
85
- this is handled for you automatically.
86
-
87
- #### Connecting from Google App Engine (GAE)
88
-
89
- If your app is running on Google App Engine, the Stackdriver Debugger agent
90
- authenticates automatically by default, and no additional configuration is
91
- required.
92
-
93
- #### Connecting from Google Kubernetes Engine (GKE)
94
-
95
- If your app is running on Google Kubernetes Engine, you must explicitly add the
96
- `cloud_debugger` OAuth scope when creating the cluster:
97
-
98
- ```sh
99
- $ gcloud container clusters create example-cluster-name --scopes https://www.googleapis.com/auth/cloud_debugger
100
- ```
101
-
102
- You can also do this through the Google Cloud Platform Console. Select
103
- **Enabled** in the Cloud Platform section of **Create a container cluster**.
104
-
105
- After the OAuth scope is enabled, the Stackdriver Debugger agent authenticates
106
- automatically by default, and no additional configuration is required.
107
-
108
- #### Connecting from Google Compute Engine (GCE)
109
-
110
- If your app is running on Google Compute Engine, its VM instances should have
111
- one of the following access scopes. These are only relevant when you use
112
- Compute Engine's default service account:
113
-
114
- * `https://www.googleapis.com/auth/cloud-platform`
115
- * `https://www.googleapis.com/auth/cloud_debugger`
116
-
117
- The `cloud-platform` access scope can be supplied when creating a new instance
118
- through the Google Cloud Platform Console. Select **Allow full access to all
119
- Cloud APIs** in the **Identity and API access** section of **Create an
120
- instance**.
121
-
122
- The `cloud_debugger` access scope can be supplied manually using the SDK's
123
- `gcloud compute instances create` command or the `gcloud compute instances
124
- set-service-account` command.
125
-
126
- After the OAuth scope is enabled, the Stackdriver Debugger agent authenticates
127
- automatically by default using the VM's service account, and no additional
128
- configuration is required.
129
-
130
- #### Connecting from other hosting environments
131
-
132
- To run the Stackdriver Debugger agent outside of Google Cloud Platform, you must
133
- supply your GCP project ID and appropriate service account credentials directly
134
- to the Stackdriver Debugger agent. This applies to running the agent on your own
135
- workstation, on your datacenter's computers, or on the VM instances of another
136
- cloud provider.
137
-
138
- The best way to provide authentication information if you're using Ruby on Rails
139
- is through the Rails configuration interface:
140
-
141
- ```ruby
142
- # in config/environments/*.rb
143
- Rails.application.configure do |config|
144
- # Shared parameters
145
- config.google_cloud.project_id = "your-project-id"
146
- config.google_cloud.credentials = "/path/to/key.json"
147
- # Or Stackdriver Debugger agent specific parameters
148
- config.google_cloud.debugger.project_id = "your-project-id"
149
- config.google_cloud.debugger.credentials = "/path/to/key.json"
150
- end
151
- ```
152
-
153
- Other Rack-based applications that are loading the Rack Middleware directly can
154
- use the configration interface:
155
-
156
- ```ruby
157
- require "google/cloud/debugger"
158
- Google::Cloud.configure do |config|
159
- # Shared parameters
160
- config.project_id = "your-project-id"
161
- config.credentials = "/path/to/key.json"
162
- # Or Stackdriver Debugger agent specific parameters
163
- config.debugger.project_id = "your-project-id"
164
- config.debugger.credentials = "/path/to/key.json"
165
- end
166
- ```
167
-
168
- Or provide the parameters to the Stackdriver Debugger agent when it starts:
169
-
170
- ```ruby
171
- require "google/cloud/debugger"
172
- Google::Cloud::Debugger.new(project_id: "your-project-id",
173
- credentials: "/path/to/key.json").start
174
- ```
175
-
176
- This library also supports the other authentication methods provided by the
177
- `google-cloud-ruby` suite. Instructions and configuration options are covered
178
- in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-debugger/latest/file.AUTHENTICATION).
179
-
180
- ### Using the Debugger
181
-
182
- When you set a breakpoint in the Stackdriver Debugger console, the agent takes
183
- a snapshot of application data when the breakpoint is hit. The application then
184
- continues running with minimal slowdown, and you can view the snapshot offline
185
- in the console.
186
-
187
- By default, the snapshot includes the local variables from the current and four
188
- most recent stack frames. You may include additional data in the snapshot by
189
- providing a list of _expressions_ when you create the breakpoint. Expressions
190
- may be instance variables, global variables, or the result of calling Ruby
191
- methods, or indeed, any Ruby expression.
192
-
193
- For more information on using the debugger features, see the
194
- [Stackdriver Debugger Documentation](https://cloud.google.com/debugger/docs/).
195
-
196
- #### Working with Mutation Protection
197
-
198
- To reduce the risk of corrupting your application data or changing your
199
- application's behavior, the debugger agent checks all expressions you provide
200
- for possible side effects before it runs them. If an expression calls any code
201
- that could modify the program state, by changing an instance variable for
202
- example, it is not evaluated.
203
-
204
- This check is rather conservative, so if you are receiving mutation errors on
205
- an expression you know to be safe, you may disable the check by wrapping your
206
- expression in a call to `Google::Cloud::Debugger.allow_mutating_methods!`. For
207
- example:
208
-
209
- ```ruby
210
- Google::Cloud::Debugger.allow_mutating_methods! { my_expression() }
211
- ```
212
-
213
- You may disable side effect checks globally by setting the
214
- `allow_mutating_methods` configuration. See the next section on configuring the
215
- agent.
216
-
217
- #### Configuring the agent
218
-
219
- You can customize the behavior of the Stackdriver Debugger agent. This includes
220
- setting the Google Cloud project and authentication, and customizing the
221
- behavior of the debugger itself, such as side effect protection and data
222
- size limits. See [agent configuration](../stackdriver/CONFIGURATION.md)
223
- for a list of possible configuration options.
224
-
225
- ## Enabling Logging
226
-
227
- To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
228
-
229
- Configuring a Ruby stdlib logger:
230
-
231
- ```ruby
232
- require "logger"
233
-
234
- module MyLogger
235
- LOGGER = Logger.new $stderr, level: Logger::WARN
236
- def logger
237
- LOGGER
238
- end
239
- end
240
-
241
- # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
242
- module GRPC
243
- extend MyLogger
244
- end
245
- ```
246
-
247
- ## Supported Ruby Versions
248
-
249
- This library is supported on Ruby 2.3+.
250
-
251
- Google provides official support for Ruby versions that are actively supported
252
- by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
253
- security maintenance, and not end of life. Currently, this means Ruby 2.3 and
254
- later. Older versions of Ruby _may_ still work, but are unsupported and not
255
- recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
256
- about the Ruby support schedule.
257
-
258
- This library follows [Semantic Versioning](http://semver.org/). It is currently
259
- in major version zero (0.y.z), which means that anything may change at any time
260
- and the public API should not be considered stable.
261
-
262
- ## Contributing
263
-
264
- Contributions to this library are always welcome and highly encouraged.
265
-
266
- See the [Contributing
267
- Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-debugger/latest/file.CONTRIBUTING)
268
- for more information on how to get started.
269
-
270
- Please note that this project is released with a Contributor Code of Conduct. By
271
- participating in this project you agree to abide by its terms. See [Code of
272
- Conduct](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-debugger/latest/file.CODE_OF_CONDUCT)
273
- for more information.
274
-
275
- ## License
276
-
277
- This library is licensed under Apache 2.0. Full license text is available in
278
- [LICENSE](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-debugger/latest/file.LICENSE).
279
-
280
- ## Support
281
-
282
- Please [report bugs at the project on
283
- Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues). Don't
284
- hesitate to [ask
285
- questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby)
286
- about the client or APIs on [StackOverflow](http://stackoverflow.com).