imprint 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/imprint/middleware.rb +1 -1
- data/lib/imprint/tracer.rb +3 -2
- data/lib/imprint/version.rb +1 -1
- data/test/unit/tracer_test.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4370ea757046369c30687047892243b4e434a66
|
4
|
+
data.tar.gz: 05e2f21ae874968110af3506ee8c5456d6cc9d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cebe40077377c417f246ab44b9daf5f5cc81bb023561d22c1b0199ae93505915ec3ef0fcbe778846f1a8b99475c10bcc3942f8024e3cfc1462801659c5b383c
|
7
|
+
data.tar.gz: d655f847cbc22d1cbf8f04687ad77dceb39d2b62c2859a49869fdcd0382f9efb70050a297743f612fab962b77af904dcc4352dd2f4f80ad29713f28d2b08e237
|
data/lib/imprint/middleware.rb
CHANGED
@@ -6,7 +6,7 @@ module Imprint
|
|
6
6
|
def self.set_request_trace_id(rack_env)
|
7
7
|
trace_id = rack_env[Imprint::Tracer::TRACER_HEADER] || rack_env[Imprint::Tracer::RAILS_REQUEST_ID]
|
8
8
|
if trace_id.nil?
|
9
|
-
trace_id =
|
9
|
+
trace_id = Imprint::Tracer.rand_trace_id
|
10
10
|
logger.info("trace_status=initiated trace_id=#{trace_id}")
|
11
11
|
end
|
12
12
|
Imprint::Tracer.set_trace_id(trace_id, rack_env)
|
data/lib/imprint/tracer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
1
3
|
module Imprint
|
2
4
|
class Tracer
|
3
5
|
TRACER_HEADER = 'HTTP_IMPRINTID'
|
@@ -5,7 +7,6 @@ module Imprint
|
|
5
7
|
RAILS_REQUEST_ID = "action_dispatch.request_id"
|
6
8
|
TRACE_ID_DEFAULT = "-1"
|
7
9
|
TRACER_TIMESTAMP = "TIMESTAMP"
|
8
|
-
TRACE_CHARS = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
|
9
10
|
|
10
11
|
def self.set_trace_id(id, rack_env = {})
|
11
12
|
Thread.current[TRACER_TIMESTAMP] = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%6N")
|
@@ -42,7 +43,7 @@ module Imprint
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def self.rand_trace_id
|
45
|
-
|
46
|
+
SecureRandom.uuid
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
data/lib/imprint/version.rb
CHANGED
data/test/unit/tracer_test.rb
CHANGED
@@ -39,8 +39,8 @@ class TracerTest < Minitest::Test
|
|
39
39
|
should "generate rand trace id" do
|
40
40
|
trace_id = Imprint::Tracer.rand_trace_id
|
41
41
|
refute_nil trace_id
|
42
|
-
assert_equal
|
43
|
-
assert trace_id.match(/[
|
42
|
+
assert_equal 36, trace_id.length
|
43
|
+
assert trace_id.match(/[a-f0-9\-]/)
|
44
44
|
end
|
45
45
|
|
46
46
|
protected
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|