gruf-lightstep 1.3.0 → 1.4.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/CHANGELOG.md +6 -1
- data/README.md +20 -14
- data/gruf-lightstep.gemspec +1 -1
- data/lib/gruf/lightstep/server_interceptor.rb +19 -7
- data/lib/gruf/lightstep/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f5ebd12fb3f139feb7dd42f1fe60a90fdc336cdde6dde41ce076a0808735384
|
4
|
+
data.tar.gz: 249367d93de69139cf8972be60dfb094c2636d7be040d8e15639812a16bd366e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05d6ff8c11f1fa20ae1842dc2bfe955baabff38eb4035ac307cbcde020bae0fee7057542e8b93f9aaed70fb064d648255f8d56a520214ddcfe94d5d996e38616
|
7
|
+
data.tar.gz: d08c23837bd69d3d8f133f8d3ea67d0a4c5a176a8d12a18afecc3daff15ac6c697f69eb50bc1e13e364531f5c5831275b205dc37c0273d021a86c4d9592c7f53
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@ Changelog for the gruf-lightstep gem.
|
|
2
2
|
|
3
3
|
### Pending Release
|
4
4
|
|
5
|
+
### 1.4.0
|
6
|
+
|
7
|
+
- Ensure `error` span tag is always set when an exception is raised
|
8
|
+
- Move from whitelist -> allowlist in server interceptor
|
9
|
+
|
5
10
|
### 1.3.0
|
6
11
|
|
7
12
|
- Bump Ruby requirement to 2.6+
|
@@ -26,7 +31,7 @@ Changelog for the gruf-lightstep gem.
|
|
26
31
|
|
27
32
|
- First OSS release
|
28
33
|
- Explicitly require bc-lightstep-ruby dependency
|
29
|
-
- Add option to
|
34
|
+
- Add option to allowlist request params to lightstep as span tags
|
30
35
|
|
31
36
|
### 1.1.1
|
32
37
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# gruf-lightstep - LightStep tracing for gruf
|
2
2
|
|
3
|
-
[](https://circleci.com/gh/bigcommerce/gruf-lightstep/tree/main) [](https://badge.fury.io/rb/gruf-lightstep) [](http://inch-ci.org/github/bigcommerce/gruf-lightstep)
|
4
4
|
|
5
5
|
Adds LightStep tracing support for [gruf](https://github.com/bigcommerce/gruf) 2.0.0+.
|
6
6
|
|
@@ -14,18 +14,24 @@ Then in an initializer or before use, after loading gruf:
|
|
14
14
|
|
15
15
|
```ruby
|
16
16
|
require 'gruf/lightstep'
|
17
|
-
|
18
|
-
Gruf::Lightstep.configure do |c|
|
19
|
-
c.component_name = 'myapp'
|
20
|
-
c.access_token = 'abcdefg'
|
21
|
-
c.host = 'my.lightstep.service.io'
|
22
|
-
c.port = 8080
|
23
|
-
c.verbosity = 1
|
24
|
-
end
|
25
|
-
Gruf::Lightstep.start
|
26
17
|
```
|
27
18
|
|
28
|
-
|
19
|
+
### Configuration
|
20
|
+
|
21
|
+
You can use the following ENV vars to configure lightstep:
|
22
|
+
|
23
|
+
| Name | Description |
|
24
|
+
| ---- | ---- |
|
25
|
+
|LIGHTSTEP_ACCESS_TOKEN|LightStep access token, if used in your satellites|
|
26
|
+
|LIGHTSTEP_COMPONENT_NAME|The name of your service|
|
27
|
+
|LIGHTSTEP_HOST|The host of your lightstep satellites|
|
28
|
+
|LIGHTSTEP_PORT|The port of your lightstep satellites|
|
29
|
+
|
30
|
+
See more configuration here: https://github.com/bigcommerce/bc-lightstep-ruby#environment-config
|
31
|
+
|
32
|
+
### Server Interceptors
|
33
|
+
|
34
|
+
In your gruf initializer:
|
29
35
|
|
30
36
|
```ruby
|
31
37
|
Gruf.configure do |c|
|
@@ -37,11 +43,11 @@ It comes with a few more options as well:
|
|
37
43
|
|
38
44
|
| Option | Description | Default |
|
39
45
|
| ------ | ----------- | ------- |
|
40
|
-
|
|
46
|
+
| allowlist | An array of parameter key names to log to lightstep. E.g. `[uuid kind]` | `[]` |
|
41
47
|
| ignore_methods | An array of method names to ignore from logging. E.g. `['namespace.health.check']` | `[]` |
|
42
48
|
|
43
|
-
It's important to maintain a safe
|
44
|
-
parameter sanitization on its own. We also recommend do not
|
49
|
+
It's important to maintain a safe allowlist should you decide to log parameters; gruf does no
|
50
|
+
parameter sanitization on its own. We also recommend do not allowlist parameters that may contain
|
45
51
|
very large values (such as binary or json data).
|
46
52
|
|
47
53
|
### Client Interceptors
|
data/gruf-lightstep.gemspec
CHANGED
@@ -43,6 +43,6 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency 'rubocop', '~> 0.82'
|
44
44
|
spec.add_development_dependency 'simplecov', '~> 0.15'
|
45
45
|
|
46
|
-
spec.add_runtime_dependency 'bc-lightstep-ruby', '~> 2.
|
46
|
+
spec.add_runtime_dependency 'bc-lightstep-ruby', '~> 2.2'
|
47
47
|
spec.add_runtime_dependency 'gruf', '>= 2.4', '< 3'
|
48
48
|
end
|
@@ -21,17 +21,16 @@ module Gruf
|
|
21
21
|
# Intercepts inbound calls to provide LightStep tracing
|
22
22
|
#
|
23
23
|
class ServerInterceptor < Gruf::Interceptors::ServerInterceptor
|
24
|
+
DEFAULT_ERROR_CLASSES = %w[GRPC::Unknown GRPC::Internal GRPC::DataLoss GRPC::FailedPrecondition GRPC::Unavailable GRPC::DeadlineExceeded GRPC::Cancelled].freeze
|
25
|
+
|
24
26
|
##
|
25
27
|
# Handle the gruf around hook and trace sampled requests
|
26
28
|
#
|
27
29
|
def call(&_block)
|
28
|
-
return yield if
|
30
|
+
return yield if ignore_methods.include?(request.method_name)
|
29
31
|
|
30
32
|
result = nil
|
31
|
-
|
32
|
-
whitelist = options.fetch(:whitelist, []).map(&:to_s).map(&:to_sym)
|
33
33
|
params = request_message_params
|
34
|
-
|
35
34
|
tracer = ::Bigcommerce::Lightstep::Tracer.instance
|
36
35
|
tracer.clear_active_span! # because we're always starting from the top on a gRPC boundary
|
37
36
|
tracer.start_span(request.method_name, context: request_method.headers.to_h) do |span|
|
@@ -40,14 +39,14 @@ module Gruf
|
|
40
39
|
span.set_tag('grpc.service', request.service_key)
|
41
40
|
span.set_tag('span.kind', 'server')
|
42
41
|
|
43
|
-
|
42
|
+
allowlist.each do |param|
|
44
43
|
span.set_tag(param.to_s, params[param]) if params.key?(param)
|
45
44
|
end
|
46
45
|
|
47
46
|
begin
|
48
47
|
result = yield
|
49
48
|
rescue StandardError => e
|
50
|
-
span.set_tag('error',
|
49
|
+
span.set_tag('error', error?(e))
|
51
50
|
span.set_tag('grpc.error', true)
|
52
51
|
span.set_tag('grpc.error_code', code_for(e))
|
53
52
|
span.set_tag('grpc.error_class', e.class)
|
@@ -59,6 +58,19 @@ module Gruf
|
|
59
58
|
|
60
59
|
private
|
61
60
|
|
61
|
+
##
|
62
|
+
# @return [Array<String>]
|
63
|
+
def ignore_methods
|
64
|
+
@ignore_methods ||= options.fetch(:ignore_methods, nil) || []
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# @return [Array<Symbol>]
|
69
|
+
#
|
70
|
+
def allowlist
|
71
|
+
@allowlist ||= (options.fetch(:allowlist, nil) || []).map(&:to_s).map(&:to_sym)
|
72
|
+
end
|
73
|
+
|
62
74
|
##
|
63
75
|
# @param [StandardError]
|
64
76
|
# @return [Number] that maps to one of the GRCP::Core::StatusCodes or Gruf::Lightstep.default_error_code
|
@@ -94,7 +106,7 @@ module Gruf
|
|
94
106
|
# @return [Array]
|
95
107
|
#
|
96
108
|
def error_classes
|
97
|
-
options.fetch(:error_classes,
|
109
|
+
@error_classes ||= (options.fetch(:error_classes, nil) || DEFAULT_ERROR_CLASSES)
|
98
110
|
end
|
99
111
|
end
|
100
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gruf-lightstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '2.
|
131
|
+
version: '2.2'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '2.
|
138
|
+
version: '2.2'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: gruf
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +178,7 @@ homepage: https://github.com/bigcommerce/gruf-lightstep
|
|
178
178
|
licenses:
|
179
179
|
- MIT
|
180
180
|
metadata: {}
|
181
|
-
post_install_message:
|
181
|
+
post_install_message:
|
182
182
|
rdoc_options: []
|
183
183
|
require_paths:
|
184
184
|
- lib
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubygems_version: 3.0.6
|
197
|
-
signing_key:
|
197
|
+
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Plugin for lightstep tracing for gruf
|
200
200
|
test_files: []
|