red_cross 0.3.2 → 0.4.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: acda5b833b5b09b8c29945df15e1d5c4c711524a0dfc78fbced10b18569e30b0
4
- data.tar.gz: afcd29810a336615ddf8cb2e1496c42b060de83c6d9ce6973e7a9624cce0025a
3
+ metadata.gz: d3f75538bedc090b23bb8c82304dba86404a34bceae8ba58269b90e13400bc56
4
+ data.tar.gz: 6dd8fc9c3ea06241a916db21de4ef83bf861007e897fbae905dc82676b679a2a
5
5
  SHA512:
6
- metadata.gz: cd7416a76733bfd28f5e61a070d2da6f3111b6ed961b389c03483654d6513f67487a92a8637bf35f9daca72ddaa808143cdaf6998fa8c69f278f07581bad197b
7
- data.tar.gz: 33d39ced96ccf73d562d58b31339e61563c51f74c4d1654791bf52c68fcdf316926049abd8f87d9744ad736ca521edfe20ccf9559e45686b8c76b3cc34664225
6
+ metadata.gz: f5a06bdb85e40b365975a9e18fbf2b0fe148b9837cb85a3e1e7ee17ace82933f17e1fdb582d8f2d57b90f8035e386ebe9cf9488cde133069d6ddd8698a52e007
7
+ data.tar.gz: 182b2f7bd3cd9282e5da0fc53ec5fc9a9cfbcd8e67fa3984cc6bcb0faa237f0e2ae564a4c420ff05b43f2b4d2261f8d8d908662c43b766104708f0ef0c98d9dc
@@ -1,7 +1,7 @@
1
1
  module RedCross
2
2
  module Configuration
3
3
  class << self
4
- attr_accessor :influxdb_connect, :influxdb, :trackers, :default_tracker, :tracker, :logger
4
+ attr_accessor :influxdb_connect, :influxdb, :trackers, :default_tracker, :tracker, :logger, :application
5
5
 
6
6
  def configure
7
7
  yield self
@@ -0,0 +1,67 @@
1
+ #####################################################
2
+ # Application tracker
3
+ # send your metrics to influxdb using udp protocol
4
+ # Usage:
5
+ # RedCross.application_track(event: 'user.registration', properties: { referrer: 'facebook' } )
6
+ #####################################################
7
+ module RedCross
8
+ module Trackers
9
+ class ApplicationTracker < RedCross::Trackers::Base
10
+ attr_accessor :client
11
+
12
+ def initialize(database = 'application_metrics', host, port)
13
+ @client = InfluxDB::Client.new udp: {
14
+ host: host,
15
+ port: port,
16
+ },
17
+ discard_write_errors: true,
18
+ database: database
19
+ end
20
+
21
+ def track(attrs, additional_args = {})
22
+ monitor_request(attrs.merge(additional_args))
23
+ end
24
+
25
+ def identify(attrs, additional_args = {})
26
+ {}
27
+ end
28
+
29
+ def flush
30
+ {}
31
+ end
32
+
33
+ def group(attrs, additional_args = {})
34
+ {}
35
+ end
36
+
37
+ def monitor_request(attrs)
38
+ return if client.nil?
39
+ event = attrs[:event].to_s
40
+ properties = attrs[:properties] || {}
41
+ values = { count: 1 }.merge((properties.delete(:fields) || {}))
42
+ begin
43
+ client.write_point(event, { values: compact(values), tags: compact(properties) })
44
+ rescue => e
45
+ error_data = {
46
+ log_message: 'Failed to send monitor data to InfluxDB',
47
+ event_arguments: {
48
+ event: event,
49
+ tags: properties,
50
+ fields: values
51
+ },
52
+ exception: {
53
+ class: e.class.to_s,
54
+ message: e.message,
55
+ backtrace: e.backtrace
56
+ }
57
+ }
58
+ log :error, error_data
59
+ end
60
+ end
61
+
62
+ def compact(hash)
63
+ hash.respond_to?(:compact) ? hash.compact : hash.delete_if {|k,v| v == nil }
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module RedCross
2
- VERSION = '0.3.2'
2
+ VERSION = '0.4.0'
3
3
  end
data/lib/red_cross.rb CHANGED
@@ -9,6 +9,7 @@ require 'red_cross/trackers/base'
9
9
  require 'red_cross/trackers/segment_tracker'
10
10
  require 'red_cross/trackers/http_tracker'
11
11
  require 'red_cross/trackers/monitor_tracker'
12
+ require 'red_cross/trackers/application_tracker'
12
13
 
13
14
  module RedCross
14
15
  class << self
data/red_cross.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'analytics-ruby', '~> 2.2.2'
23
23
  spec.add_dependency 'typhoeus', '~> 1'
24
24
  spec.add_dependency 'resque', '>= 1.26'
25
- spec.add_dependency 'influxdb', '~> 0.5.0'
25
+ spec.add_dependency 'influxdb', '~> 0.6.0'
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 1.10'
28
28
  spec.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_cross
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronbarab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-27 00:00:00.000000000 Z
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: analytics-ruby
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.5.0
61
+ version: 0.6.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.5.0
68
+ version: 0.6.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +117,7 @@ files:
117
117
  - lib/red_cross/logging.rb
118
118
  - lib/red_cross/resque/plugins/red_cross_monitor.rb
119
119
  - lib/red_cross/resque/scheduler.rb
120
+ - lib/red_cross/trackers/application_tracker.rb
120
121
  - lib/red_cross/trackers/base.rb
121
122
  - lib/red_cross/trackers/http_tracker.rb
122
123
  - lib/red_cross/trackers/monitor_tracker.rb