instana 1.10.10 → 1.11.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
2
  SHA256:
3
- metadata.gz: 54dbfa2e6e3fee8fd8337508ce7d7d081a1194f8af73bde7c2cf5fb35aac326a
4
- data.tar.gz: c075709c97ef6659d4ab6f5533cad16f77fdcaaff79ebd6fabeddf53f49ef72f
3
+ metadata.gz: 1d71c06463463f206e4dd8aeae47776ce792a130d3aa6daccc0477823dd7a357
4
+ data.tar.gz: bb6fe211979e648b15a48f7fbc949a4ee9408f6a46808159e32a8bf7323e8336
5
5
  SHA512:
6
- metadata.gz: f290172a3f51b156f1eece7f23a53021766c7213b795191c5c33103c57006ce96e7155fee264dfcf102ebcc2836f55f52ef5e1faf2074d1b23e1953db932803d
7
- data.tar.gz: a664f54a125015cb539e690add70372cdfea5d8519f556a36a88b7680a5b7cf65fbaece21b56a45a756d4d4a6432fd8327413b4d06a7850c23fc9a4ff5b1a876
6
+ metadata.gz: 20493e913bc0569334318bbfeab8590da2a3507810a51f35adaf7320d5d552aefecf12a37e29b0d47e250d5bf4eeecf81e5332d96c1bdaa784fb0ed9bc047984
7
+ data.tar.gz: d1cebdc236820122711614678d777c4d96587f3672ead7430ccb48b65743b1dfa38df8007647e39ef34fbe01ecab32dc58d4afdaa5c186903e593fffb653bba0
data/Dockerfile CHANGED
@@ -1,13 +1,16 @@
1
1
  # For development/testing, you can run this instrumentation
2
2
  # interactively in a Docker container:
3
- # docker build -t instana/ruby-sensor-console:0.1
4
- # docker run -it instana/ruby-sensor-console:0.1
5
- #
6
- FROM ruby:2.3.1
7
- RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs openssh-client git vim zip curl uni2ascii bsdmainutils
8
- RUN mkdir /ruby-sensor
9
- WORKDIR /ruby-sensor
10
- COPY Gemfile Gemfile.lock instana.gemspec ./
11
- COPY . ./
12
- RUN gem install bundler && bundle install --jobs 20 --retry 5
13
- CMD bundle exec rake console
3
+ # docker build -t instana/ruby-sensor:1.0
4
+ #
5
+ # To mount the host ruby-sensor directory in the container:
6
+ # docker run -v /host/path/to/ruby-sensor:/ruby-sensor instana/ruby-sensor:1.0 /bin/bash
7
+ #
8
+ # Once inside the container, you can run `cd /ruby-sensor && bundle install && bundle exec rake console` for a development
9
+ # console in the gem.
10
+ #
11
+ # https://github.com/instana/ruby-sensor#development
12
+ #
13
+ FROM ruby:2.6
14
+ ENV INSTANA_DEBUG=true
15
+ RUN gem install bundler
16
+ RUN apt update && apt install -y vim
@@ -231,25 +231,35 @@ module Instana
231
231
  @process = ::Instana::Util.collect_process_info
232
232
 
233
233
  announce_payload = {}
234
- announce_payload[:pid] = pid_namespace? ? get_real_pid : Process.pid
235
234
  announce_payload[:name] = @process[:name]
236
235
  announce_payload[:args] = @process[:arguments]
237
236
 
237
+ socket = nil
238
238
  if @is_linux && !@testmode
239
239
  # We create an open socket to the host agent in case we are running in a container
240
240
  # and the real pid needs to be detected.
241
- socket = TCPSocket.new @discovered[:agent_host], @discovered[:agent_port]
241
+ socket = TCPSocket.open @discovered[:agent_host], @discovered[:agent_port]
242
+
242
243
  announce_payload[:fd] = socket.fileno
243
- announce_payload[:inode] = File.readlink("/proc/#{Process.pid}/fd/#{socket.fileno}")
244
+ announce_payload[:inode] = File.readlink("/proc/self/fd/#{socket.fileno}")
245
+ announce_payload[:cpuSetFileContent] = get_cpuset_contents
246
+
247
+ sched_pid = get_sched_pid
248
+ announce_payload[:pid] = sched_pid
249
+ announce_payload[:pidFromParentNS] = running_in_container? && (sched_pid != Process.pid)
250
+ else
251
+ announce_payload[:pid] = Process.pid
252
+ announce_payload[:pidFromParentNS] = true
244
253
  end
245
254
 
246
255
  uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{DISCOVERY_PATH}")
247
256
  req = Net::HTTP::Put.new(uri)
248
257
  req.body = Oj.dump(announce_payload, OJ_OPTIONS)
249
258
 
250
- ::Instana.logger.debug { "Announce: http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{DISCOVERY_PATH} - payload: #{req.body}" }
259
+ #::Instana.logger.debug("Announce payload: #{announce_payload}")
260
+ #::Instana.logger.debug { "Announce: http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{DISCOVERY_PATH} - payload: #{req.body}" }
251
261
 
252
- response = make_host_agent_request(req)
262
+ response = make_host_agent_request(req, open_timeout=3, read_timeout=3, debug=true)
253
263
 
254
264
  if response && (response.code.to_i == 200)
255
265
  data = Oj.load(response.body, OJ_OPTIONS)
@@ -449,18 +459,21 @@ module Instana
449
459
  # @param req [Net::HTTP::Req] A prepared Net::HTTP request object of the type
450
460
  # you wish to make (Get, Put, Post etc.)
451
461
  #
452
- def make_host_agent_request(req)
462
+ def make_host_agent_request(req, open_timeout=1, read_timeout=1, debug=false)
453
463
  req['Accept'] = MIME_JSON
454
464
  req['Content-Type'] = MIME_JSON
455
465
 
456
466
  if @state == :unannounced
457
467
  @httpclient = Net::HTTP.new(req.uri.hostname, req.uri.port)
458
- @httpclient.open_timeout = 1
459
- @httpclient.read_timeout = 1
468
+ @httpclient.open_timeout = open_timeout
469
+ @httpclient.read_timeout = read_timeout
460
470
  end
461
471
 
462
472
  response = @httpclient.request(req)
463
- # ::Instana.logger.debug "#{req.method}->#{req.uri} body:(#{req.body}) Response:#{response} body:(#{response.body})"
473
+
474
+ if debug
475
+ ::Instana.logger.debug "#{req.method}->#{req.uri} body:(#{req.body}) Response:#{response} body:(#{response.body})"
476
+ end
464
477
 
465
478
  response
466
479
  rescue Errno::ECONNREFUSED
@@ -7,13 +7,20 @@ module AgentHelpers
7
7
  Process.pid != get_real_pid
8
8
  end
9
9
 
10
+ # Attempts to determine if we're running inside a container.
11
+ # The qualifications are:
12
+ # 1. Linux based OS
13
+ # 2. /proc/self/cpuset exists and contents include a container id
14
+ def running_in_container?
15
+ return false unless @is_linux
16
+ get_cpuset_contents == '/' ? false : true
17
+ end
18
+
10
19
  # Attempts to determine the true process ID by querying the
11
20
  # /proc/<pid>/sched file. This works on linux currently.
12
21
  #
13
- def get_real_pid
14
- raise RuntimeError.new("Unsupported platform: get_real_pid") unless @is_linux
15
-
16
- sched_file = "/proc/#{Process.pid}/sched"
22
+ def get_sched_pid
23
+ sched_file = "/proc/self/sched"
17
24
  pid = Process.pid
18
25
 
19
26
  if File.exist?(sched_file)
@@ -23,6 +30,19 @@ module AgentHelpers
23
30
  pid
24
31
  end
25
32
 
33
+ # Open and read /proc/<pid>/cpuset and return as a string. Used as
34
+ # part of the announce payload for process differentiation.
35
+ #
36
+ def get_cpuset_contents
37
+ cpuset_file = "/proc/#{Process.pid}/cpuset"
38
+ contents = ""
39
+
40
+ if File.exist?(cpuset_file)
41
+ contents = File.open(cpuset_file, "r").read
42
+ end
43
+ contents
44
+ end
45
+
26
46
  # Returns the PID that we are reporting to
27
47
  #
28
48
  def report_pid
@@ -1,4 +1,4 @@
1
1
  module Instana
2
- VERSION = "1.10.10"
2
+ VERSION = "1.11.0"
3
3
  VERSION_FULL = "instana-#{VERSION}"
4
4
  end
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.10.10
4
+ version: 1.11.0
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: 2019-10-09 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler