instana 1.7.0 → 1.7.1

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
2
  SHA1:
3
- metadata.gz: 2b5079ebac90a5ee51a0a808661dd4ccf2f0a308
4
- data.tar.gz: 61284e14d6d709258d7b67e5f0e582cc0fb9d72c
3
+ metadata.gz: 44130c934680011eede485a8a15d5e4cd893e7ec
4
+ data.tar.gz: 4a2af4a9b1a888b81f733d8362da8f0efa409033
5
5
  SHA512:
6
- metadata.gz: 4eb5d83f78ae37c40b3e0d7a959391e67b938876cd13a0d1d07bc6c9b0638e0486626caf03349eb974dd5efc9bf62feb459607d978a57e557fd004709ebb9c74
7
- data.tar.gz: adfdead8d412acb7bcaef9a1e51e9bdb70a4dd6aaaf323ffde5ddc4a5aa0950a6653b4015575f0fea65ad10b00b3fc71864d9cf61a5d1d5f2f41d5ab6b7ebba1
6
+ metadata.gz: 893eedd5bf3fa56b18c54ac511a430f41a5a27a650c12dee8f7ef1576e9b28aa0571c69e02c279976c5e05b566052b73a0aeffdc26e56e9eac38d8bea90b37f2
7
+ data.tar.gz: a3790d930ba1c5afd2622703458497006055bf984d54ff652ac41a277be8048abe3d1cea7dc9855e1e2cbd85b00a2e891eaec0fd2641a4794bd1babbc8f54999
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Instana
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/lib/instana/agent.rb CHANGED
@@ -4,6 +4,7 @@ require 'socket'
4
4
  require 'sys/proctable'
5
5
  require 'timers'
6
6
  require 'uri'
7
+ require 'thread'
7
8
  include Sys
8
9
 
9
10
  module Instana
@@ -11,6 +12,8 @@ module Instana
11
12
  attr_accessor :state
12
13
  attr_accessor :agent_uuid
13
14
  attr_accessor :process
15
+ attr_accessor :collect_thread
16
+ attr_accessor :thread_spawn_lock
14
17
 
15
18
  LOCALHOST = '127.0.0.1'.freeze
16
19
  MIME_JSON = 'application/json'.freeze
@@ -32,6 +35,8 @@ module Instana
32
35
  @announce_timer = nil
33
36
  @collect_timer = nil
34
37
 
38
+ @thread_spawn_lock = Mutex.new
39
+
35
40
  # Detect platform flags
36
41
  @is_linux = (RUBY_PLATFORM =~ /linux/i) ? true : false
37
42
  @is_osx = (RUBY_PLATFORM =~ /darwin/i) ? true : false
@@ -90,12 +95,15 @@ module Instana
90
95
  # end
91
96
  #
92
97
  def spawn_background_thread
93
- # The thread calling fork is the only thread in the created child process.
94
- # fork doesn’t copy other threads.
95
- # Restart our background thread
96
- Thread.new do
97
- start
98
- end
98
+ @thread_spawn_lock.synchronize {
99
+ if @collect_thread && @collect_thread.alive?
100
+ ::Instana.logger.info "[instana] Collect thread already started & alive. Not spawning another."
101
+ else
102
+ @collect_thread = Thread.new do
103
+ start
104
+ end
105
+ end
106
+ }
99
107
  end
100
108
 
101
109
  # Sets up periodic timers and starts the agent in a background thread.
@@ -104,7 +112,7 @@ module Instana
104
112
  # The announce timer
105
113
  # We attempt to announce this ruby sensor to the host agent.
106
114
  # In case of failure, we try again in 30 seconds.
107
- @announce_timer = @timers.every(30) do
115
+ @announce_timer = @timers.now_and_every(30) do
108
116
  if @state == :unannounced
109
117
  if host_agent_ready? && announce_sensor
110
118
  transition_to(:announced)
@@ -143,6 +151,7 @@ module Instana
143
151
  #
144
152
  def start
145
153
  ::Instana.logger.warn "Host agent not available. Will retry periodically." unless host_agent_ready?
154
+
146
155
  loop do
147
156
  if @state == :unannounced
148
157
  @collect_timer.pause
@@ -25,6 +25,11 @@ module Instana
25
25
  #
26
26
  # @param [Trace] the trace to be added to the queue
27
27
  def add(trace)
28
+ # Do a quick checkup on our background thread.
29
+ if ::Instana.agent.collect_thread.nil? || !::Instana.agent.collect_thread.alive?
30
+ ::Instana.agent.spawn_background_thread
31
+ end
32
+
28
33
  # ::Instana.logger.debug("Queuing completed trace id: #{trace.id}")
29
34
  @queue.push(trace)
30
35
  end
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
data/lib/instana.rb CHANGED
@@ -5,9 +5,8 @@ require "instana/setup"
5
5
  #
6
6
  # gem "instana", :require => "instana/setup"
7
7
  #
8
- # ...and manually call ::Instana.agent.start in the thread
9
- # of your choice
8
+ # ...and override ::Instana::Agent.spawn_background_thread to boot
9
+ # the thread of your choice.
10
10
  #
11
- Thread.new do
12
- ::Instana.agent.start
13
- end
11
+
12
+ ::Instana.agent.spawn_background_thread
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Giacomo Lombardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -164,6 +164,7 @@ files:
164
164
  - Configuration.md
165
165
  - Dockerfile
166
166
  - Gemfile
167
+ - LICENSE
167
168
  - README.md
168
169
  - Rakefile
169
170
  - Tracing.md