chef-telemetry 1.0.0 → 1.0.8

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: faf29c758b1dbcddd569962312d55a7f9b7648ac2fed2896a962360f62d50b93
4
- data.tar.gz: '079575327ecc06c86e9fb305cd4e0b6339ea443ad53800006f74baa710d9f266'
3
+ metadata.gz: 9f2ff4beb037d29b86146839a762c60921a201762c1d1d747df5c19ba3c244b0
4
+ data.tar.gz: 24c6da8c811b432061f122c9574a6defdcc432f8228db2aae6fcf98a301d36db
5
5
  SHA512:
6
- metadata.gz: 35a60bfa480f9085eac39bd3f1699ab2926f1c270e947439c13bfbc585e97849b5cb155bf8eaadef41496fc0a62c13867dc25b3380ece12d1460e84fee8794aa
7
- data.tar.gz: 4bd4017b173ba7a50f5888550c16e1b0616c0a2b6176ba719513bad27ece43ce32dca9208ad7a891e519e3d957e64c26ce8ef56e20ca2eace83383c743b81592
6
+ metadata.gz: 54e5b9ba49b785a70db72c9d03a7ceadf4a52f1f78c3fb6be191e43494c022a98fe905bea220f5e962f784a30daca4b8ce94921ccc1f367fb91a9050837efe66
7
+ data.tar.gz: 8806715da530362fe23e6ae512b9455aa5e13115476a5e749f593a4ff19cda706322859818e047573ad0410a46afdb6e1af64318a30f42fcdcbe31c8aa7e6845
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "chef/telemetry/version"
18
+ require_relative "telemetry/version"
19
19
  require "benchmark"
20
20
  require "forwardable"
21
21
  require "singleton"
@@ -24,7 +24,7 @@ require "digest/sha1"
24
24
  require "securerandom"
25
25
  require "yaml"
26
26
 
27
- module Chef
27
+ class Chef
28
28
  # This definites the Telemeter interface. Implementation thoughts for
29
29
  # when we unstub it:
30
30
  # - let's track the call sequence; most of our calls will be nested inside
@@ -51,17 +51,18 @@ module Chef
51
51
  # :dev_mode # false, not required
52
52
  config[:dev_mode] ||= false
53
53
  config[:enabled] ||= false
54
- require "chef_core/telemeter/sender"
54
+ require_relative "telemeter/sender"
55
55
  @config = config
56
56
  Sender.start_upload_thread(config)
57
57
  end
58
58
 
59
59
  def enabled?
60
- require "chef/telemetry/decision"
60
+ require_relative "telemetry/decision"
61
61
  config[:enabled] && !Telemetry::Decision.env_opt_out?
62
62
  end
63
63
 
64
64
  def initialize
65
+ @config = []
65
66
  @events_to_send = []
66
67
  @run_timestamp = Time.now.utc.strftime("%FT%TZ")
67
68
  end
@@ -15,11 +15,11 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "chef/telemetry"
19
- require "chef/telemeter"
18
+ require_relative "../telemetry"
19
+ require_relative "../telemeter"
20
20
  require "logger"
21
21
 
22
- module Chef
22
+ class Chef
23
23
  class Telemeter
24
24
  logger = ::Logger.new(STDERR) # TODO: maybe switch to file, maybe switch to mixlib
25
25
  logger.level = Logger::ERROR
@@ -1,10 +1,10 @@
1
- require "chef/telemetry/client"
2
- require "chef/telemetry/decision"
3
- require "chef/telemetry/event"
4
- require "chef/telemetry/session"
5
- require "chef/telemetry/version"
1
+ require_relative "telemetry/client"
2
+ require_relative "telemetry/decision"
3
+ require_relative "telemetry/event"
4
+ require_relative "telemetry/session"
5
+ require_relative "telemetry/version"
6
6
 
7
- module Chef
7
+ class Chef
8
8
  class Telemetry
9
9
  attr_accessor :product, :origin, :product_version, :install_context
10
10
  def initialize(product: nil, origin: "command-line",
@@ -1,7 +1,9 @@
1
- require "http"
1
+ require "net/http"
2
+ require "uri"
3
+ require "json"
2
4
  require "concurrent"
3
5
 
4
- module Chef
6
+ class Chef
5
7
  class Telemetry
6
8
  class Client
7
9
  include Concurrent::Async
@@ -11,11 +13,18 @@ module Chef
11
13
  attr_reader :http
12
14
  def initialize(endpoint = TELEMETRY_ENDPOINT)
13
15
  super()
14
- @http = HTTP.persistent(endpoint)
16
+ uri = URI(endpoint)
17
+ @http = Net::HTTP.new(uri.host, uri.port)
18
+ @http.use_ssl = uri.scheme == "https"
19
+ @http.start
15
20
  end
16
21
 
17
22
  def fire(event)
18
- http.post("/events", json: event).flush
23
+ req = Net::HTTP::Post.new("/events")
24
+ req["Content-Type"] = "application/json"
25
+ req.body = JSON.dump(event)
26
+ # TODO: @cwolfe use response and at least debug log status
27
+ http.request req
19
28
  end
20
29
  end
21
30
 
@@ -2,7 +2,7 @@ require "chef-config/path_helper"
2
2
  require "chef-config/windows"
3
3
 
4
4
  # Decision allows us to inspect whether the user has made a decision to opt in or opt out of telemetry.
5
- module Chef
5
+ class Chef
6
6
  class Telemetry
7
7
  module Decision
8
8
  OPT_OUT_FILE = "telemetry_opt_out".freeze
@@ -1,4 +1,4 @@
1
- module Chef
1
+ class Chef
2
2
  class Telemetry
3
3
  class Event
4
4
 
@@ -1,7 +1,7 @@
1
1
  require "securerandom"
2
2
  require "chef-config/path_helper"
3
3
 
4
- module Chef
4
+ class Chef
5
5
  class Telemetry
6
6
  class Session
7
7
  def initialize
@@ -1,5 +1,5 @@
1
- module Chef
1
+ class Chef
2
2
  class Telemetry
3
- VERSION = "1.0.0".freeze
3
+ VERSION = "1.0.8".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-telemetry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-03 00:00:00.000000000 Z
11
+ date: 2020-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: http
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.2'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: ffi-yajl
43
29
  requirement: !ruby/object:Gem::Requirement