google-cloud-error_reporting 0.24.0 → 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.
@@ -0,0 +1,118 @@
1
+ # Copyright 2017 Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0oud
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require "google/cloud/errors"
17
+ require "google/cloud/error_reporting/version"
18
+ require "google/cloud/error_reporting/v1beta1"
19
+ require "google/gax/errors"
20
+
21
+ module Google
22
+ module Cloud
23
+ module ErrorReporting
24
+ ##
25
+ # @private Represents the gRPC Error Reporting service, including all the
26
+ # API methods.
27
+ class Service
28
+ attr_accessor :project, :credentials, :host, :timeout, :client_config
29
+
30
+ ##
31
+ # Creates a new Service instance.
32
+ def initialize project, credentials,
33
+ host: nil, timeout: nil, client_config: nil
34
+ @project = project
35
+ @credentials = credentials
36
+ @host = host || V1beta1::ReportErrorsServiceClient::SERVICE_ADDRESS
37
+ @timeout = timeout
38
+ @client_config = client_config || {}
39
+ end
40
+
41
+ def channel
42
+ require "grpc"
43
+ GRPC::Core::Channel.new host, nil, chan_creds
44
+ end
45
+
46
+ def chan_creds
47
+ require "grpc"
48
+ return credentials if insecure?
49
+ GRPC::Core::ChannelCredentials.new.compose \
50
+ GRPC::Core::CallCredentials.new credentials.client.updater_proc
51
+ end
52
+
53
+ def insecure?
54
+ credentials == :this_channel_is_insecure
55
+ end
56
+
57
+ def error_reporting
58
+ return mocked_error_reporting if mocked_error_reporting
59
+ @error_reporting ||= \
60
+ V1beta1::ReportErrorsServiceClient.new(
61
+ service_path: host,
62
+ channel: channel,
63
+ timeout: timeout,
64
+ client_config: client_config,
65
+ lib_name: "gccl",
66
+ lib_version: Google::Cloud::ErrorReporting::VERSION
67
+ )
68
+ end
69
+ attr_accessor :mocked_error_reporting
70
+
71
+ ##
72
+ # Report a {Google::Cloud::ErrorReporting::ErrorEvent} to Stackdriver
73
+ # Error Reporting service.
74
+ #
75
+ # @example
76
+ # require "google/cloud/error_reporting"
77
+ #
78
+ # error_reporting = Google::Cloud::ErrorReporting.new
79
+ #
80
+ # error_event =
81
+ # error_reporting.error_event "Error Message with Backtrace",
82
+ # timestamp: Time.now,
83
+ # service_name: "my_app_name",
84
+ # service_version: "v8",
85
+ # user: "johndoh",
86
+ # file_path: "MyController.rb",
87
+ # line_number: 123,
88
+ # function_name: "index"
89
+ # error_reporting.report error_event
90
+ #
91
+ def report error_event
92
+ if error_event.message.nil? || error_event.message.empty?
93
+ fail ArgumentError, "Cannot report empty message"
94
+ end
95
+
96
+ error_event_grpc = error_event.to_grpc
97
+
98
+ execute do
99
+ error_reporting.report_error_event project_path, error_event_grpc
100
+ end
101
+ end
102
+
103
+ protected
104
+
105
+ def project_path
106
+ V1beta1::ReportErrorsServiceClient.project_path project
107
+ end
108
+
109
+ def execute
110
+ yield
111
+ rescue Google::Gax::GaxError => e
112
+ # GaxError wraps BadStatus, but exposes it as #cause
113
+ raise Google::Cloud::Error.from_error(e.cause)
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2017 Google Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ module Google
17
+ module Cloud
18
+ module ErrorReporting
19
+ VERSION = "0.25.0".freeze
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-error_reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-01 00:00:00.000000000 Z
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
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: stackdriver-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: google-gax
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +123,7 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: 0.35.1
111
125
  - !ruby/object:Gem::Dependency
112
- name: actionpack
126
+ name: railties
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
@@ -123,33 +137,61 @@ dependencies:
123
137
  - !ruby/object:Gem::Version
124
138
  version: '4.0'
125
139
  - !ruby/object:Gem::Dependency
126
- name: railties
140
+ name: rack
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: '4.0'
159
+ version: '0.9'
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: '4.0'
166
+ version: '0.9'
139
167
  - !ruby/object:Gem::Dependency
140
- name: rack
168
+ name: yard
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
- - - ">="
171
+ - - "~>"
144
172
  - !ruby/object:Gem::Version
145
- version: '0.1'
173
+ version: '0.9'
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
- - - ">="
178
+ - - "~>"
151
179
  - !ruby/object:Gem::Version
152
- version: '0.1'
180
+ version: '0.9'
181
+ - !ruby/object:Gem::Dependency
182
+ name: yard-doctest
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "<="
186
+ - !ruby/object:Gem::Version
187
+ version: 0.1.8
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "<="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.1.8
153
195
  description: google-cloud-error_reporting is the official library for Stackdriver
154
196
  Error Reporting.
155
197
  email:
@@ -162,8 +204,13 @@ files:
162
204
  - LICENSE
163
205
  - README.md
164
206
  - lib/google-cloud-error_reporting.rb
207
+ - lib/google/cloud/error_reporting.rb
208
+ - lib/google/cloud/error_reporting/credentials.rb
209
+ - lib/google/cloud/error_reporting/error_event.rb
165
210
  - lib/google/cloud/error_reporting/middleware.rb
211
+ - lib/google/cloud/error_reporting/project.rb
166
212
  - lib/google/cloud/error_reporting/rails.rb
213
+ - lib/google/cloud/error_reporting/service.rb
167
214
  - lib/google/cloud/error_reporting/v1beta1.rb
168
215
  - lib/google/cloud/error_reporting/v1beta1/doc/google/devtools/clouderrorreporting/v1beta1/common.rb
169
216
  - lib/google/cloud/error_reporting/v1beta1/doc/google/devtools/clouderrorreporting/v1beta1/error_stats_service.rb
@@ -176,6 +223,7 @@ files:
176
223
  - lib/google/cloud/error_reporting/v1beta1/error_stats_service_client_config.json
177
224
  - lib/google/cloud/error_reporting/v1beta1/report_errors_service_client.rb
178
225
  - lib/google/cloud/error_reporting/v1beta1/report_errors_service_client_config.json
226
+ - lib/google/cloud/error_reporting/version.rb
179
227
  - lib/google/devtools/clouderrorreporting/v1beta1/common_pb.rb
180
228
  - lib/google/devtools/clouderrorreporting/v1beta1/error_group_service_pb.rb
181
229
  - lib/google/devtools/clouderrorreporting/v1beta1/error_group_service_services_pb.rb
@@ -183,7 +231,7 @@ files:
183
231
  - lib/google/devtools/clouderrorreporting/v1beta1/error_stats_service_services_pb.rb
184
232
  - lib/google/devtools/clouderrorreporting/v1beta1/report_errors_service_pb.rb
185
233
  - lib/google/devtools/clouderrorreporting/v1beta1/report_errors_service_services_pb.rb
186
- homepage: http://googlecloudplatform.github.io/google-cloud-ruby/
234
+ homepage: https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-error_reporting
187
235
  licenses:
188
236
  - Apache-2.0
189
237
  metadata: {}
@@ -203,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
251
  version: '0'
204
252
  requirements: []
205
253
  rubyforge_project:
206
- rubygems_version: 2.6.11
254
+ rubygems_version: 2.6.12
207
255
  signing_key:
208
256
  specification_version: 4
209
257
  summary: API Client library for Stackdriver Error Reporting