grpc_access_logging_interceptor 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile.lock +3 -3
- data/lib/grpc_access_logging_interceptor/server_interceptor.rb +25 -3
- data/lib/grpc_access_logging_interceptor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2ac41e62dbedd2f938035e7a60fa98fd4a04a70fb3850ff3b5c9e8363b11518
|
4
|
+
data.tar.gz: 993cc5f03380eb3740150b2150c07f3ca59287b50b35088b5fca864153e5f706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24960dc060169a1b8584ba2be8299ba509f65076619d1b253f50a883f99a20e54164ac165cf984c015de1bbb62860a7dca667b41b9cd0909f13fd03da23762e3
|
7
|
+
data.tar.gz: 5f8362c76c97e95f3361b634be72d225027288ca08cab488e7650819d9259f2a08083a2a8000ed3a0d1169d4ecfedda6f164476d6bf9c652027a5fbb559091db
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grpc_access_logging_interceptor (0.0.
|
4
|
+
grpc_access_logging_interceptor (0.0.4)
|
5
5
|
grpc
|
6
6
|
|
7
7
|
GEM
|
@@ -9,10 +9,10 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
coderay (1.1.2)
|
11
11
|
diff-lcs (1.3)
|
12
|
-
google-protobuf (3.
|
12
|
+
google-protobuf (3.11.1)
|
13
13
|
googleapis-common-protos-types (1.0.4)
|
14
14
|
google-protobuf (~> 3.0)
|
15
|
-
grpc (1.
|
15
|
+
grpc (1.25.0)
|
16
16
|
google-protobuf (~> 3.8)
|
17
17
|
googleapis-common-protos-types (~> 1.0)
|
18
18
|
method_source (0.9.2)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "base64"
|
1
2
|
require "grpc"
|
2
3
|
require "grpc_access_logging_interceptor/default_logger"
|
3
4
|
|
@@ -22,16 +23,18 @@ module GrpcAccessLoggingInterceptor
|
|
22
23
|
# @param [Method] method
|
23
24
|
#
|
24
25
|
def request_response(request:, call:, method:)
|
26
|
+
data = {} # Initialize at first to avoid nil
|
27
|
+
|
25
28
|
accessed_at = Time.now
|
26
29
|
|
27
|
-
data
|
30
|
+
data.merge!({
|
28
31
|
remote_addr: remote_addr(call.peer),
|
29
32
|
accessed_at: accessed_at.utc.strftime('%Y-%m-%d %H:%M:%S.%6N'),
|
30
33
|
params: filter(request.to_h).to_json,
|
31
34
|
user_agent: call.metadata[USER_AGENT_KEY],
|
32
35
|
grpc_method: grpc_method(method),
|
33
|
-
grpc_metadata: call.metadata
|
34
|
-
}
|
36
|
+
grpc_metadata: jsonize(call.metadata),
|
37
|
+
})
|
35
38
|
data.merge!(custom_data(request: request, call: call, method: method))
|
36
39
|
|
37
40
|
yield
|
@@ -69,6 +72,25 @@ module GrpcAccessLoggingInterceptor
|
|
69
72
|
"/#{method.owner.service_name}/#{camelize(method.name.to_s)}"
|
70
73
|
end
|
71
74
|
|
75
|
+
# @param [Hash] metadata
|
76
|
+
# @return [String]
|
77
|
+
def jsonize(metadata)
|
78
|
+
h = {}
|
79
|
+
metadata.each do |k, v|
|
80
|
+
if v.is_a?(String) && v.encoding == Encoding::ASCII_8BIT
|
81
|
+
begin
|
82
|
+
h[k] = v.encode(Encoding::UTF_8)
|
83
|
+
rescue Encoding::UndefinedConversionError
|
84
|
+
# If the value is binary, encode with Base64
|
85
|
+
h[k] = Base64.strict_encode64(v)
|
86
|
+
end
|
87
|
+
else
|
88
|
+
h[k] = v
|
89
|
+
end
|
90
|
+
end
|
91
|
+
h.to_json
|
92
|
+
end
|
93
|
+
|
72
94
|
# @param [String] term
|
73
95
|
# @return [String]
|
74
96
|
def camelize(term)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc_access_logging_interceptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nao Minami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|