minato-stackdriver 0.1.0.pre.3 → 0.1.0.pre.5

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
  SHA256:
3
- metadata.gz: 35e5b9fc732eef1bea6278908dc6a579aff7c970da01a13ec1b69759db729e7f
4
- data.tar.gz: 675285811e330721194acb1057c72caa4fe3df5a370272d092f80a23cc59b4a0
3
+ metadata.gz: cd1d1350fad7bba843363307fc6ccbe853c646a4a78390fd0c9057a8b726d426
4
+ data.tar.gz: 80b2445e66eab767ea7856ffa4e224ef304cd8f379a476920990aea69eb249e7
5
5
  SHA512:
6
- metadata.gz: 51cbf2d0a086d0fc0723fdbdd5f7e96a7bc4de7a6ade987312ee2130b62e1b994a5af38be9483ebd18050fb91c0c14cc9f839b09024fa7dbb23a1acf9c5b13c4
7
- data.tar.gz: 3012d935e6a0b75c6f886dbc989c4aad12151bb3bd72d0b2231618a306a408e6ac0a074b28e7646cf54262ad67b3e4ed970a70248270b9caf190b5d4694b26b6
6
+ metadata.gz: 6ad75ec9e669e9488cf0592a273d26b118874fe4b1d3a271a132fe5188cb1246fae1e8ddfe26f3acd989a0c0aa97debe4462eb627aa4aef18ba547d10ace970d
7
+ data.tar.gz: 5db6c1139eeca524038c72d1f304444ddd823ce6312f5ff91a616608ce4f1a35859d3f75ebfb04c526176dd0ba52c7eb91554fe544cf9bb20837c124612d018e
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Minato
4
+ module Stackdriver
5
+ module Middleware
6
+ class DistributedTraceContext
7
+ TRACE_HEADER_KEY = "X-Cloud-Trace-Context"
8
+
9
+ def initialize(app)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+ add_trace_context_header(env)
15
+
16
+ @app.call(env)
17
+ end
18
+
19
+ private
20
+
21
+ def add_trace_context_header(env)
22
+ return unless Rails.env.production?
23
+
24
+ env.request_headers.merge!({ "#{TRACE_HEADER_KEY}": "#{current_cloud_trace.trace.trace_id};o=1" })
25
+ end
26
+
27
+ def current_cloud_trace
28
+ @current_cloud_trace ||= current_trace_from_google_cloud
29
+ end
30
+
31
+ def current_trace_from_google_cloud
32
+ _trace_client = Google::Cloud::Trace.new
33
+ Google::Cloud::Trace.get
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "minato/stackdriver/middleware/distributed_trace_context"
4
+
5
+ module Minato
6
+ module Stackdriver
7
+ module Middleware
8
+ end
9
+ end
10
+ end
@@ -3,8 +3,9 @@
3
3
  module Minato
4
4
  module Stackdriver
5
5
  class Railtie < ::Rails::Railtie
6
- config.before_configuration do |app|
7
- Minato::Stackdriver.init(app)
6
+ initializer "minato_stackdriver_setup",
7
+ before: "load_environment_config" do
8
+ Minato::Stackdriver.init
8
9
  end
9
10
  end
10
11
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minato
4
4
  module Stackdriver
5
- VERSION = "0.1.0-3"
5
+ VERSION = "0.1.0-5"
6
6
  end
7
7
  end
@@ -2,16 +2,19 @@
2
2
 
3
3
  require "minato/stackdriver/version"
4
4
  require "minato/stackdriver/railtie"
5
+ require "minato/stackdriver/middleware"
5
6
  require "stackdriver"
6
7
 
7
8
  module Minato
8
9
  module Stackdriver
9
10
  BLACKLIST_PATHS = ["/health/alive", "/health/ready"].freeze
10
11
 
11
- def self.init(app)
12
- app.config.google_cloud.use_logging = false
13
- app.config.google_cloud.use_trace = true
14
- app.config.google_cloud.trace_sampler = Google::Cloud::Trace::TimeSampler.new(path_blacklist: BLACKLIST_PATHS.dup)
12
+ def self.init
13
+ Google::Cloud.configure do |config|
14
+ config.use_logging = false
15
+ config.use_trace = true
16
+ config.trace.sampler = Google::Cloud::Trace::TimeSampler.new(path_blacklist: BLACKLIST_PATHS.dup)
17
+ end
15
18
  end
16
19
  end
17
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minato-stackdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.3
4
+ version: 0.1.0.pre.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ferreri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-25 00:00:00.000000000 Z
11
+ date: 2024-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -49,6 +49,8 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - lib/minato/stackdriver.rb
52
+ - lib/minato/stackdriver/middleware.rb
53
+ - lib/minato/stackdriver/middleware/distributed_trace_context.rb
52
54
  - lib/minato/stackdriver/railtie.rb
53
55
  - lib/minato/stackdriver/version.rb
54
56
  - lib/tasks/minato/stackdriver_tasks.rake