Class: NewrelicTag
- Inherits:
-
Object
- Object
- NewrelicTag
- Defined in:
- lib/newrelic_tag.rb,
lib/newrelic_tag/version.rb
Defined Under Namespace
Modules: Version
Class Attribute Summary collapse
-
.allowed_environments ⇒ Object
Returns the value of attribute allowed_environments.
-
.aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
-
.aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
-
.instance_id_url ⇒ Object
Returns the value of attribute instance_id_url.
-
.tag ⇒ Object
Returns the value of attribute tag.
-
.value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
- .compute ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .enabled? ⇒ Boolean
- .instance ⇒ Object
- .reset! ⇒ Object
Instance Method Summary collapse
Class Attribute Details
.allowed_environments ⇒ Object
Returns the value of attribute allowed_environments.
14 15 16 |
# File 'lib/newrelic_tag.rb', line 14 def allowed_environments @allowed_environments end |
.aws_access_key_id ⇒ Object
Returns the value of attribute aws_access_key_id.
11 12 13 |
# File 'lib/newrelic_tag.rb', line 11 def aws_access_key_id @aws_access_key_id end |
.aws_secret_access_key ⇒ Object
Returns the value of attribute aws_secret_access_key.
12 13 14 |
# File 'lib/newrelic_tag.rb', line 12 def aws_secret_access_key @aws_secret_access_key end |
.instance_id_url ⇒ Object
Returns the value of attribute instance_id_url.
13 14 15 |
# File 'lib/newrelic_tag.rb', line 13 def instance_id_url @instance_id_url end |
.tag ⇒ Object
Returns the value of attribute tag.
9 10 11 |
# File 'lib/newrelic_tag.rb', line 9 def tag @tag end |
.value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/newrelic_tag.rb', line 10 def value @value end |
Class Method Details
.compute ⇒ Object
39 40 41 42 43 44 |
# File 'lib/newrelic_tag.rb', line 39 def compute @compute ||= Fog::Compute.new( :provider => 'AWS', :aws_access_key_id => aws_access_key_id, :aws_secret_access_key => aws_secret_access_key) end |
.configure {|_self| ... } ⇒ Object
31 32 33 |
# File 'lib/newrelic_tag.rb', line 31 def configure yield(self) if block_given? end |
.enabled? ⇒ Boolean
35 36 37 |
# File 'lib/newrelic_tag.rb', line 35 def enabled? instance.enabled? end |
.instance ⇒ Object
23 24 25 |
# File 'lib/newrelic_tag.rb', line 23 def instance @instance ||= self.new end |
.reset! ⇒ Object
27 28 29 |
# File 'lib/newrelic_tag.rb', line 27 def reset! @instance = nil end |
Instance Method Details
#enabled? ⇒ Boolean
47 48 49 50 51 52 53 54 |
# File 'lib/newrelic_tag.rb', line 47 def enabled? @enabled = begin environment_allowed? && newrelic_allowed? && has_tag? rescue => e puts "Error reading NewRelic tag: #{e}" false end end |
#environment_allowed? ⇒ Boolean
61 62 63 |
# File 'lib/newrelic_tag.rb', line 61 def environment_allowed? self.class.allowed_environments.include?(environment) end |
#has_tag? ⇒ Boolean
56 57 58 59 |
# File 'lib/newrelic_tag.rb', line 56 def has_tag? !self.class.compute..all('key' => self.class.tag, 'value' => self.class.value, 'resource-id' => instance_id).empty? end |