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 +4 -4
- data/lib/red_cross/configuration.rb +1 -1
- data/lib/red_cross/trackers/application_tracker.rb +67 -0
- data/lib/red_cross/version.rb +1 -1
- data/lib/red_cross.rb +1 -0
- data/red_cross.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3f75538bedc090b23bb8c82304dba86404a34bceae8ba58269b90e13400bc56
|
4
|
+
data.tar.gz: 6dd8fc9c3ea06241a916db21de4ef83bf861007e897fbae905dc82676b679a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/red_cross/version.rb
CHANGED
data/lib/red_cross.rb
CHANGED
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.
|
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.
|
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
|
+
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.
|
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.
|
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
|