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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5459901d3dc0b3f89bf973e477c409230a60e611
4
- data.tar.gz: c460d8059c154b9079098e4d7da14a4c0df002c8
3
+ metadata.gz: f4370ea757046369c30687047892243b4e434a66
4
+ data.tar.gz: 05e2f21ae874968110af3506ee8c5456d6cc9d51
5
5
  SHA512:
6
- metadata.gz: ed8cadb75ca9549197cb8407bb4d566ded40c6136859d03e1a6d17a8ae17f47f5a426c66aab55876ba7e92d5beaf9ffb7e24474bc68535a374c101e521c7139a
7
- data.tar.gz: a473cc378d6b1870c836481540d2fabba7e3bfb84241a6de6d8648ac39c034759e09f99c74085052ddf4ae8d8fc58ce5b21841c1a5dc7c2bfb4844d4ba95415c
6
+ metadata.gz: 2cebe40077377c417f246ab44b9daf5f5cc81bb023561d22c1b0199ae93505915ec3ef0fcbe778846f1a8b99475c10bcc3942f8024e3cfc1462801659c5b383c
7
+ data.tar.gz: d655f847cbc22d1cbf8f04687ad77dceb39d2b62c2859a49869fdcd0382f9efb70050a297743f612fab962b77af904dcc4352dd2f4f80ad29713f28d2b08e237
@@ -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 = "#{Time.now.to_i}_#{Imprint::Tracer.rand_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)
@@ -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
- (0...6).map { TRACE_CHARS[rand(TRACE_CHARS.length)] }.join
46
+ SecureRandom.uuid
46
47
  end
47
48
  end
48
49
  end
@@ -1,3 +1,3 @@
1
1
  module Imprint
2
- VERSION = "1.4.3"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -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 6, trace_id.length
43
- assert trace_id.match(/[A-Za-z]/)
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.3
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-05-07 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler