logjam_agent 0.12.3 → 0.13.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7e8279fe1b7c12c2263946e8ec20859336bdff1
4
- data.tar.gz: b07f94026782f2a936c4d25dfc7b6a1bbb676237
3
+ metadata.gz: 6729159239dcd10c5f56d76ae34d34f6798c102a
4
+ data.tar.gz: c55ddcfb030609b5018d8452509a285cdd5264c6
5
5
  SHA512:
6
- metadata.gz: e5d97646965e5668d9a4d3b825d680b0620066f53f13ea3b0bfa007cccd2d01560461a3bf5fa1791e1724d3a0a12b893ff477fe1d29c14c4d2776079e8b8e2ec
7
- data.tar.gz: c999c6cfd7290c1624fd524e222990c3c119365b11880e221f8377bc1fd7945de92e2152a2fe499d5c60400265729e42616b986c3df6e18c48b7d2506b7440a5
6
+ metadata.gz: f2d799502c05f8561e645e675e44d58dc6ef2e94c3513222d4afc3ce50a324854530cea6c2aefc8fb7574c588b3900bede0d4d03a3657ea183a709302854960e
7
+ data.tar.gz: abbf559d5e30c33cfd93599df6fb5aac070ddfec28abdf8fe1b8e08f05377a46335fc6e3fccabdfd2589a3b2d4a73fa6be420cd77d39ff98018672eae34c4ca0
data/README.md CHANGED
@@ -94,7 +94,7 @@ LogjamAgent.error_handler = lambda {|exception| ... }
94
94
 
95
95
  The MIT License
96
96
 
97
- Copyright (c) 2013, 2014 Stefan Kaes
97
+ Copyright (c) 2013 - 2015 Stefan Kaes
98
98
 
99
99
  Permission is hereby granted, free of charge, to any person obtaining a copy
100
100
  of this software and associated documentation files (the "Software"), to deal
@@ -27,9 +27,9 @@ module LogjamAgent
27
27
 
28
28
  def call_app(request, env)
29
29
  start_time = Time.now
30
- start_time_header = env['HTTP_X_STARTTIME'] # || "t=#{((Time.now - 50.0/1_000.0).to_f*1_000_000).to_i}"
30
+ start_time_header = env['HTTP_X_STARTTIME']
31
31
  if start_time_header && start_time_header =~ /\At=(\d+)\z/
32
- # accuracy?
32
+ # HTTP_X_STARTTIME is microseconds since the epoch (UTC)
33
33
  http_start_time = Time.at($1.to_f / 1_000_000.0)
34
34
  if (wait_time_ms = (start_time - http_start_time) * 1000) > 0
35
35
  start_time = http_start_time
@@ -75,9 +75,10 @@ module LogjamAgent
75
75
  logjam_request = LogjamAgent.request
76
76
  logjam_request.ignore! if ignored_asset_request?(path)
77
77
 
78
+ logjam_request.start_time = start_time
78
79
  logjam_fields = logjam_request.fields
79
80
  ip = LogjamAgent.ip_obfuscator(request.ip)
80
- logjam_fields.merge!(:started_at => start_time.iso8601, :ip => ip, :host => @hostname)
81
+ logjam_fields.merge!(:ip => ip, :host => @hostname)
81
82
  logjam_fields.merge!(extract_request_info(request))
82
83
 
83
84
  info "Started #{request.request_method} \"#{path}\" for #{ip} at #{start_time.to_default_s}" unless logjam_request.ignored?
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  module LogjamAgent
8
8
  class Request
9
- attr_reader :fields, :uuid
9
+ attr_reader :fields, :uuid, :start_time
10
10
 
11
11
  def initialize(app, env, initial_fields)
12
12
  @app = app
@@ -14,7 +14,11 @@ module LogjamAgent
14
14
  @forwarder = Forwarders.get(app, env)
15
15
  @lines = []
16
16
  @uuid = LogjamAgent.generate_uuid
17
- @fields = initial_fields.merge(:request_id => @uuid, :host => LogjamAgent.hostname, :process_id => Process.pid, :lines => @lines)
17
+ @fields = initial_fields.merge(:request_id => @uuid, :host => LogjamAgent.hostname,
18
+ :process_id => Process.pid, :lines => @lines)
19
+ if start_time = @fields.delete(:start_time)
20
+ self.start_time = start_time
21
+ end
18
22
  @mutex = Mutex.new
19
23
  @ignored = false
20
24
  @bytes_all_lines = 0
@@ -22,6 +26,12 @@ module LogjamAgent
22
26
  @max_line_length = LogjamAgent.max_line_length
23
27
  end
24
28
 
29
+ def start_time=(start_time)
30
+ @start_time = start_time
31
+ @fields[:started_at] = start_time.iso8601
32
+ @fields[:started_ms] = start_time.tv_sec * 1000 + start_time.tv_usec / 1000
33
+ end
34
+
25
35
  def ignore!
26
36
  @ignored = true
27
37
  end
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.12.3"
2
+ VERSION = "0.13.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake