gitlab-labkit 0.18.0 → 0.20.0
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 -0
- data/Rakefile +2 -4
- data/gitlab-labkit.gemspec +2 -1
- data/lib/labkit/context.rb +3 -0
- data/lib/labkit/logging/sanitizer.rb +6 -0
- data/lib/labkit/tracing/rails/active_record/sql_instrumenter.rb +6 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ffa08defed93e465326a1f5db11670aacc69f3ebf2382d25459e4a9db3834b0
|
4
|
+
data.tar.gz: 81e98feb830a7247ecfb21b227d0b8f9bd632a1e7d3a90b95e4563d7a6ccfb6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8132d375526e57b7afa78b4edcc93268cfffbe9b3c1cf5db9de0f18e6f4c8ac22b934d7e2deed413caf13583e483a896584acd8e56fa1318a748fedf19cd98a0
|
7
|
+
data.tar.gz: 1f18c8ab7c8bacf6f8549d741c8ed500eebbca0e3fc4a47bed3fc5d239fc19eac9316c43ddfefdc771eb58ef11adc52e1a358ef46502bf4de0c7a6bca2e08207
|
data/.gitlab-ci.yml
CHANGED
data/Rakefile
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rufo"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
RSpec::Core::RakeTask.new(:spec)
|
9
|
-
end
|
6
|
+
require "rspec/core/rake_task"
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
8
|
|
11
9
|
require "rubocop/rake_task"
|
12
10
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
data/gitlab-labkit.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency "grpc", "~> 1.19" # Be sure to update the "grpc-tools" dev_depenency too
|
25
25
|
spec.add_runtime_dependency "jaeger-client", "~> 1.1"
|
26
26
|
spec.add_runtime_dependency "opentracing", "~> 0.4"
|
27
|
-
spec.add_runtime_dependency "
|
27
|
+
spec.add_runtime_dependency "pg_query", "~> 2.1"
|
28
28
|
spec.add_runtime_dependency "redis", ">3.0.0", "<5.0.0"
|
29
29
|
|
30
30
|
# Please maintain alphabetical order for dev dependencies
|
@@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency "rspec-parameterized", "~> 0.4"
|
43
43
|
spec.add_development_dependency "rufo", "0.9.0"
|
44
44
|
spec.add_development_dependency "sidekiq", "~> 5.2.7"
|
45
|
+
spec.add_development_dependency "webrick", "~> 1.7.0"
|
45
46
|
end
|
data/lib/labkit/context.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "securerandom"
|
4
|
+
|
3
5
|
require "active_support/core_ext/module/delegation"
|
4
6
|
require "active_support/core_ext/string/starts_ends_with"
|
7
|
+
require "active_support/core_ext/string/inflections"
|
5
8
|
|
6
9
|
module Labkit
|
7
10
|
# A context can be used to provide structured information on what resources
|
@@ -28,6 +28,12 @@ module Labkit
|
|
28
28
|
""
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.sql_fingerprint(normalized_sql)
|
32
|
+
PgQuery.parse(normalized_sql)&.fingerprint
|
33
|
+
rescue PgQuery::ParseError
|
34
|
+
""
|
35
|
+
end
|
36
|
+
|
31
37
|
# Ensures that URLS are sanitized to hide credentials
|
32
38
|
def self.mask_url(url)
|
33
39
|
url = url.to_s.strip
|
@@ -14,7 +14,11 @@ module Labkit
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def tags(payload)
|
17
|
-
|
17
|
+
if Labkit::Tracing.sampled? && payload[:sql]
|
18
|
+
sql = Labkit::Logging::Sanitizer.sanitize_sql(payload[:sql])
|
19
|
+
fingerprint = Labkit::Logging::Sanitizer.sql_fingerprint(sql)
|
20
|
+
end
|
21
|
+
|
18
22
|
{
|
19
23
|
"component" => COMPONENT_TAG,
|
20
24
|
"span.kind" => "client",
|
@@ -22,6 +26,7 @@ module Labkit
|
|
22
26
|
"db.connection_id" => payload[:connection_id],
|
23
27
|
"db.cached" => payload[:cached] || false,
|
24
28
|
"db.statement" => sql,
|
29
|
+
"db.statement_fingerprint" => fingerprint,
|
25
30
|
}
|
26
31
|
end
|
27
32
|
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.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Newdigate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -93,19 +93,19 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0.4'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
96
|
+
name: pg_query
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '2.
|
101
|
+
version: '2.1'
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: '2.
|
108
|
+
version: '2.1'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: redis
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -322,6 +322,20 @@ dependencies:
|
|
322
322
|
- - "~>"
|
323
323
|
- !ruby/object:Gem::Version
|
324
324
|
version: 5.2.7
|
325
|
+
- !ruby/object:Gem::Dependency
|
326
|
+
name: webrick
|
327
|
+
requirement: !ruby/object:Gem::Requirement
|
328
|
+
requirements:
|
329
|
+
- - "~>"
|
330
|
+
- !ruby/object:Gem::Version
|
331
|
+
version: 1.7.0
|
332
|
+
type: :development
|
333
|
+
prerelease: false
|
334
|
+
version_requirements: !ruby/object:Gem::Requirement
|
335
|
+
requirements:
|
336
|
+
- - "~>"
|
337
|
+
- !ruby/object:Gem::Version
|
338
|
+
version: 1.7.0
|
325
339
|
description:
|
326
340
|
email:
|
327
341
|
- andrew@gitlab.com
|