stackdriver-core 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4bb62b8cdb5f28de4f303da6a8ff2e0a31d6cbcd
4
- data.tar.gz: 2e6eda3a499805fef92f27a3d0b5167d8d508e31
2
+ SHA256:
3
+ metadata.gz: 6c6ef552f209b36ad5abc3ccbad6df179289ce5632b031fe33380aeea6dd695d
4
+ data.tar.gz: 4cfb1f1ff935e105789df3d93420cf788a08acf7939b6c7b5f1fc8eca4083b86
5
5
  SHA512:
6
- metadata.gz: 122c12d22560686b2a45f63aca85b33d68876d5d3a513dc5bf8deef952fa060dd4065f948447dc096ef96ec0e29102fb70d429bbdba0b18becda93c141e2faa8
7
- data.tar.gz: c88f340bd0a325928c9d94d2587e8c7c72a38f1735631416541070a1b8ed30999b725b871bbca1e5580d8baeaff451708ed4c3c761f3a206e1500ef9e44c4037
6
+ metadata.gz: af74f8cd44085dad4f62c112ad2c0d7ef041583e04f4b4d575a16c01b6308258b98ab91468b9a7fec9305dfa0433bf063c3c7ecf3bb7c7ed19a2c9a4ea35bc94
7
+ data.tar.gz: 82d6b7a67de239556611a318aa979deba3efeba24bc300b68ca000e4837ab98395afa52b9535a04b52cab676730c2ceb0b209627b280f77b470fda6ad049a079
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Apache License
2
2
  Version 2.0, January 2004
3
- http://www.apache.org/licenses/
3
+ https://www.apache.org/licenses/
4
4
 
5
5
  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
6
 
@@ -192,7 +192,7 @@
192
192
  you may not use this file except in compliance with the License.
193
193
  You may obtain a copy of the License at
194
194
 
195
- http://www.apache.org/licenses/LICENSE-2.0
195
+ https://www.apache.org/licenses/LICENSE-2.0
196
196
 
197
197
  Unless required by applicable law or agreed to in writing, software
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
@@ -1,10 +1,10 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -1,10 +1,10 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "google/cloud/configuration"
16
+ require "stackdriver/core/configuration"
17
17
  require "stackdriver/core/async_actor"
18
18
  require "stackdriver/core/configuration"
19
19
  require "stackdriver/core/trace_context"
@@ -1,10 +1,10 @@
1
- # Copyright 2017 Google Inc. All rights reserved.
1
+ # Copyright 2017 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -228,7 +228,7 @@ module Stackdriver
228
228
  # This should be the main task job that will be run asynchronously and
229
229
  # repeatly.
230
230
  def run_backgrounder
231
- fail "#{self.class} class should override #run_backgrounder method"
231
+ raise "#{self.class} class should override #run_backgrounder method"
232
232
  end
233
233
 
234
234
  ##
@@ -302,7 +302,7 @@ module Stackdriver
302
302
  # to run async_run_job. Also make calls register_for_cleanup on the
303
303
  # async job to make sure it exits properly.
304
304
  def ensure_thread
305
- fail "async_actor not initialized" if @startup_lock.nil?
305
+ raise "async_actor not initialized" if @startup_lock.nil?
306
306
  @startup_lock.synchronize do
307
307
  if (@thread.nil? || !@thread.alive?) && @async_state != :stopped
308
308
  @lock_cond = new_cond
@@ -352,8 +352,7 @@ module Stackdriver
352
352
  # @private Default abstract definition of this function that's a no-op.
353
353
  # The extending classes can override this method to handle state changing
354
354
  # logic.
355
- def on_async_state_change
356
- end
355
+ def on_async_state_change; end
357
356
  end
358
357
  end
359
358
  end
@@ -1,10 +1,10 @@
1
- # Copyright 2017 Google Inc. All rights reserved.
1
+ # Copyright 2017 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0oud
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,115 +13,12 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
+ require "google/cloud/config"
17
+
16
18
  module Stackdriver
17
19
  module Core
18
20
  ##
19
- # @private Helps organize configuration options for Stackdriver
20
- # instrumentation libraries. It's initialized with a nested list of
21
- # predefined category keys, then only allows getting and setting these
22
- # predefined options.
23
- #
24
- # @example
25
- # nested_categories = [:cat1, {cat2: [:cat3]}]
26
- # config = Stackdriver::Core::Configuration.new nested_categories
27
- #
28
- # config.opt1 #=> nil
29
- # config.opt1 = true #=> true
30
- # config.opt1 #=> true
31
- #
32
- # config.cat1 #=> <Stackdriver::Core::Configuration>
33
- # config.cat2.cat3 #=> <Stackdriver::Core::Configuration>
34
- #
35
- class Configuration
36
- ##
37
- # Constructs a new instance of Configuration object.
38
- #
39
- # @param [Symbol, Array<Symbol, Hash>, Hash<Symbol, (Array, Hash)>]
40
- # categories A Symbol, or nested Array and Hash of sub configuration
41
- # categories. A single symbol, or symbols in array, will be key(s) to
42
- # next level of categories. Nested hash represent sub categories with
43
- # further nested sub categories.
44
- #
45
- def initialize categories = {}
46
- @configs = {}
47
-
48
- add_options categories
49
- end
50
-
51
- ##
52
- # Add nested sub configuration categories to a Configuration object
53
- #
54
- # @param [Symbol, Array<Symbol, Hash>, Hash<Symbol, (Array, Hash)>]
55
- # categories A Symbol, or nested Array and Hash of sub configuration
56
- # categories. A single symbol, or symbols in array, will be key(s) to
57
- # next level of categories. Nested hash represent sub categories with
58
- # further nested sub categories.
59
- #
60
- # @example
61
- # config = Stackdriver::Core::Configuration.new
62
- # config.cat1 #=> nil
63
- # config.add_options {cat1: [:cat2]}
64
- # config.cat1 #=> <Stackdriver::Core::Configuration>
65
- # config.cat1.cat2 #=> <Stackdriver::Core::Configuration>
66
- #
67
- def add_options categories
68
- categories = [categories].flatten(1)
69
- categories.each do |sub_key|
70
- case sub_key
71
- when Symbol
72
- self[sub_key] = self.class.new
73
- when Hash
74
- sub_key.each do |k, v|
75
- self[k] = self.class.new v
76
- end
77
- else
78
- fail ArgumentError \
79
- "Configuration option can only be Symbol or Hash"
80
- end
81
- end
82
- end
83
-
84
- ##
85
- # Assign an option with `key` to value, while forcing `key` to be a
86
- # Symbol.
87
- def []= key, value
88
- @configs[key.to_sym] = value
89
- end
90
-
91
- ##
92
- # Get the option with `key`, while forcing `key` to be a Symbol.
93
- def [] key
94
- @configs[key.to_sym]
95
- end
96
-
97
- ##
98
- # Delete the option with `key`, while forcing `key` to be a Symbol.
99
- def delete key
100
- @configs.delete key.to_sym
101
- end
102
-
103
- ##
104
- # Check if the Configuration object has this option
105
- #
106
- # @param [Symbol] key The key to check for.
107
- #
108
- # @return [Boolean] True if the inquired key is a valid option for this
109
- # Configuration object. False otherwise.
110
- #
111
- def option? key
112
- @configs.key? key.to_sym
113
- end
114
-
115
- ##
116
- # @private Dynamic getters and setters
117
- def method_missing mid, *args
118
- method_string = mid.to_s
119
- if method_string.chomp!("=")
120
- self[method_string] = args.first
121
- else
122
- self[mid]
123
- end
124
- end
125
- end
21
+ # Keep this for backwards compatibility
22
+ Configuration = Google::Cloud::Config
126
23
  end
127
24
  end
@@ -1,10 +1,10 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,11 +29,11 @@ module Stackdriver
29
29
  class TraceContext
30
30
  ##
31
31
  # @private
32
- HEADER_RACK_KEY = "HTTP_X_CLOUD_TRACE_CONTEXT"
32
+ HEADER_RACK_KEY = "HTTP_X_CLOUD_TRACE_CONTEXT".freeze
33
33
 
34
34
  ##
35
35
  # @private
36
- MEMO_RACK_KEY = "google.cloud.trace_context"
36
+ MEMO_RACK_KEY = "google.cloud.trace_context".freeze
37
37
 
38
38
  ##
39
39
  # @private
@@ -70,11 +70,11 @@ module Stackdriver
70
70
  def initialize trace_id: nil, is_new: nil, span_id: nil, sampled: nil,
71
71
  capture_stack: false
72
72
  @trace_id = trace_id || new_random_trace_id
73
- if is_new.nil?
74
- @is_new = !trace_id
75
- else
76
- @is_new = is_new ? true : false
77
- end
73
+ @is_new = if is_new.nil?
74
+ !trace_id
75
+ else
76
+ is_new ? true : false
77
+ end
78
78
  @span_id = span_id ? span_id.to_i : nil
79
79
  @sampled = sampled
80
80
  if @sampled.nil?
@@ -145,7 +145,7 @@ module Stackdriver
145
145
  sampled? == other.sampled? &&
146
146
  capture_stack? == other.capture_stack?
147
147
  end
148
- alias_method :==, :eql?
148
+ alias == eql?
149
149
 
150
150
  ##
151
151
  # Generate standard hash code for this object.
@@ -206,7 +206,7 @@ module Stackdriver
206
206
  end
207
207
  str
208
208
  end
209
- alias_method :to_s, :to_string
209
+ alias to_s to_string
210
210
 
211
211
  ##
212
212
  # Attempts to parse the given string as a trace context representation.
@@ -226,21 +226,19 @@ module Stackdriver
226
226
  #
227
227
  def self.parse_string str
228
228
  match = %r|^(\w{32})(/(\d+))?(;o=(\d+))?|.match str
229
- if match
230
- trace_id = match[1]
231
- span_id = match[3] ? match[3].to_i : nil
232
- options = match[5] ? match[5].to_i : nil
233
- if options.nil?
234
- sampled = capture_stack = nil
235
- else
236
- sampled = options & 1 != 0
237
- capture_stack = options & 2 != 0
238
- end
239
- new trace_id: trace_id, span_id: span_id, sampled: sampled,
240
- capture_stack: capture_stack
229
+ return unless match
230
+
231
+ trace_id = match[1]
232
+ span_id = match[3] ? match[3].to_i : nil
233
+ options = match[5] ? match[5].to_i : nil
234
+ if options.nil?
235
+ sampled = capture_stack = nil
241
236
  else
242
- nil
237
+ sampled = options & 1 != 0
238
+ capture_stack = options & 2 != 0
243
239
  end
240
+ new trace_id: trace_id, span_id: span_id, sampled: sampled,
241
+ capture_stack: capture_stack
244
242
  end
245
243
 
246
244
  ##
@@ -1,10 +1,10 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,6 +15,6 @@
15
15
 
16
16
  module Stackdriver
17
17
  module Core
18
- VERSION = "1.2.0".freeze
18
+ VERSION = "1.3.0".freeze
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackdriver-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.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-07-12 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-cloud-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: minitest
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +98,16 @@ dependencies:
84
98
  name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "<="
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 0.35.1
103
+ version: 0.50.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "<="
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 0.35.1
110
+ version: 0.50.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +161,6 @@ files:
147
161
  - ".yardopts"
148
162
  - LICENSE
149
163
  - README.md
150
- - lib/google/cloud/configuration.rb
151
164
  - lib/stackdriver-core.rb
152
165
  - lib/stackdriver/core.rb
153
166
  - lib/stackdriver/core/async_actor.rb
@@ -174,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
187
  version: '0'
175
188
  requirements: []
176
189
  rubyforge_project:
177
- rubygems_version: 2.6.12
190
+ rubygems_version: 2.7.6
178
191
  signing_key:
179
192
  specification_version: 4
180
193
  summary: Internal shared library for Ruby Stackdriver integration
@@ -1,63 +0,0 @@
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
- require "stackdriver/core/configuration"
17
-
18
- module Google
19
- module Cloud
20
- ##
21
- # @private Defines Google::Cloud.configure method. This will be the root
22
- # configuration object shared by Stackdriver instrumentation libraries'
23
- # configurations.
24
- module Configuration
25
- ##
26
- # @private The shared Configuration object that all the Stackdriver
27
- # instrumentation libraries will build on top of.
28
- @@config = ::Stackdriver::Core::Configuration.new
29
-
30
- ##
31
- # Configure the default parameter for Google::Cloud. The values defined on
32
- # this top level will be shared across all Stackdriver instrumentation
33
- # libraries (Debugger, ErrorReporting, Logging, and Trace). These other
34
- # libraries may also add sub configuration options under this.
35
- #
36
- # Possible configuration parameters:
37
- # * project_id: The Google Cloud Project ID. Automatically discovered
38
- # when running from GCP environments.
39
- # * keyfile: The service account JSON file path. Automatically
40
- # discovered when running from GCP environments.
41
- # * use_debugger: Explicitly enable or disable Stackdriver Debugger
42
- # instrumentation
43
- # * use_error_reporting: Explicitly enable or disable Stackdriver Error
44
- # Reporting instrumentation
45
- # * use_logging: Explicitly enable or disable Stackdriver Logging
46
- # instrumentation
47
- # * use_trace: Explicitly enable or disable Stackdriver
48
- #
49
- # @return [Stackdriver::Core::Configuration] The configuration object
50
- # the Google::Cloud module uses.
51
- #
52
- def configure
53
- yield @@config if block_given?
54
-
55
- @@config
56
- end
57
- end
58
-
59
- # Immediately extend Google::Cloud::Configuration#configure
60
- # into Google::Cloud.configure
61
- extend Configuration
62
- end
63
- end