-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cf4996
commit 94ce420
Showing
7 changed files
with
140 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe Sentry::PropagationContext do | ||
before do | ||
perform_basic_setup | ||
end | ||
|
||
let(:scope) { Sentry.get_current_scope } | ||
let(:subject) { described_class.new(scope) } | ||
|
||
describe "#initialize" do | ||
it "generates correct attributes" do | ||
expect(subject.trace_id.length).to eq(32) | ||
expect(subject.span_id.length).to eq(16) | ||
expect(subject.parent_span_id).to be_nil | ||
end | ||
end | ||
|
||
describe "#get_trace_context" do | ||
it "generates correct trace context" do | ||
expect(subject.get_trace_context).to eq({ | ||
trace_id: subject.trace_id, | ||
span_id: subject.span_id, | ||
parent_span_id: subject.parent_span_id | ||
}) | ||
end | ||
end | ||
|
||
describe "#get_traceparent" do | ||
it "generates correct traceparent" do | ||
expect(subject.get_traceparent).to eq("#{subject.trace_id}-#{subject.span_id}") | ||
end | ||
end | ||
|
||
describe "#get_baggage" do | ||
before do | ||
perform_basic_setup do |config| | ||
config.environment = "test" | ||
config.release = "foobar" | ||
config.traces_sample_rate = 0.5 | ||
end | ||
end | ||
|
||
it "populates head baggage" do | ||
baggage = subject.get_baggage | ||
|
||
expect(baggage.mutable).to eq(false) | ||
expect(baggage.items).to eq({ | ||
"trace_id" => subject.trace_id, | ||
"sample_rate" => "0.5", | ||
"environment" => "test", | ||
"release" => "foobar", | ||
"public_key" => Sentry.configuration.dsn.public_key | ||
}) | ||
end | ||
end | ||
|
||
describe "#get_dynamic_sampling_context" do | ||
it "generates DSC from baggage" do | ||
expect(subject.get_dynamic_sampling_context).to eq(subject.get_baggage.dynamic_sampling_context) | ||
end | ||
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