ygrene_istio_tracing 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: 4304d7cab88e1472ec889d293642e36544f58436a9ae751c31767f7eb94d3dc6
4
- data.tar.gz: 5b4890393f3be80917aa2378bdf89050f81af074286b26b6357511f80e6b3d99
3
+ metadata.gz: 8361cbf8ec454a057b43180a718ba352d20a83658b36cd4efd92a24320ca853e
4
+ data.tar.gz: a052baad266616035ece1adbbb4d2c2fd6c4950c8cf379b47c92e4cbd7afef88
5
5
  SHA512:
6
- metadata.gz: dcd39895e34b7b57c85242207178240a12a29343ce00aa72558df6207e7659fcd314ff657d51e14ff57b24822d0a44c4304a280ce6b6d643cf5f878b8afedb2a
7
- data.tar.gz: 4995d8b2b80abc64bd398585222d161d4be5d4e71e2958a8978e4087218c1655d0ad2c16c6d0d2daac93c46f69581e4615080b672a8c8a471572d3662ed73d39
6
+ metadata.gz: dd6558df91d5c1c8f69ea7e71d9da9f01bd4dc5548f23cca204a15f6b86ab456d49ccf9abdffa90120161d7902c346da8e3e4d5cb9eb0722a2f293c12c182854
7
+ data.tar.gz: 5b4cc52c8e68f37e5c4e2bf00fe10f3b661df4c70eefaae4da92247d8b7afb68d2a37e947030c457028e305251d4c448c539c15409e64b52b482aa5aa0d182ac
data/Gemfile CHANGED
@@ -4,5 +4,5 @@ source 'https://rubygems.org'
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
- # Specify your gem's dependencies in istio.gemspec
7
+ # Specify your gem's dependencies in ygrene_istio_tracing.gemspec
8
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ygrene_istio_tracing (1.0.0)
4
+ ygrene_istio_tracing (1.0.2)
5
5
  typhoeus (~> 1.3.1)
6
6
 
7
7
  GEM
@@ -113,4 +113,4 @@ DEPENDENCIES
113
113
  ygrene_istio_tracing!
114
114
 
115
115
  BUNDLED WITH
116
- 1.16.6
116
+ 1.17.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ygrene_istio_tracing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Adams
@@ -125,16 +125,7 @@ files:
125
125
  - Rakefile
126
126
  - bin/console
127
127
  - bin/setup
128
- - istio.gemspec
129
- - lib/istio.rb
130
- - lib/istio/tracing.rb
131
- - lib/istio/tracing/context.rb
132
- - lib/istio/tracing/header.rb
133
- - lib/istio/tracing/http.rb
134
- - lib/istio/tracing/rack.rb
135
- - lib/istio/tracing/railtie.rb
136
- - lib/istio/version.rb
137
- homepage: https://github.com/ygrene/ygrene-istio-tracing
128
+ homepage: https://github.com/ygrene/ygrene_istio_tracing
138
129
  licenses: []
139
130
  metadata:
140
131
  allowed_push_host: https://rubygems.org
data/istio.gemspec DELETED
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'istio/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'ygrene_istio_tracing'
9
- spec.version = Istio::VERSION
10
- spec.authors = ['Austin Adams']
11
- spec.email = ['me@austbot.com']
12
-
13
- spec.summary = 'Ruby gem for Istio service mesh (https://istio.io/)'
14
- spec.description = 'This gem lets your rails app propagate http headers for distributed tracing with Istio.'
15
- spec.homepage = 'https://github.com/ygrene/ygrene-istio-tracing'
16
-
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- if spec.respond_to?(:metadata)
20
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
- else
22
- raise 'RubyGems 2.0 or newer is required to protect against ' \
23
- 'public gem pushes.'
24
- end
25
-
26
- # Specify which files should be added to the gem when it is released.
27
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
- end
31
- spec.bindir = 'exe'
32
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
- spec.require_paths = ['lib']
34
-
35
- spec.add_dependency 'typhoeus', '~> 1.3.1'
36
-
37
- spec.add_development_dependency 'bundler', '~> 1.16'
38
- spec.add_development_dependency 'rack'
39
- spec.add_development_dependency 'rake', '~> 10.0'
40
- spec.add_development_dependency 'rspec-rails'
41
-
42
- spec.add_development_dependency 'webmock', ['~>3.3.0']
43
- spec.add_development_dependency 'httparty', ['~>0.16.3']
44
- end
data/lib/istio.rb DELETED
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'istio/version'
4
- require 'istio/tracing'
data/lib/istio/tracing.rb DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'istio/tracing/context'
4
- require 'istio/tracing/header'
5
- require 'istio/tracing/http'
6
- require 'istio/tracing/rack'
7
-
8
- begin
9
- require 'rails/railtie'
10
- require 'istio/tracing/railtie'
11
- rescue LoadError
12
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Istio
4
- module Tracing
5
- class NotSetError < ::StandardError
6
- def initialize
7
- super('Context is not set for this thread')
8
- end
9
- end
10
-
11
- class Context
12
- VAR_NAME = :_istio_tracing_context_
13
-
14
- class << self
15
- def current
16
- Thread.current.thread_variable_get(VAR_NAME) || raise(NotSetError)
17
- end
18
-
19
- def with_given_context(ctx)
20
- Thread.current.thread_variable_set(VAR_NAME, ctx)
21
- yield
22
- ensure
23
- remove_current
24
- end
25
-
26
- def exists_current?
27
- !!Thread.current.thread_variable_get(VAR_NAME)
28
- end
29
-
30
- def build_current(headers)
31
- Thread.current.thread_variable_set(VAR_NAME, Context.new(headers))
32
- end
33
-
34
- def remove_current
35
- Thread.current.thread_variable_set(VAR_NAME, nil)
36
- end
37
- end
38
-
39
- attr_reader :headers
40
-
41
- def initialize(headers)
42
- @headers = headers
43
- end
44
- end
45
- end
46
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Istio
4
- module Tracing
5
- PROPAGATION_HEADERS = %w[
6
- x-request-id
7
- x-b3-traceid
8
- x-b3-spanid
9
- x-b3-parentspanid
10
- x-b3-sampled
11
- x-b3-flags
12
- x-ot-span-context
13
- X-REQUEST-ID
14
- X-B3-TRACEID
15
- X-B3-SPANID
16
- X-B3-PARENTSPANID
17
- X-B3-SAMPLED
18
- X-B3-FLAGS
19
- X-OT-SPAN-CONTEXT
20
- ].freeze
21
- end
22
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'net/http'
4
- require 'typhoeus'
5
-
6
- module Istio
7
- module NetHttp
8
- module ClassInterceptor
9
- def new(*options)
10
- o = super(*options)
11
- o
12
- end
13
- end
14
- module InstanceInterceptor
15
- def initialize(*options)
16
- super(*options)
17
- end
18
-
19
- def request(req, *args, &block)
20
- return super unless Context.exists_current?
21
-
22
- headers = Context.current.headers
23
- PROPAGATION_HEADERS.each do |h|
24
- req[h] = headers[h] if headers[h].present?
25
- end
26
- super
27
- end
28
- end
29
- end
30
- end
31
-
32
- ::Net::HTTP.singleton_class.prepend Istio::NetHttp::ClassInterceptor
33
- ::Net::HTTP.prepend Istio::NetHttp::InstanceInterceptor
34
-
35
- module Typhoeus
36
- Typhoeus.before do |req|
37
- return req unless Istio::Tracing::Context.exists_current?
38
-
39
- headers = Istio::Tracing::Context.current.headers
40
- Istio::Tracing::PROPAGATION_HEADERS.each do |h|
41
- req.options[:headers][h] = headers[h] unless headers[h]&.nil?
42
- end
43
- req
44
- end
45
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Istio
4
- module Tracing
5
- class RackMiddleware
6
-
7
- def initialize(app)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- Context.build_current(extract_http_headers(env))
13
- @app.call(env)
14
- ensure
15
- Context.remove_current
16
- end
17
-
18
- def extract_http_headers(env)
19
- env.select { |k, _v| PROPAGATION_HEADERS.include?(k.downcase) }
20
- end
21
- end
22
- end
23
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/railtie'
4
-
5
- module Istio
6
- module Tracing
7
- class Railtie < ::Rails::Railtie
8
- initializer 'istio.tracing.rack_middleware' do |app|
9
- puts 'Tracing Loaded'
10
- app.middleware.use(::Istio::Tracing::RackMiddleware)
11
- end
12
- end
13
- end
14
- end
data/lib/istio/version.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Istio
4
- VERSION = '1.0.1'
5
- end