bc-lightstep-ruby 1.5.1 → 1.5.2

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: 58c01708c8b34494f5d5f4ddc5a5cb8b6b581b9b1dd3f9f7297ea1e4e9abb1c2
4
- data.tar.gz: c19459c44193e5693691ce9c005c64cca1d8df2c2076147913d856fcf7fe17d5
3
+ metadata.gz: 07ca22705b74ee7e761a63732cc416f45ca6a9db01a4a8c28615db57342301b1
4
+ data.tar.gz: e9856c08fc1bfacec3f57d8f9481d278c1133db5bbc199b14428782b4ad7b805
5
5
  SHA512:
6
- metadata.gz: 0e7699221456ddab9993f18d304275df2e11331bba58f9fe09f98794d1747e39fc65bba412d253cc379788969961babd433facfad7646da3c86956290c3b677f
7
- data.tar.gz: 9a7507f2afd324b38ffed8c62a2fc71cff6cc12a8d5a56bcb880c2f0e478840a995c22fd095aca39979f1aa0b153e24ebaba7d6ce7448b29c4e593fa164d98a6
6
+ metadata.gz: 35096ce470d7bb32b059752e14612ebed5815e88b885c851e9e20c62e6bee0c41e512244b4ef462ccb2b5f7c07ef27d5509ed1c01697a1742ff46b1035c30770
7
+ data.tar.gz: 595f9ff72ee56b899b959cfbc5f7fb5e0b370db4fa40da7eaa7a673e48ca89068f04904685cff78c548d4d7aaee3590ea41cd8be2f82d605c1d0ce59a751826c
@@ -2,6 +2,10 @@ Changelog for the bc-lightstep-ruby gem.
2
2
 
3
3
  h3. Pending Release
4
4
 
5
+ h3. 1.5.2
6
+
7
+ - Add rspec helper for testing custom lightstep spans
8
+
5
9
  h3. 1.5.1
6
10
 
7
11
  - Add `hostname` preset for env var injection into spans
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
@@ -17,6 +17,6 @@
17
17
  #
18
18
  module Bigcommerce
19
19
  module Lightstep
20
- VERSION = '1.5.1'
20
+ VERSION = '1.5.2'
21
21
  end
22
22
  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.1
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-16 00:00:00.000000000 Z
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