gitlab-labkit 0.13.2 → 0.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +4 -4
- data/gitlab-labkit.gemspec +1 -0
- data/lib/labkit/logging/sanitizer.rb +8 -0
- data/lib/labkit/tracing.rb +6 -0
- data/lib/labkit/tracing/rails/active_record/sql_instrumenter.rb +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7365b2f12b026f6b497d56738197b66e34014676dc284f568e97fad669cecef
|
4
|
+
data.tar.gz: ca9da033595aed9506edd7ba376a1bdd0b15c8e880a5e6b3edc52dc72b5a5570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87aaa07295098883563e77694fdb1401ba9e2e5fbc26569ee0b87f8ce7bc329f0d26b78df5d2e1c2e97b86f3d7ec3c41200406eb2b7028aba8ce8bdec4001ab4
|
7
|
+
data.tar.gz: 42f5dcee07855cd347b9585b96e44ac3e36e05a5fd634db55ddea02676b82df9c35e0ba3d6bbbbf0e4c6b4ec16906ff8a86f041db67d392485008d811f3d20b2
|
data/.gitlab-ci.yml
CHANGED
@@ -14,6 +14,10 @@ workflow:
|
|
14
14
|
- bundle install
|
15
15
|
- bundle exec rake verify build install
|
16
16
|
|
17
|
+
test:2.7:
|
18
|
+
image: ruby:2.7
|
19
|
+
<<: *test_definition
|
20
|
+
|
17
21
|
test:2.6:
|
18
22
|
image: ruby:2.6
|
19
23
|
<<: *test_definition
|
@@ -22,10 +26,6 @@ test:2.5:
|
|
22
26
|
image: ruby:2.5
|
23
27
|
<<: *test_definition
|
24
28
|
|
25
|
-
test:2.4:
|
26
|
-
image: ruby:2.4
|
27
|
-
<<: *test_definition
|
28
|
-
|
29
29
|
deploy:
|
30
30
|
stage: deploy
|
31
31
|
script:
|
data/gitlab-labkit.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_runtime_dependency "jaeger-client", "~> 1.1"
|
26
26
|
spec.add_runtime_dependency "opentracing", "~> 0.4"
|
27
27
|
spec.add_runtime_dependency "redis", ">3.0.0", "<5.0.0"
|
28
|
+
spec.add_runtime_dependency "gitlab-pg_query", "~> 1.3"
|
28
29
|
|
29
30
|
# Please maintain alphabetical order for dev dependencies
|
30
31
|
spec.add_development_dependency "grpc-tools", "~> 1.19"
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "pg_query"
|
4
|
+
|
3
5
|
module Labkit
|
4
6
|
module Logging
|
5
7
|
# Sanitizer provides log message sanitization, removing
|
@@ -22,6 +24,12 @@ module Labkit
|
|
22
24
|
content
|
23
25
|
end
|
24
26
|
|
27
|
+
def self.sanitize_sql(sql)
|
28
|
+
PgQuery.normalize(sql)
|
29
|
+
rescue PgQuery::ParseError
|
30
|
+
""
|
31
|
+
end
|
32
|
+
|
25
33
|
# Ensures that URLS are sanitized to hide credentials
|
26
34
|
def self.mask_url(url)
|
27
35
|
url = url.to_s.strip
|
data/lib/labkit/tracing.rb
CHANGED
@@ -28,6 +28,12 @@ module Labkit
|
|
28
28
|
ENV["GITLAB_TRACING_URL"]
|
29
29
|
end
|
30
30
|
|
31
|
+
# Check if the current request is being traced.
|
32
|
+
def self.sampled?
|
33
|
+
context = OpenTracing.active_span&.context
|
34
|
+
context && context.respond_to?(:sampled?) && context.sampled?
|
35
|
+
end
|
36
|
+
|
31
37
|
def self.stacktrace_operations
|
32
38
|
@stacktrace_operations ||= Set.new(ENV["GITLAB_TRACING_INCLUDE_STACKTRACE"].to_s.split(",").map(&:strip))
|
33
39
|
end
|
@@ -14,13 +14,14 @@ module Labkit
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def tags(payload)
|
17
|
+
sql = Labkit::Logging::Sanitizer.sanitize_sql(payload[:sql]) if Labkit::Tracing.sampled? && payload[:sql]
|
17
18
|
{
|
18
19
|
"component" => COMPONENT_TAG,
|
19
20
|
"span.kind" => "client",
|
20
21
|
"db.type" => "sql",
|
21
22
|
"db.connection_id" => payload[:connection_id],
|
22
23
|
"db.cached" => payload[:cached] || false,
|
23
|
-
"db.statement" =>
|
24
|
+
"db.statement" => sql,
|
24
25
|
}
|
25
26
|
end
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-labkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Newdigate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -112,6 +112,20 @@ dependencies:
|
|
112
112
|
- - "<"
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 5.0.0
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: gitlab-pg_query
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.3'
|
122
|
+
type: :runtime
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '1.3'
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: grpc-tools
|
117
131
|
requirement: !ruby/object:Gem::Requirement
|