newrelic_logger_extension 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 47b4bac116ae08eddbd49abfb642f504bd857322
4
- data.tar.gz: 690e8dcec9f206835fcbd13938ded8587074f048
3
+ metadata.gz: f4e26b56101bee5849dff6a54f64172fb8d7d677
4
+ data.tar.gz: e3af46970e4142fc551dabb0977446091be63d62
5
5
  SHA512:
6
- metadata.gz: 5801bded28b2c026fc4895f5e6fffcc450a0821192b8b22bd81617739c571cc606afdb562268a48f41ad27a8cbf719473bf4664d53bed97cd2192f3444eb2da6
7
- data.tar.gz: 0d8c898bceee4ce13b6ccce55095a3a3370f98c9fd63d885c27b5a6d226264ec67d868ef90d10347686cf52c01b963e885570cdf5a9443dbd160c67300f225f9
6
+ metadata.gz: 72c673790d42cfa86ae9dda835750bfb95d3bed6366b804ac2048ec4cec666d19b88c74f0ca19348c17bbf4b138005f02d913c8a40f54d706d436f6e05841f17
7
+ data.tar.gz: 14c6128a692e93c35c181643db3d13e3e7bea2a65543a35fc597eb975ce552471b2db6962ca1d4955d58326f0f799575035d7239d00b0754fe1c13282c2bff0a
@@ -1,4 +1,5 @@
1
1
  require 'newrelic_logger_extension/version'
2
+ require 'binding_of_caller'
2
3
  # require 'newrelic_rpm'
3
4
 
4
5
  module NewrelicLoggerExtension
@@ -12,7 +13,7 @@ module NewrelicLoggerExtension
12
13
  logger.singleton_class.class_eval do
13
14
  define_method("#{level}_with_newrelic") do |*args|
14
15
  send("#{level}_without_newrelic", *args)
15
- log_to_newrelic("#{level.capitalize}", caller_locations(1).first)
16
+ log_to_newrelic level.capitalize, binding.of_caller(1).eval('self')
16
17
  end
17
18
 
18
19
  alias_method "#{level}_without_newrelic", level
@@ -21,14 +22,9 @@ module NewrelicLoggerExtension
21
22
  end
22
23
  def self.inject_shared_methods(logger)
23
24
  logger.singleton_class.class_eval do
24
- def log_to_newrelic(category, kaller)
25
- ::NewRelic::Agent.increment_metric("Custom/#{category}/#{format_caller(kaller)}")
26
- end
27
-
28
- def format_caller(kaller)
29
- (kaller.path.split(/\/|\./)[-4..-2] << kaller.lineno).join(SEPARATOR)
30
- rescue
31
- File.basename(kaller.path)
25
+ def log_to_newrelic(category, caller_class)
26
+ caller_class = caller_class.class unless caller_class.class.to_s == 'Class'
27
+ ::NewRelic::Agent.increment_metric("Custom/#{category}/#{caller_class}")
32
28
  end
33
29
  end
34
30
  end
@@ -1,3 +1,3 @@
1
1
  module NewrelicLoggerExtension
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -22,6 +22,7 @@ EOS
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_dependency 'newrelic_rpm', '>= 3.9'
25
+ spec.add_dependency 'binding_of_caller', '>= 0.7'
25
26
 
26
27
  spec.add_development_dependency 'bundler', '~> 1.6'
27
28
  spec.add_development_dependency 'rake'
@@ -28,7 +28,7 @@ describe NewrelicLoggerExtension do
28
28
  it 'should call correctly set the custom metric nameing' do
29
29
  expect(::NewRelic::Agent)
30
30
  .to receive(:increment_metric)
31
- .with('Custom/Warn/spec__lib__newrelic_logger_extension_spec__32')
32
- logger.warn('test warning') # this is line 32
31
+ .with('Custom/Warn/RSpec::ExampleGroups::NewrelicLoggerExtension')
32
+ logger.warn('test warning')
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_logger_extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Eger
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: binding_of_caller
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement