Skip to content

Commit

Permalink
Reorder checks in test in case values are being cleared before checked (
Browse files Browse the repository at this point in the history
  • Loading branch information
estolfo authored Mar 30, 2020
1 parent 62386cd commit 471ece0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions spec/elastic_apm/instrumenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ module ElasticAPM

txn_set, = agent.metrics.get(:transaction).collect

brk_sets = agent.metrics.get(:breakdown).collect
txn_self_time = brk_sets.find do |d|
d.span&.fetch(:type) == 'app'
end

spn_self_time = brk_sets.find { |d| d.span&.fetch(:type) == 'a' }

# txn_set
expect(txn_set.samples[:'transaction.duration.sum.us']).to eq 300
expect(txn_set.samples[:'transaction.duration.count']).to eq 1
expect(txn_set.transaction).to match(
Expand All @@ -130,15 +138,7 @@ module ElasticAPM
type: 'custom'
)

# resets on collect
new_txn_set, = agent.metrics.get(:transaction).collect
expect(new_txn_set).to be nil

brk_sets = agent.metrics.get(:breakdown).collect

txn_self_time = brk_sets.find do |d|
d.span&.fetch(:type) == 'app'
end
# txn_self_time
expect(txn_self_time.samples[:'span.self_time.sum.us']).to eq 200
expect(txn_self_time.samples[:'span.self_time.count']).to eq 1
expect(txn_self_time.transaction).to match(
Expand All @@ -147,14 +147,18 @@ module ElasticAPM
)
expect(txn_self_time.span).to match(type: 'app', subtype: nil)

spn_self_time = brk_sets.find { |d| d.span&.fetch(:type) == 'a' }
#spn_self_time
expect(spn_self_time.samples[:'span.self_time.sum.us']).to eq 100
expect(spn_self_time.samples[:'span.self_time.count']).to eq 1
expect(spn_self_time.transaction).to match(
name: 'a_transaction',
type: 'custom'
)
expect(spn_self_time.span).to match(type: 'a', subtype: 'b')

# resets on collect
new_txn_set, = agent.metrics.get(:transaction).collect
expect(new_txn_set).to be nil
end

context 'with breakdown metrics disabled' do
Expand Down

0 comments on commit 471ece0

Please sign in to comment.