gitlab-labkit 0.26.0 → 0.28.0
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 +4 -4
- data/.env.example.sh +7 -0
- data/.gitignore +1 -0
- data/README.md +14 -0
- data/gitlab-labkit.gemspec +1 -1
- data/lib/labkit/fips.rb +1 -0
- data/lib/labkit/tracing/jaeger_factory.rb +29 -5
- metadata +9 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7858d4755aa67f53d9ec232cfba39e8ee1245cea7e19a27a902e37fb3a80fda
|
|
4
|
+
data.tar.gz: f730b09600a2d855a1391ef7c10538cdaa757838cef2ca7daff2d1a0349be3e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 878574f3a7c26400e6ea7fcfbc2c4d16fc7f86cec1f9651dfad977d07a1bf203c6ef3ab843a3c996b3c0a6c17bbf5e847d23d7a2ab160c559f7617a24d9d9345
|
|
7
|
+
data.tar.gz: 4b7aea548f16103da6ac81aa8a9a195efdc952feaa13860415fc50ab028eb0e5ce76c4283d10b7e2f03807573ca2717de2386e9becdd0ec7031c18658495b27b
|
data/.env.example.sh
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export CI_PROJECT_ID=10947578
|
|
2
|
+
export CI_API_V4_URL="https://gitlab.com/api/v4"
|
|
3
|
+
export CI_PROJECT_URL="https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby"
|
|
4
|
+
# Don't keep secrets in plaintext files. Use a keyring or 1password to load
|
|
5
|
+
# it instead and export it as an env var.
|
|
6
|
+
token=$(load-your-token)
|
|
7
|
+
export GITLAB_TOKEN=$token
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -44,6 +44,20 @@ Note that LabKit-Ruby uses the [`rufo`](https://github.com/ruby-formatter/rufo)
|
|
|
44
44
|
|
|
45
45
|
Please also review the [development section of the LabKit (go) README](https://gitlab.com/gitlab-org/labkit#developing-labkit) for details of the LabKit architectural philosophy.
|
|
46
46
|
|
|
47
|
+
To work on some of the scripts we use for releasing a new version,
|
|
48
|
+
make sure to add a new `.env.sh`.
|
|
49
|
+
|
|
50
|
+
```console
|
|
51
|
+
cp .env.example.sh .env.sh`
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Inside `.env.sh`, add a personal acccess token for the `GITLAB_TOKEN`
|
|
55
|
+
environment variable. Next source the file:
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
. .env.sh
|
|
59
|
+
```
|
|
60
|
+
|
|
47
61
|
### Releasing a new version
|
|
48
62
|
|
|
49
63
|
Releasing a new version can be done by pushing a new tag, or creating
|
data/gitlab-labkit.gemspec
CHANGED
|
@@ -42,6 +42,6 @@ Gem::Specification.new do |spec|
|
|
|
42
42
|
spec.add_development_dependency "rspec", "~> 3.10.0"
|
|
43
43
|
spec.add_development_dependency "rspec-parameterized", "~> 0.4"
|
|
44
44
|
spec.add_development_dependency "rufo", "0.9.0"
|
|
45
|
-
spec.add_development_dependency "sidekiq", ">= 5.2"
|
|
45
|
+
spec.add_development_dependency "sidekiq", ">= 5.2", "< 7"
|
|
46
46
|
spec.add_development_dependency "webrick", "~> 1.7.0"
|
|
47
47
|
end
|
data/lib/labkit/fips.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "active_support"
|
|
4
|
+
require "active_support/core_ext"
|
|
5
|
+
|
|
3
6
|
require "jaeger/client"
|
|
4
7
|
|
|
5
8
|
module Labkit
|
|
@@ -22,10 +25,13 @@ module Labkit
|
|
|
22
25
|
# The service_name parameter from GITLAB_TRACING takes precedence over the application one
|
|
23
26
|
service_name = options[:service_name] if options[:service_name]
|
|
24
27
|
|
|
28
|
+
# parse reporter headers as necessary
|
|
29
|
+
headers = build_headers(options)
|
|
30
|
+
|
|
25
31
|
kwargs = {
|
|
26
32
|
service_name: service_name,
|
|
27
33
|
sampler: get_sampler(options[:sampler], options[:sampler_param]),
|
|
28
|
-
reporter: get_reporter(service_name, options[:http_endpoint], options[:udp_endpoint]),
|
|
34
|
+
reporter: get_reporter(service_name, options[:http_endpoint], options[:udp_endpoint], headers),
|
|
29
35
|
}.compact
|
|
30
36
|
|
|
31
37
|
extra_params = options.except(:sampler, :sampler_param, :http_endpoint, :udp_endpoint, :strict_parsing, :debug)
|
|
@@ -40,6 +46,24 @@ module Labkit
|
|
|
40
46
|
Jaeger::Client.build(**kwargs)
|
|
41
47
|
end
|
|
42
48
|
|
|
49
|
+
def self.build_headers(options)
|
|
50
|
+
return unless options&.key?(:http_endpoint)
|
|
51
|
+
|
|
52
|
+
http_endpoint = options[:http_endpoint]
|
|
53
|
+
parsed = URI.parse(http_endpoint)
|
|
54
|
+
|
|
55
|
+
headers = {}
|
|
56
|
+
# add basic auth header only when both user and password are setup correctly
|
|
57
|
+
user = parsed.user
|
|
58
|
+
password = parsed.password
|
|
59
|
+
if user.present? && password.present?
|
|
60
|
+
headers["Authorization"] = "Basic " + Base64.strict_encode64("#{user}:#{password}")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
return headers
|
|
64
|
+
end
|
|
65
|
+
private_class_method :build_headers
|
|
66
|
+
|
|
43
67
|
def self.get_sampler(sampler_type, sampler_param)
|
|
44
68
|
case sampler_type
|
|
45
69
|
when "probabilistic"
|
|
@@ -52,11 +76,11 @@ module Labkit
|
|
|
52
76
|
end
|
|
53
77
|
private_class_method :get_sampler
|
|
54
78
|
|
|
55
|
-
def self.get_reporter(service_name, http_endpoint, udp_endpoint)
|
|
79
|
+
def self.get_reporter(service_name, http_endpoint, udp_endpoint, headers)
|
|
56
80
|
encoder = Jaeger::Encoders::ThriftEncoder.new(service_name: service_name)
|
|
57
81
|
|
|
58
82
|
if http_endpoint.present?
|
|
59
|
-
sender = get_http_sender(encoder, http_endpoint)
|
|
83
|
+
sender = get_http_sender(encoder, http_endpoint, headers)
|
|
60
84
|
elsif udp_endpoint.present?
|
|
61
85
|
sender = get_udp_sender(encoder, udp_endpoint)
|
|
62
86
|
else
|
|
@@ -67,8 +91,8 @@ module Labkit
|
|
|
67
91
|
end
|
|
68
92
|
private_class_method :get_reporter
|
|
69
93
|
|
|
70
|
-
def self.get_http_sender(encoder, address)
|
|
71
|
-
Jaeger::HttpSender.new(url: address, encoder: encoder, logger: Logger.new(STDOUT))
|
|
94
|
+
def self.get_http_sender(encoder, address, headers)
|
|
95
|
+
Jaeger::HttpSender.new(url: address, headers: headers, encoder: encoder, logger: Logger.new(STDOUT))
|
|
72
96
|
end
|
|
73
97
|
private_class_method :get_http_sender
|
|
74
98
|
|
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.28.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: 2022-10-
|
|
11
|
+
date: 2022-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|
|
@@ -329,6 +329,9 @@ dependencies:
|
|
|
329
329
|
- - ">="
|
|
330
330
|
- !ruby/object:Gem::Version
|
|
331
331
|
version: '5.2'
|
|
332
|
+
- - "<"
|
|
333
|
+
- !ruby/object:Gem::Version
|
|
334
|
+
version: '7'
|
|
332
335
|
type: :development
|
|
333
336
|
prerelease: false
|
|
334
337
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -336,6 +339,9 @@ dependencies:
|
|
|
336
339
|
- - ">="
|
|
337
340
|
- !ruby/object:Gem::Version
|
|
338
341
|
version: '5.2'
|
|
342
|
+
- - "<"
|
|
343
|
+
- !ruby/object:Gem::Version
|
|
344
|
+
version: '7'
|
|
339
345
|
- !ruby/object:Gem::Dependency
|
|
340
346
|
name: webrick
|
|
341
347
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -357,6 +363,7 @@ executables: []
|
|
|
357
363
|
extensions: []
|
|
358
364
|
extra_rdoc_files: []
|
|
359
365
|
files:
|
|
366
|
+
- ".env.example.sh"
|
|
360
367
|
- ".gitignore"
|
|
361
368
|
- ".gitlab-ci.yml"
|
|
362
369
|
- ".gitlab/CODEOWNERS"
|