bc-lightstep-ruby 1.5.1 → 1.5.2
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 +4 -0
- data/README.md +16 -0
- data/lib/bigcommerce/lightstep/rspec.rb +61 -0
- data/lib/bigcommerce/lightstep/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07ca22705b74ee7e761a63732cc416f45ca6a9db01a4a8c28615db57342301b1
|
4
|
+
data.tar.gz: e9856c08fc1bfacec3f57d8f9481d278c1133db5bbc199b14428782b4ad7b805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35096ce470d7bb32b059752e14612ebed5815e88b885c851e9e20c62e6bee0c41e512244b4ef462ccb2b5f7c07ef27d5509ed1c01697a1742ff46b1035c30770
|
7
|
+
data.tar.gz: 595f9ff72ee56b899b959cfbc5f7fb5e0b370db4fa40da7eaa7a673e48ca89068f04904685cff78c548d4d7aaee3590ea41cd8be2f82d605c1d0ce59a751826c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -86,6 +86,22 @@ re-enable this by setting the `redis_allow_root_spans` configuration option to `
|
|
86
86
|
It also excludes `ping` commands, and you can provide a custom list by setting the `redis_excluded_commands`
|
87
87
|
configuration option to an array of commands to exclude.
|
88
88
|
|
89
|
+
## RSpec
|
90
|
+
|
91
|
+
This library comes with a built-in matcher for testing span blocks. In your rspec config:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
require 'bigcommerce/lightstep/rspec'
|
95
|
+
```
|
96
|
+
|
97
|
+
Then, in a test:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
it 'should create a lightstep span' do
|
101
|
+
expect { my_code_here }.to create_a_lightstep_span(name: 'my-span-name', tags: { tag_one: 'value-here' })
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
89
105
|
## License
|
90
106
|
|
91
107
|
Copyright (c) 2018-present, BigCommerce Pty. Ltd. All rights reserved
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/expectations'
|
6
|
+
BC_LIGHTSTEP_RSPEC_NAMESPACE = RSpec
|
7
|
+
BC_LIGHTSTEP_RSPEC_RUNNER = RSpec
|
8
|
+
rescue LoadError # old rspec compat
|
9
|
+
require 'spec'
|
10
|
+
BC_LIGHTSTEP_RSPEC_NAMESPACE = Spec
|
11
|
+
BC_LIGHTSTEP_RSPEC_RUNNER = Spec::Runner
|
12
|
+
end
|
13
|
+
|
14
|
+
module Bigcommerce
|
15
|
+
module Lightstep
|
16
|
+
##
|
17
|
+
# RSpec helper for lightstep traces
|
18
|
+
#
|
19
|
+
module RspecHelpers
|
20
|
+
def lightstep_tracer
|
21
|
+
::Bigcommerce::Lightstep::Tracer.instance
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Usage:
|
29
|
+
# expect { my_code_here }.to create_a_lightstep_span(name: 'my-span-name', tags: { tag_one: 'value-here' })
|
30
|
+
#
|
31
|
+
BC_LIGHTSTEP_RSPEC_NAMESPACE::Matchers.define :create_a_lightstep_span do |opts|
|
32
|
+
match(notify_expectation_failures: true) do |proc|
|
33
|
+
span_name = opts.fetch(:name)
|
34
|
+
lightstep_span = ::LightStep::Span.new(
|
35
|
+
tracer: ::Bigcommerce::Lightstep::Tracer.instance,
|
36
|
+
operation_name: span_name,
|
37
|
+
max_log_records: 0,
|
38
|
+
start_micros: 0
|
39
|
+
)
|
40
|
+
expect(::Bigcommerce::Lightstep::Tracer.instance).to receive(:start_span).with(span_name).and_yield(lightstep_span).ordered
|
41
|
+
opts.fetch(:tags, {}).each do |key, value|
|
42
|
+
expect(lightstep_span).to receive(:set_tag).with(key.to_s, value)
|
43
|
+
end
|
44
|
+
proc.call
|
45
|
+
end
|
46
|
+
supports_block_expectations
|
47
|
+
end
|
48
|
+
|
49
|
+
BC_LIGHTSTEP_RSPEC_RUNNER.configure do |config|
|
50
|
+
config.include Bigcommerce::Lightstep::RspecHelpers
|
51
|
+
config.before do
|
52
|
+
# provide a dummy span for noop calls
|
53
|
+
lightstep_span = ::LightStep::Span.new(
|
54
|
+
tracer: ::Bigcommerce::Lightstep::Tracer.instance,
|
55
|
+
operation_name: 'default',
|
56
|
+
max_log_records: 0,
|
57
|
+
start_micros: 0
|
58
|
+
)
|
59
|
+
allow(::Bigcommerce::Lightstep::Tracer.instance).to receive(:start_span).and_yield(lightstep_span)
|
60
|
+
end
|
61
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bc-lightstep-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun McCormick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/bigcommerce/lightstep/rails_controller_instrumentation.rb
|
122
122
|
- lib/bigcommerce/lightstep/redis/tracer.rb
|
123
123
|
- lib/bigcommerce/lightstep/redis/wrapper.rb
|
124
|
+
- lib/bigcommerce/lightstep/rspec.rb
|
124
125
|
- lib/bigcommerce/lightstep/tracer.rb
|
125
126
|
- lib/bigcommerce/lightstep/transport.rb
|
126
127
|
- lib/bigcommerce/lightstep/transport_factory.rb
|