hubstep 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/hubstep.gemspec +2 -1
- data/lib/hubstep/faraday/middleware.rb +1 -2
- data/lib/hubstep/tracer.rb +0 -2
- data/lib/hubstep/transport/http_json.rb +68 -32
- data/lib/hubstep/version.rb +2 -1
- data/lib/hubstep.rb +0 -20
- metadata +4 -6
- data/lib/hubstep/internal/instrumenter/memory.rb +0 -35
- data/lib/hubstep/internal/instrumenter/noop.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6daeef652b6059de7c8414e25607406ac11cc1d9
|
4
|
+
data.tar.gz: 90cbcab84a1aa56013c5830a9bb2759b8983af9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e9b64109349da07a79569580694a032746e4bc5ecc9a5f3d33f45b14409932e5b9b33385345e2131571d77d875df948561a8190abba22a7b8df3d5a6872233
|
7
|
+
data.tar.gz: cbc706f4afa3a8b2dfded9b02723bc0a769e5fc5f8aeb91467baadb52965b96202f45c2a27a6ab09ab30006ef5cb2f53ba12c63526df3041a6721df9903fafcc
|
data/.rubocop.yml
CHANGED
@@ -5,6 +5,9 @@ AllCops:
|
|
5
5
|
Exclude:
|
6
6
|
- "bin/**/*"
|
7
7
|
- "vendor/**/*"
|
8
|
+
Lint/AmbiguousBlockAssociation:
|
9
|
+
Exclude:
|
10
|
+
- "test/**/*"
|
8
11
|
|
9
12
|
Metrics/BlockLength:
|
10
13
|
Exclude:
|
@@ -19,9 +22,13 @@ Metrics/LineLength:
|
|
19
22
|
|
20
23
|
Metrics/MethodLength:
|
21
24
|
Max: 15
|
25
|
+
Exclude:
|
26
|
+
- "test/**/*"
|
22
27
|
|
23
28
|
Metrics/AbcSize:
|
24
29
|
Max: 17
|
30
|
+
Exclude:
|
31
|
+
- "test/**/*"
|
25
32
|
|
26
33
|
Style/DoubleNegation:
|
27
34
|
Enabled: false
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/hubstep.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# frozen_string_literal: true
|
3
|
+
|
3
4
|
lib = File.expand_path("../lib", __FILE__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
require "hubstep/version"
|
@@ -28,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.add_development_dependency "bundler", "~> 1.13"
|
29
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
30
31
|
spec.add_development_dependency "minitest", "~> 5.0"
|
31
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
32
|
+
spec.add_development_dependency "rubocop", "~> 0.49.0"
|
32
33
|
spec.add_development_dependency "rack-test", "~> 0.6"
|
33
34
|
spec.add_development_dependency "activesupport", "~> 4.0"
|
34
35
|
spec.add_development_dependency "faraday", "~> 0.10"
|
data/lib/hubstep/tracer.rb
CHANGED
@@ -132,14 +132,12 @@ module HubStep
|
|
132
132
|
host = ENV["LIGHTSTEP_COLLECTOR_HOST"]
|
133
133
|
port = ENV["LIGHTSTEP_COLLECTOR_PORT"]
|
134
134
|
encryption = ENV["LIGHTSTEP_COLLECTOR_ENCRYPTION"]
|
135
|
-
verbosity = Integer(ENV.fetch("LIGHTSTEP_TRANSPORT_VERBOSITY", 0))
|
136
135
|
access_token = ENV["LIGHTSTEP_ACCESS_TOKEN"]
|
137
136
|
|
138
137
|
if host && port && encryption && access_token
|
139
138
|
HubStep::Transport::HTTPJSON.new(host: host,
|
140
139
|
port: port.to_i,
|
141
140
|
encryption: encryption,
|
142
|
-
verbose: verbosity,
|
143
141
|
access_token: access_token)
|
144
142
|
else
|
145
143
|
LightStep::Transport::Nil.new
|
@@ -5,47 +5,83 @@ require "net/http"
|
|
5
5
|
|
6
6
|
unless LightStep::VERSION == '0.11.2'
|
7
7
|
raise <<-MSG
|
8
|
-
This
|
9
|
-
To review,
|
10
|
-
method and
|
11
|
-
changes that seem necessary.
|
8
|
+
This custom transport needs to be reviewed for new LightStep versions.
|
9
|
+
To review, compare this implementation with `LightStep::Transport::HTTPJSON#report`
|
10
|
+
method and port any changes that seem necessary.
|
12
11
|
MSG
|
13
12
|
end
|
14
13
|
|
15
14
|
module HubStep
|
16
15
|
module Transport
|
17
|
-
# HTTPJSON is
|
18
|
-
#
|
19
|
-
# in the queue will be copied and sent in duplicate.
|
16
|
+
# HTTPJSON is our customized transport which add some additional
|
17
|
+
# instrumentation and performance improvements.
|
20
18
|
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
19
|
+
# Callback Notes: To provide some observability into this transport's
|
20
|
+
# operation, we allow a callback `on_report_callback` to be provided. This
|
21
|
+
# callback will be called with the signature (report, result, duration_ms)
|
22
|
+
# where result can be either the http response or an exception. This
|
23
|
+
# callback will be delivered while maintaining this transports mutex which
|
24
|
+
# should provide some measure of thread-safety for the caller.
|
25
|
+
class HTTPJSON < LightStep::Transport::Base
|
26
|
+
ENCRYPTION_TLS = 'tls'
|
27
|
+
ENCRYPTION_NONE = 'none'
|
28
|
+
|
29
|
+
# Initialize the transport
|
30
|
+
# @param host [String] host of the domain to the endpoind to push data
|
31
|
+
# @param port [Numeric] port on which to connect
|
32
|
+
# @param encryption [ENCRYPTION_TLS, ENCRYPTION_NONE] kind of encryption to use
|
33
|
+
# @param access_token [String] access token for LightStep server
|
34
|
+
# @param on_report_callback [method] Called after reporting has completed
|
35
|
+
# @return [HTTPJSON]
|
36
|
+
def initialize(host:, port:, encryption: ENCRYPTION_TLS, access_token:, on_report_callback: nil)
|
37
|
+
@on_report_callback = on_report_callback
|
38
|
+
|
39
|
+
raise Tracer::ConfigurationError, "host must be specified" if host.nil? || host.empty?
|
40
|
+
raise Tracer::ConfigurationError, "port must be specified" if port.nil?
|
41
|
+
raise Tracer::ConfigurationError, "access_token must be a string" unless String === access_token
|
42
|
+
raise Tracer::ConfigurationError, "access_token cannot be blank" if access_token.empty?
|
43
|
+
|
44
|
+
@access_token = access_token
|
45
|
+
|
46
|
+
# This mutex protects the use of our Net::HTTP instance which we
|
47
|
+
# maintain as a long lived connection. While a Lightstep::Transport is
|
48
|
+
# typically called only from within the reporting thread, there are
|
49
|
+
# some situations where this can be bypassed (directly calling `flush`
|
50
|
+
# for example)
|
51
|
+
@mutex = Mutex.new
|
52
|
+
|
53
|
+
@https = Net::HTTP.new(host, port)
|
54
|
+
@https.use_ssl = encryption == ENCRYPTION_TLS
|
55
|
+
end
|
56
|
+
|
57
|
+
def report(report)
|
58
|
+
start = Time.now
|
59
|
+
|
60
|
+
req = request report
|
61
|
+
|
62
|
+
@mutex.synchronize do
|
63
|
+
begin
|
64
|
+
res = @https.request(req)
|
65
|
+
rescue => e
|
66
|
+
res = e
|
67
|
+
ensure
|
68
|
+
@on_report_callback&.call(report, res, start)
|
69
|
+
end
|
44
70
|
end
|
45
71
|
|
46
72
|
nil
|
47
|
-
|
48
|
-
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def request(report)
|
78
|
+
req = Net::HTTP::Post.new('/api/v0/reports')
|
79
|
+
req['LightStep-Access-Token'] = @access_token
|
80
|
+
req['Content-Type'] = 'application/json'
|
81
|
+
req['Connection'] = 'keep-alive'
|
82
|
+
|
83
|
+
req.body = report.to_json
|
84
|
+
req
|
49
85
|
end
|
50
86
|
end
|
51
87
|
end
|
data/lib/hubstep/version.rb
CHANGED
data/lib/hubstep.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "hubstep/tracer"
|
4
|
-
require "hubstep/internal/instrumenter/noop"
|
5
4
|
require "hubstep/version"
|
6
5
|
|
7
6
|
require "socket"
|
@@ -27,23 +26,4 @@ module HubStep
|
|
27
26
|
{}.freeze
|
28
27
|
end
|
29
28
|
end
|
30
|
-
|
31
|
-
# setter for instrumenter that defaults to the Noop instrumenter
|
32
|
-
#
|
33
|
-
# instrumenter - an object that responds to the ActiveSupport::Notifications
|
34
|
-
# interface, when omitted the Noop instrumenter will be used
|
35
|
-
#
|
36
|
-
def self.instrumenter=(instrumenter)
|
37
|
-
@instrumenter = instrumenter
|
38
|
-
end
|
39
|
-
|
40
|
-
# getter for the instrumenter ivar. When the ivar isn't set it will
|
41
|
-
# default to the Noop instrumenter
|
42
|
-
#
|
43
|
-
# instrumenter - an object that responds to the ActiveSupport::Notifications
|
44
|
-
# interface, when omitted the Noop instrumenter will be used
|
45
|
-
#
|
46
|
-
def self.instrumenter(instrumenter: nil)
|
47
|
-
@instrumenter ||= (instrumenter || HubStep::Internal::Instrumenter::Noop.new)
|
48
|
-
end
|
49
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lightstep
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.49.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.49.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rack-test
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,8 +202,6 @@ files:
|
|
202
202
|
- lib/hubstep/failbot.rb
|
203
203
|
- lib/hubstep/faraday/middleware.rb
|
204
204
|
- lib/hubstep/instrumenter.rb
|
205
|
-
- lib/hubstep/internal/instrumenter/memory.rb
|
206
|
-
- lib/hubstep/internal/instrumenter/noop.rb
|
207
205
|
- lib/hubstep/rack/middleware.rb
|
208
206
|
- lib/hubstep/tracer.rb
|
209
207
|
- lib/hubstep/transport/http_json.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module HubStep
|
4
|
-
module Internal
|
5
|
-
module Instrumenter
|
6
|
-
# A memory instrumenter to be used in to test instrumentation. This class records
|
7
|
-
# each instrument call in a HubStep::Internal::Instrumenter::Memory::Event instance
|
8
|
-
# and stores the instance in an events array.
|
9
|
-
class Memory
|
10
|
-
class Event # rubocop:disable Style/Documentation
|
11
|
-
attr_reader :name, :payload, :result
|
12
|
-
|
13
|
-
def initialize(name, payload, result)
|
14
|
-
@name = name
|
15
|
-
@payload = payload
|
16
|
-
@result = result
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
@events = []
|
22
|
-
end
|
23
|
-
|
24
|
-
attr_reader :events
|
25
|
-
|
26
|
-
def instrument(name, payload = {})
|
27
|
-
payload = payload.dup
|
28
|
-
result = (yield payload if block_given?)
|
29
|
-
@events << Event.new(name, payload, result)
|
30
|
-
result
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module HubStep
|
4
|
-
module Internal
|
5
|
-
module Instrumenter
|
6
|
-
# A noop instrumenter that fulfills the interface for ActiveSupport::Notifications
|
7
|
-
# but does nothing. This is the default instrumenter when the client does not pass
|
8
|
-
# one in
|
9
|
-
class Noop
|
10
|
-
def instrument(_name, payload = {})
|
11
|
-
yield payload if block_given?
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|