meter 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meter/rails/middleware.rb +24 -0
- data/lib/meter/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df9faee203f427e1f2f643edefea1b5b3ff3ac30
|
4
|
+
data.tar.gz: dd45228ac7f2b8130aca58cd203ad6d3a91c768e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dcfd251841b8493a0c42a0a91d0f162a1e0d4adf0fbcd7e25eaf249e4ae4467b5aef4adf6ae310f337f4afe5f44b16ffeb222e396abe586aa9b16e1054bd36e
|
7
|
+
data.tar.gz: 0919517568a175fb40118da8f120568cdb012ae8197e55fa6d22f1709c16c5a22b58f06b4ac756dca31a33e50786b0b9955a551bc5b103ac82b5be7cddb7c3a1
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'useragent'
|
1
2
|
module Meter
|
2
3
|
module Rails
|
3
4
|
class Middleware
|
@@ -6,10 +7,33 @@ module Meter
|
|
6
7
|
end
|
7
8
|
|
8
9
|
def call(env)
|
10
|
+
request = Rack::Request.new(env)
|
11
|
+
Meter::MDC.data['request_id'] = env['action_dispatch.request_id']
|
12
|
+
Meter::MDC.data['pid'] = Process.pid
|
13
|
+
Meter::MDC.data['ip'] = request.ip.presence || '?'
|
14
|
+
|
15
|
+
store_user_agent_data(request)
|
16
|
+
store_geoip_data(request)
|
17
|
+
|
9
18
|
@app.call(env)
|
10
19
|
ensure
|
11
20
|
Meter::MDC.clear!
|
12
21
|
end
|
22
|
+
|
23
|
+
def store_user_agent_data(request)
|
24
|
+
user_agent = UserAgent.parse(request.user_agent)
|
25
|
+
Meter::MDC.tags['user_agent_name'] = user_agent.browser
|
26
|
+
Meter::MDC.tags['user_agent_version'] = "#{user_agent.browser}_#{user_agent.version}"
|
27
|
+
Meter::MDC.tags['user_agent_platform'] = user_agent.platform
|
28
|
+
Meter::MDC.data['user_agent'] = user_agent.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def store_geoip_data(request)
|
32
|
+
return unless defined?(Locality)
|
33
|
+
lookup = Locality::IP.new request.ip
|
34
|
+
Meter::MDC.tags['geoip_city'] = lookup.city_name
|
35
|
+
Meter::MDC.tags['geoip_country'] = lookup.country_name
|
36
|
+
end
|
13
37
|
end
|
14
38
|
end
|
15
39
|
end
|
data/lib/meter/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bukowskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: useragent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|