Skip to content

Commit e29c0cc

Browse files
fix: correct indentation and remove trailing whitespace
Both environment_id and inExperiment contexts are nested inside 'with add_spans' context and need consistent 4-space indentation. Also removed trailing whitespace from blank lines. Co-Authored-By: Vadim Korolik <[email protected]>
1 parent b25c8eb commit e29c0cc

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

spec/tracing_hook_spec.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -168,70 +168,70 @@
168168
expect(top.events[0].attributes['feature_flag.result.value']).to be_nil
169169
end
170170

171-
context 'with environment_id' do
172-
let(:options) { LaunchDarkly::Otel::TracingHookOptions.new({environment_id: 'test-env-123'}) }
173-
let(:hook) { LaunchDarkly::Otel::TracingHook.new(options) }
174-
let(:config) { LaunchDarkly::Config.new({data_source: td, hooks: [hook]}) }
175-
let(:client) { LaunchDarkly::LDClient.new('key', config) }
171+
context 'with environment_id' do
172+
let(:options) { LaunchDarkly::Otel::TracingHookOptions.new({environment_id: 'test-env-123'}) }
173+
let(:hook) { LaunchDarkly::Otel::TracingHook.new(options) }
174+
let(:config) { LaunchDarkly::Config.new({data_source: td, hooks: [hook]}) }
175+
let(:client) { LaunchDarkly::LDClient.new('key', config) }
176176

177-
it 'includes environment_id in event' do
178-
tracer.in_span('toplevel') do |span|
179-
result = client.variation('boolean', {key: 'org-key', kind: 'org'}, true)
177+
it 'includes environment_id in event' do
178+
tracer.in_span('toplevel') do |span|
179+
result = client.variation('boolean', {key: 'org-key', kind: 'org'}, true)
180+
end
181+
182+
spans = exporter.finished_spans
183+
event = spans[0].events[0]
184+
expect(event.attributes['feature_flag.set.id']).to eq 'test-env-123'
180185
end
181186

182-
spans = exporter.finished_spans
183-
event = spans[0].events[0]
184-
expect(event.attributes['feature_flag.set.id']).to eq 'test-env-123'
185-
end
187+
it 'does not include environment_id when invalid' do
188+
invalid_options = LaunchDarkly::Otel::TracingHookOptions.new({environment_id: ''})
189+
invalid_hook = LaunchDarkly::Otel::TracingHook.new(invalid_options)
190+
invalid_config = LaunchDarkly::Config.new({data_source: td, hooks: [invalid_hook]})
191+
invalid_client = LaunchDarkly::LDClient.new('key', invalid_config)
186192

187-
it 'does not include environment_id when invalid' do
188-
invalid_options = LaunchDarkly::Otel::TracingHookOptions.new({environment_id: ''})
189-
invalid_hook = LaunchDarkly::Otel::TracingHook.new(invalid_options)
190-
invalid_config = LaunchDarkly::Config.new({data_source: td, hooks: [invalid_hook]})
191-
invalid_client = LaunchDarkly::LDClient.new('key', invalid_config)
193+
tracer.in_span('toplevel') do |span|
194+
result = invalid_client.variation('boolean', {key: 'org-key', kind: 'org'}, true)
195+
end
192196

193-
tracer.in_span('toplevel') do |span|
194-
result = invalid_client.variation('boolean', {key: 'org-key', kind: 'org'}, true)
197+
spans = exporter.finished_spans
198+
event = spans[0].events[0]
199+
expect(event.attributes['feature_flag.set.id']).to be_nil
195200
end
196-
197-
spans = exporter.finished_spans
198-
event = spans[0].events[0]
199-
expect(event.attributes['feature_flag.set.id']).to be_nil
200201
end
201-
end
202202

203203
context 'with inExperiment and variationIndex' do
204204
let(:hook) { LaunchDarkly::Otel::TracingHook.new }
205205
let(:config) { LaunchDarkly::Config.new({data_source: td, hooks: [hook]}) }
206206
let(:client) { LaunchDarkly::LDClient.new('key', config) }
207-
207+
208208
it 'includes inExperiment when evaluation is part of experiment' do
209209
flag = LaunchDarkly::Integrations::TestData::FlagBuilder.new('experiment-flag')
210210
.variations(false, true)
211211
.fallthrough_variation(1)
212212
.on(true)
213213
td.update(flag)
214-
214+
215215
tracer.in_span('toplevel') do |span|
216216
result = client.variation('experiment-flag', {key: 'user-key', kind: 'user'}, false)
217217
end
218-
218+
219219
spans = exporter.finished_spans
220220
event = spans[0].events[0]
221221
expect(event.attributes.key?('feature_flag.result.reason.inExperiment')).to be false
222222
end
223-
223+
224224
it 'includes variationIndex when available' do
225225
flag = LaunchDarkly::Integrations::TestData::FlagBuilder.new('indexed-flag')
226226
.variations('value-0', 'value-1', 'value-2')
227227
.fallthrough_variation(1)
228228
.on(true)
229229
td.update(flag)
230-
230+
231231
tracer.in_span('toplevel') do |span|
232232
result = client.variation('indexed-flag', {key: 'user-key', kind: 'user'}, 'default')
233233
end
234-
234+
235235
spans = exporter.finished_spans
236236
event = spans[0].events[0]
237237
expect(event.attributes['feature_flag.result.variationIndex']).to eq 1

0 commit comments

Comments
 (0)