minato-trace 0.1.6.pre.5 → 0.1.6.pre.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4967547c4c025a758bab7ccf46a595d117ea1b2a089960cbd5807b2622452e6d
|
4
|
+
data.tar.gz: 0a6c050b09590ce43dded6e12cd3929188e21eb3ee7063644662ae49aebc21bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b90af4d09657878148ee11b7f4a1f80636e35354e60c2d09027386f7dae771dcee7b4e52996d72b6a681549524c887490be0ef99f2654b76f98b006a751a27bb
|
7
|
+
data.tar.gz: ecda535566853b1b7f2293688c0baf70a9a4861b8c0ff255fb7f7f6b0c7c55f9410487d97db396675af0423e0e34494289b3ffe6f5863b9137900aa33081945a
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Add support to [Google Cloud Trace](https://cloud.google.com/trace) to your Mina
|
|
5
5
|
Install this gem and your application will be abble to send trace information to Google Cloud Trace for any request. To configure distributed trace with other microservices see [Configuring distributed trace](#configuring-distributed-trace)
|
6
6
|
|
7
7
|
## Integration with Google Cloud Logging
|
8
|
-
For integration with [Google Cloud Logging](https://cloud.google.com/logging?hl=en) you have to install [minato-logger-rails](https://gitlab.com/ferreri/minato/minato-logger-rails) v0.1.
|
8
|
+
For integration with [Google Cloud Logging](https://cloud.google.com/logging?hl=en) you have to install [minato-logger-rails](https://gitlab.com/ferreri/minato/minato-logger-rails) v0.1.13+.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
Add this line to your application's Gemfile:
|
@@ -34,7 +34,9 @@ config/initializers/{service_name}.rb
|
|
34
34
|
end
|
35
35
|
```
|
36
36
|
## Disable trace
|
37
|
-
Trace is enabled by default. If you want to disable trace, set an environment variable `MINATO_TRACE_DISABLE=true` in your app.
|
37
|
+
Trace is enabled by default in remote environments. If you want to disable trace, set an environment variable `MINATO_TRACE_DISABLE=true` in your app.
|
38
|
+
|
39
|
+
`In local environment like angeplus-infra-local, the trace is disabled by default.`
|
38
40
|
|
39
41
|
## Changelog
|
40
42
|
Changelog information could be found [here](CHANGELOG.md).
|
@@ -19,7 +19,7 @@ module Minato
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def add_trace_context_header(env)
|
22
|
-
return unless Rails.env.production? && Minato::Trace.enabled?
|
22
|
+
return unless (Rails.env.production? && Minato::Trace.enabled?) || current_cloud_trace.nil?
|
23
23
|
|
24
24
|
env.request_headers.merge!({ "#{TRACE_HEADER_KEY}": "#{current_cloud_trace.trace.trace_id};o=1" })
|
25
25
|
end
|
@@ -22,10 +22,10 @@ module Minato
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def current_cloud_trace
|
25
|
-
@current_cloud_trace ||=
|
25
|
+
@current_cloud_trace ||= current_cloud_trace_from_google_cloud
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def current_cloud_trace_from_google_cloud
|
29
29
|
_trace_client = Google::Cloud::Trace.new
|
30
30
|
Google::Cloud::Trace.get
|
31
31
|
end
|
data/lib/minato/trace/version.rb
CHANGED
data/lib/minato/trace.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "minato/trace/version"
|
4
|
-
require "minato/trace/railtie"
|
5
4
|
require "minato/trace/middleware"
|
6
|
-
|
5
|
+
|
6
|
+
if defined? Rails::Railtie
|
7
|
+
require "google/cloud/trace/rails"
|
8
|
+
require "minato/trace/railtie"
|
9
|
+
end
|
7
10
|
|
8
11
|
module Minato
|
9
12
|
module Trace
|
@@ -12,7 +15,7 @@ module Minato
|
|
12
15
|
def self.init(app)
|
13
16
|
if Minato::Trace.enabled?
|
14
17
|
Minato::Trace.configure_loggging(app)
|
15
|
-
Minato::Trace.configure_trace
|
18
|
+
Minato::Trace.configure_trace
|
16
19
|
end
|
17
20
|
|
18
21
|
app
|
@@ -22,18 +25,25 @@ module Minato
|
|
22
25
|
ENV["MINATO_TRACE_DISABLED"] != "true"
|
23
26
|
end
|
24
27
|
|
25
|
-
def self.configure_trace
|
26
|
-
|
27
|
-
config.
|
28
|
-
config.
|
29
|
-
config.minato_logger.trace_logs = Minato::Trace::Middleware::IntegrateWithCloudLogging.new
|
28
|
+
def self.configure_trace
|
29
|
+
Google::Cloud.configure do |config|
|
30
|
+
config.use_trace = true
|
31
|
+
config.trace.sampler = Google::Cloud::Trace::TimeSampler.new(path_blacklist: BLACKLIST_PATHS.dup)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def self.configure_loggging(app)
|
36
|
+
Google::Cloud.configure do |config|
|
37
|
+
config.use_logging = false
|
38
|
+
end
|
39
|
+
|
34
40
|
app.configure do
|
35
|
-
config.
|
41
|
+
config.minato_logger.middleware.use Minato::Trace::Middleware::IntegrateWithCloudLogging
|
36
42
|
end
|
37
43
|
end
|
44
|
+
|
45
|
+
def self.skip_trace?(trace)
|
46
|
+
BLACKLIST_PATHS.any? { |path| trace.name.start_with?(path) }
|
47
|
+
end
|
38
48
|
end
|
39
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minato-trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.6.pre.
|
4
|
+
version: 0.1.6.pre.7
|
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-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-trace
|