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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd1d1350fad7bba843363307fc6ccbe853c646a4a78390fd0c9057a8b726d426
|
4
|
+
data.tar.gz: 80b2445e66eab767ea7856ffa4e224ef304cd8f379a476920990aea69eb249e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/minato/stackdriver.rb
CHANGED
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
|
+
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-
|
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
|