plain_apm 0.2.8 → 0.3.0

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: fae5b33c61e3205e05e0321b6e2189f458095998d466c5f8f3494902eb279f26
4
- data.tar.gz: 0e46fdbd9c5a3e7c6a41c4e75767046a03811c7d6c0af8688f72e14b5dce1a4e
3
+ metadata.gz: e496879797c3c3bedfeea9f641b9f113bae2104b6a3c69bb67fdd6cfd8734af6
4
+ data.tar.gz: 484e1217d8d459ccf6c3619da23730c2126094136648a6c8fe15f5dbb63962b1
5
5
  SHA512:
6
- metadata.gz: 10f006bfd8ef860ca46a4af5656f99665c0de125d41d611a07678364650e50de6ca0b45cb34f2962a6344f6425ec8cf47af93c512bad50c2f712eca0bd3a9f65
7
- data.tar.gz: 8f6d46f2e471fe8f5a917ececcee37db2f0c6e056e62f0320eb17797424ec86a73a43b942b54fd2e619becfdd0725705f8af3d3a299e8a5c6aab4ea1499de3b7
6
+ metadata.gz: '052286dd61178482ed0c794f0486d28d21914bb250a77b86ec408599a25d6b6198baa844f34678ec6094ad84f3d3ec37ff2a5761ec89286527d19676ed1b7ef5'
7
+ data.tar.gz: 51b7cbc86ff0c6c8595ffde40361713f41e206d0d73f63ef0bb8270454a3a62af16e5851a789c2c9c2367cb8ade92e36324d9acaca64bd1784cf81fe486ddf15
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "singleton"
4
4
  require "json"
5
+ require "socket"
5
6
 
6
7
  module PlainApm
7
8
  class Agent
@@ -30,6 +31,7 @@ module PlainApm
30
31
  event.merge!(
31
32
  "version" => PlainApm::VERSION,
32
33
  "collected_at" => Time.now.utc.to_f,
34
+ "hostname" => Socket.gethostname,
33
35
  "pid" => Process.pid,
34
36
  "thread_id" => Thread.current.object_id.to_s,
35
37
  )
@@ -7,19 +7,37 @@ module PlainApm
7
7
  attr_accessor :endpoint, :app_key, :enabled
8
8
 
9
9
  def initialize
10
- @enabled = enabled?
10
+ @enabled = enabled? && key_present?
11
11
  @endpoint = ENV["PLAIN_APM_ENDPOINT"] || DEFAULT_EVENT_ENDPOINT
12
- @app_key = ENV["PLAIN_APM_APP_KEY"] || warn("Missing PLAIN_APM_APP_KEY environment variable, plain_apm agent won't start.")
12
+ @app_key = ENV["PLAIN_APM_APP_KEY"]
13
+
14
+ if enabled? && !key_present?
15
+ warn("Missing PLAIN_APM_APP_KEY environment variable, plain_apm agent won't start.")
16
+ end
13
17
  end
14
18
 
15
19
  private
16
20
 
17
21
  def enabled?
18
- force = ENV["PLAIN_APM_ENABLED"] == "1"
19
- key_present = ENV["PLAIN_APM_APP_KEY"] != ""
20
- production = (ENV["RAILS_ENV"] || ENV["RACK_ENV"]) == "production"
22
+ (production? || force_enabled?) && !force_disabled?
23
+ end
24
+
25
+ def key_present?
26
+ ENV["PLAIN_APM_APP_KEY"] != ""
27
+ end
28
+
29
+ def production?
30
+ (ENV["RAILS_ENV"] || ENV["RACK_ENV"]) == "production"
31
+ end
32
+
33
+ # Allow to start in e.g. development.
34
+ def force_enabled?
35
+ ENV["PLAIN_APM_ENABLED"] == "1"
36
+ end
21
37
 
22
- key_present && (production || force)
38
+ # Do not instrument
39
+ def force_disabled?
40
+ ENV["PLAIN_APM_DISABLED"] == "1"
23
41
  end
24
42
  end
25
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlainApm
4
- VERSION = "0.2.8"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plain_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PlainAPM Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-05 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest