gitlab-labkit 0.5.2 → 0.6.0
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: 657f2a528464eceb2b62cba36dba3dc262722a95ff2a351a71fb2162a7e5b949
|
4
|
+
data.tar.gz: 97d123fab3d434469eea2c948d26535decfd38ccad14f1b26aa441c26acef367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70ca817fd1f24705c50888f0e4ee22091424b6b2d05f12543bc8d0a350725b9052df28fa6ead8742d9ce5863d30d808955d574335b35939675aff61fa8e3815a
|
7
|
+
data.tar.gz: 5bab0eecef0233b1620f6da6ab609b6ff8af4ea96db6ed1803f924f55bae24f8f8e4de6497bd2131112d234ca5509baf75412b0bc64111207b01419274cd469c
|
data/lib/labkit/correlation.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Labkit
|
4
|
+
module Correlation
|
5
|
+
# The GRPC module contains functionality for instrumenting GRPC calls
|
6
|
+
module GRPC
|
7
|
+
autoload :GRPCCommon, "labkit/correlation/grpc/grpc_common"
|
8
|
+
autoload :ServerInterceptor, "labkit/correlation/grpc/server_interceptor"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Labkit
|
4
|
+
module Correlation
|
5
|
+
module GRPC
|
6
|
+
# This module is shared between the client and server interceptor middlewares.
|
7
|
+
# It is not part of the public API
|
8
|
+
module GRPCCommon
|
9
|
+
CORRELATION_METADATA_KEY = "x-gitlab-correlation-id"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Disable the UnusedMethodArgument linter, since we need to declare the kwargs
|
4
|
+
# in the methods, but we don't actually use them.
|
5
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
6
|
+
|
7
|
+
require "grpc"
|
8
|
+
|
9
|
+
module Labkit
|
10
|
+
module Correlation
|
11
|
+
module GRPC
|
12
|
+
# ServerInterceptor is a server-side GRPC interceptor
|
13
|
+
# for injecting GRPC calls with a correlation-id passed from
|
14
|
+
# a GRPC client to the GRPC Ruby Service
|
15
|
+
class ServerInterceptor < ::GRPC::ServerInterceptor
|
16
|
+
include Labkit::Correlation::GRPC::GRPCCommon
|
17
|
+
|
18
|
+
def request_response(request: nil, call: nil, method: nil)
|
19
|
+
wrap_with_correlation_id(call) do
|
20
|
+
yield
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def client_streamer(call: nil, method: nil)
|
25
|
+
wrap_with_correlation_id(call) do
|
26
|
+
yield
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def server_streamer(request: nil, call: nil, method: nil)
|
31
|
+
wrap_with_correlation_id(call) do
|
32
|
+
yield
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def bidi_streamer(requests: nil, call: nil, method: nil)
|
37
|
+
wrap_with_correlation_id(call) do
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def wrap_with_correlation_id(call, &block)
|
45
|
+
correlation_id = call.metadata[CORRELATION_METADATA_KEY]
|
46
|
+
correlation_id ||= Labkit::Correlation::CorrelationId.current_or_new_id
|
47
|
+
|
48
|
+
Labkit::Correlation::CorrelationId.use_id(correlation_id, &block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
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.6.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: 2019-08-
|
11
|
+
date: 2019-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -233,6 +233,9 @@ files:
|
|
233
233
|
- lib/gitlab-labkit.rb
|
234
234
|
- lib/labkit/correlation.rb
|
235
235
|
- lib/labkit/correlation/correlation_id.rb
|
236
|
+
- lib/labkit/correlation/grpc.rb
|
237
|
+
- lib/labkit/correlation/grpc/grpc_common.rb
|
238
|
+
- lib/labkit/correlation/grpc/server_interceptor.rb
|
236
239
|
- lib/labkit/logging.rb
|
237
240
|
- lib/labkit/logging/sanitizer.rb
|
238
241
|
- lib/labkit/tracing.rb
|