minato-stackdriver 0.1.0.pre.4 → 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: bb79a2a57e649891beb276d827106826788a56e0b437eea0836e07c4ef6e3738
4
- data.tar.gz: 939d3a399f3bf16e0a848afd4c547b09dedd150b213354dd5d33c796b8c9b7d6
3
+ metadata.gz: cd1d1350fad7bba843363307fc6ccbe853c646a4a78390fd0c9057a8b726d426
4
+ data.tar.gz: 80b2445e66eab767ea7856ffa4e224ef304cd8f379a476920990aea69eb249e7
5
5
  SHA512:
6
- metadata.gz: f1a8ab4c9c02d0f548c5b33a9cf01896d7b06328cb598ec51787e9b5417ab733909c19ae1ebf036f8bca08b5b613abfd0932c97c645112e9190da918e27a8571
7
- data.tar.gz: f48593fa0a0e53f4866064b2e8077305d861b67709779dc4270fb282a514e2ce0dd9099624c45b097851c9f8849e076110417ef23a1e36f2ee059ec15e8f3678
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minato
4
4
  module Stackdriver
5
- VERSION = "0.1.0-4"
5
+ VERSION = "0.1.0-5"
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
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
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.4
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