socialHub_httpUtility 1.0.14 → 1.1.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: 6e56d8cd8858a9bc32a6b582a8127c7ef0d8f8ed
4
- data.tar.gz: e5de0207e53a646183c8fc8e120b70eff11244b0
3
+ metadata.gz: 9ef6da29ee0c5450a8c2ab834ceb3949f20fb4e2
4
+ data.tar.gz: d7c71938ecc20cb225e1a9ab8a11d0cf64cba752
5
5
  SHA512:
6
- metadata.gz: b265a3f2c9b3798938afd4cc2096a0afedeaaf6b9204f5505d0828fc2f254548ac0e89e02d010233416ce06649f29ec8cb177f52bf5c099291084f406103a7e7
7
- data.tar.gz: 265be8f57288f9c614d8c83a49bec665135a5ef7ae753342a21eeef58e65eeea1e60bcce01f88ecf14bbc290608fabc570930fb57c43de8fc7b7731b97127e2b
6
+ metadata.gz: 862b2f9a341fbd4130b217fb51e9ac8e041c5acee04d3ac32bc160d1c1c761f2316c29f4892ef8d3a7dca548408cf1d9af0d68eebc77ed7f2f84893af465e554
7
+ data.tar.gz: 563aba79fd091c636a3c5c636a695904655be82a937f8854e8969cdbb20f851ea697675855d625bdccc73a20014e777e382fe9f6b7655e0223d3c52fa900edd2
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 10.0"
7
7
  gem "rspec", "~> 3.0"
8
+ gem 'rack', '~> 2.0'
9
+ gem 'zipkin-tracer', '~> 0.27.0'
@@ -1,8 +1,19 @@
1
1
  require "socialHub_httpUtility/version"
2
- require "socialHub_httpUtility/configuration"
2
+ require 'zipkin-tracer'
3
3
 
4
4
  module SocialHubHttpUtility
5
5
 
6
+ class Configuration
7
+
8
+ attr_accessor :service_name, :service_port
9
+
10
+ def initialize
11
+ @service_name = nil
12
+ @service_port = nil
13
+ end
14
+
15
+ end
16
+
6
17
  class << self
7
18
  attr_accessor :configuration
8
19
  end
@@ -19,7 +30,7 @@ module SocialHubHttpUtility
19
30
  yield(configuration)
20
31
  end
21
32
 
22
- def self.get_http_request(domain, path, params, headers, distination_service)
33
+ def self.get_http_request(domain, path, params, headers, distination_service, trace_id)
23
34
 
24
35
  if(configuration.service_name)
25
36
  puts "service name from the ruby gem is"
@@ -42,6 +53,14 @@ module SocialHubHttpUtility
42
53
  if(!headers.key?("request-id"))
43
54
  request.add_field("request-id",SecureRandom.uuid)
44
55
  end
56
+
57
+ ZipkinTracer::TraceContainer.with_trace_id(trace_id) do
58
+ b3_headers.each do |method, header|
59
+ request.add_field(header, trace_id.send(method).to_s)
60
+ end
61
+ end
62
+
63
+
45
64
  log_params = {
46
65
  "service_name" => params["service_name"],
47
66
  "http_url" => url,
@@ -96,8 +115,20 @@ module SocialHubHttpUtility
96
115
 
97
116
  return response
98
117
  end
118
+
119
+ # Zipkin Related Header Values
120
+ def b3_headers
121
+ {
122
+ trace_id: 'X-B3-TraceId',
123
+ parent_id: 'X-B3-ParentSpanId',
124
+ span_id: 'X-B3-SpanId',
125
+ sampled: 'X-B3-Sampled',
126
+ flags: 'X-B3-Flags'
127
+ }
128
+ end
129
+ # End of Zipking header values
99
130
 
100
- def self.post_http_request(domain, path, params, headers, distination_service)
131
+ def self.post_http_request(domain, path, params, headers, distination_service, trace_id)
101
132
 
102
133
  if(configuration.service_name)
103
134
  puts "service name from the ruby gem is"
@@ -114,6 +145,13 @@ module SocialHubHttpUtility
114
145
  if(!headers.key?("request-id"))
115
146
  headers["request-id"] = SecureRandom.uuid
116
147
  end
148
+
149
+ ZipkinTracer::TraceContainer.with_trace_id(trace_id) do
150
+ b3_headers.each do |method, header|
151
+ headers[header] = trace_id.send(method).to_s
152
+ end
153
+ end
154
+
117
155
  log_params = {
118
156
  "service_name" => params["service_name"],
119
157
  "http_url" => url,
@@ -1,4 +1,4 @@
1
1
  module SocialHubHttpUtility
2
- VERSION = "1.0.14"
2
+ VERSION = "1.1.0"
3
3
  end
4
4
 
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
20
20
 
21
- spec.files = ["lib/socialHub_httpUtility" , "lib/socialHub_httpUtility/configuration"]
22
21
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
22
  f.match(%r{^(test|spec|features)/})
24
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socialHub_httpUtility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AbdAllah Elabasery
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler