-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from solarwindscloud/NH-52516
NH-52516: return false if span is not sampled or invalid
- Loading branch information
Showing
10 changed files
with
94 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) 2023 SolarWinds, LLC. | ||
# All rights reserved. | ||
|
||
require 'minitest_helper' | ||
require './lib/solarwinds_apm/support/txn_name_manager' | ||
require './lib/solarwinds_apm/opentelemetry' | ||
require './lib/solarwinds_apm/otel_config' | ||
require './lib/solarwinds_apm/constants' | ||
require './lib/solarwinds_apm/api' | ||
|
||
describe 'SolarWinds Set Transaction Name Test' do | ||
before do | ||
@span = create_span | ||
SolarWindsAPM::OTelConfig.initialize | ||
@processors = ::OpenTelemetry.tracer_provider.instance_variable_get(:@span_processors) | ||
@solarwinds_processor = @processors.last | ||
@solarwinds_processor.txn_manager.del("77cb6ccc522d3106114dd6ecbb70036a-31e175128efc4018") | ||
end | ||
|
||
after do | ||
@span.context.trace_flags.instance_variable_set(:@flags, 0) | ||
end | ||
|
||
it 'calculate_transaction_names_with_unsampled_span' do | ||
@solarwinds_processor.on_start(@span, ::OpenTelemetry::Context.current) | ||
result = SolarWindsAPM::API.set_transaction_name('abcdf') | ||
_(result).must_equal false | ||
_(@solarwinds_processor.txn_manager.get("77cb6ccc522d3106114dd6ecbb70036a-31e175128efc4018")).must_equal "abcdf" | ||
end | ||
|
||
it 'calculate_transaction_names_with_empty_transaction_name' do | ||
@solarwinds_processor.on_start(@span, ::OpenTelemetry::Context.current) | ||
result = SolarWindsAPM::API.set_transaction_name('') | ||
_(result).must_equal false | ||
assert_nil(@solarwinds_processor.txn_manager.get("77cb6ccc522d3106114dd6ecbb70036a-31e175128efc4018")) | ||
end | ||
|
||
it 'calculate_transaction_names_with_sampled_span' do | ||
@span.context.trace_flags.instance_variable_set(:@flags, 1) | ||
@solarwinds_processor.on_start(@span, ::OpenTelemetry::Context.current) | ||
result = SolarWindsAPM::API.set_transaction_name('abcdf') | ||
_(result).must_equal true | ||
_(@solarwinds_processor.txn_manager.get("77cb6ccc522d3106114dd6ecbb70036a-31e175128efc4018")).must_equal "abcdf" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters