revolutionhealth-metrics 0.0.9 → 0.0.10
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.
- data/Rakefile +1 -1
 - data/lib/metrics.rb +11 -11
 - data/lib/metrics/{logger.rb → metric_logger.rb} +1 -1
 - metadata +3 -3
 
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/metrics.rb
    CHANGED
    
    | 
         @@ -12,7 +12,7 @@ if not defined?(METRICS_LOGGER) 
     | 
|
| 
       12 
12 
     | 
    
         
             
                METRICS_LOGGER = Logger.new(STDOUT)
         
     | 
| 
       13 
13 
     | 
    
         
             
              end
         
     | 
| 
       14 
14 
     | 
    
         
             
            end
         
     | 
| 
       15 
     | 
    
         
            -
            require 'metrics/ 
     | 
| 
      
 15 
     | 
    
         
            +
            require 'metrics/metric_logger'
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            module Metrics
         
     | 
| 
       18 
18 
     | 
    
         
             
              extend self
         
     | 
| 
         @@ -20,7 +20,7 @@ module Metrics 
     | 
|
| 
       20 
20 
     | 
    
         
             
              def collect_metrics(label = nil, *args)
         
     | 
| 
       21 
21 
     | 
    
         
             
                reset_metrics_id = false
         
     | 
| 
       22 
22 
     | 
    
         
             
                collector = nil
         
     | 
| 
       23 
     | 
    
         
            -
                if Metrics:: 
     | 
| 
      
 23 
     | 
    
         
            +
                if Metrics::MetricLogger.enabled?
         
     | 
| 
       24 
24 
     | 
    
         
             
                  @@_metrics_id ||= nil
         
     | 
| 
       25 
25 
     | 
    
         
             
                  if @@_metrics_id.nil?
         
     | 
| 
       26 
26 
     | 
    
         
             
                    reset_metrics_id = true
         
     | 
| 
         @@ -32,7 +32,7 @@ module Metrics 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                result = yield
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                log_metrics(collector.end_metric(label || metric_label), args) if Metrics:: 
     | 
| 
      
 35 
     | 
    
         
            +
                log_metrics(collector.end_metric(label || metric_label), args) if Metrics::MetricLogger.enabled?
         
     | 
| 
       36 
36 
     | 
    
         
             
                @@_metrics_id = nil if reset_metrics_id
         
     | 
| 
       37 
37 
     | 
    
         
             
                result
         
     | 
| 
       38 
38 
     | 
    
         
             
              end
         
     | 
| 
         @@ -52,7 +52,7 @@ module Metrics 
     | 
|
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
              private
         
     | 
| 
       54 
54 
     | 
    
         
             
              def begin_metric()
         
     | 
| 
       55 
     | 
    
         
            -
                if Metrics:: 
     | 
| 
      
 55 
     | 
    
         
            +
                if Metrics::MetricLogger.enabled?
         
     | 
| 
       56 
56 
     | 
    
         
             
                  @@_metrics_id = rand(99999)
         
     | 
| 
       57 
57 
     | 
    
         
             
                  @collector = Metrics::Collector.new
         
     | 
| 
       58 
58 
     | 
    
         
             
                  @collector.begin_metric() if @collector != nil
         
     | 
| 
         @@ -60,7 +60,7 @@ module Metrics 
     | 
|
| 
       60 
60 
     | 
    
         
             
              end
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
              def end_metric()
         
     | 
| 
       63 
     | 
    
         
            -
                if Metrics:: 
     | 
| 
      
 63 
     | 
    
         
            +
                if Metrics::MetricLogger.enabled? and @collector != nil
         
     | 
| 
       64 
64 
     | 
    
         
             
                  result = @collector.end_metric(metric_label) 
         
     | 
| 
       65 
65 
     | 
    
         
             
                  log_metrics(result)
         
     | 
| 
       66 
66 
     | 
    
         
             
                end
         
     | 
| 
         @@ -84,14 +84,14 @@ module Metrics 
     | 
|
| 
       84 
84 
     | 
    
         
             
                    output += delimiter + real_time(result).strip
         
     | 
| 
       85 
85 
     | 
    
         
             
                    output += delimiter + controller_args if respond_to?(:controller_name)
         
     | 
| 
       86 
86 
     | 
    
         
             
                    output += delimiter + "args=#{args[0].inspect}" if (args != nil) and (args.size > 0)
         
     | 
| 
       87 
     | 
    
         
            -
                    Metrics:: 
     | 
| 
      
 87 
     | 
    
         
            +
                    Metrics::MetricLogger.log(output)
         
     | 
| 
       88 
88 
     | 
    
         
             
                  else
         
     | 
| 
       89 
     | 
    
         
            -
                    Metrics:: 
     | 
| 
       90 
     | 
    
         
            -
                    Metrics:: 
     | 
| 
       91 
     | 
    
         
            -
                    Metrics:: 
     | 
| 
       92 
     | 
    
         
            -
                    Metrics:: 
     | 
| 
      
 89 
     | 
    
         
            +
                    Metrics::MetricLogger.log("#{METRICS_LABEL} #{result.label}")
         
     | 
| 
      
 90 
     | 
    
         
            +
                    Metrics::MetricLogger.log("#{METRICS_LABEL} Metrics Id=#{@@_metrics_id}") if Metrics::Config[:metrics_tracking_id]
         
     | 
| 
      
 91 
     | 
    
         
            +
                    Metrics::MetricLogger.log("#{METRICS_LABEL} args=#{args[0].inspect}") if (args != nil) and (args.size > 0)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    Metrics::MetricLogger.log("#{METRICS_LABEL} #{METRICS_CAPTION}")
         
     | 
| 
       93 
93 
     | 
    
         
             
                    result_str = result.to_s.delete("\n")
         
     | 
| 
       94 
     | 
    
         
            -
                    Metrics:: 
     | 
| 
      
 94 
     | 
    
         
            +
                    Metrics::MetricLogger.log("#{METRICS_LABEL} #{result_str}")
         
     | 
| 
       95 
95 
     | 
    
         
             
                  end
         
     | 
| 
       96 
96 
     | 
    
         
             
                end
         
     | 
| 
       97 
97 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: revolutionhealth-metrics
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Revolution Health
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: metrics 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2008- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2008-08-07 00:00:00 -07:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
         @@ -31,7 +31,7 @@ files: 
     | 
|
| 
       31 
31 
     | 
    
         
             
            - lib/metrics
         
     | 
| 
       32 
32 
     | 
    
         
             
            - lib/metrics/collector.rb
         
     | 
| 
       33 
33 
     | 
    
         
             
            - lib/metrics/config.rb
         
     | 
| 
       34 
     | 
    
         
            -
            - lib/metrics/ 
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/metrics/metric_logger.rb
         
     | 
| 
       35 
35 
     | 
    
         
             
            - lib/metrics.rb
         
     | 
| 
       36 
36 
     | 
    
         
             
            - lib/rails
         
     | 
| 
       37 
37 
     | 
    
         
             
            - lib/rails/activerecord_enhanced_metrics.rb
         
     |