|
154 | 154 |
|
155 | 155 | it 'starts a sentry transaction on otel root span' do
|
156 | 156 | expect(Sentry).to receive(:start_transaction).and_call_original
|
157 |
| - expect_any_instance_of(Sentry::Transaction).to receive(:set_initial_sample_decision).with( |
158 |
| - sampling_context: a_hash_including( |
159 |
| - otel: { |
160 |
| - attributes: root_span.attributes, |
161 |
| - resource: root_span.resource.attribute_enumerator.to_h, |
162 |
| - kind: root_span.kind, |
163 |
| - instrumentation_scope: { |
164 |
| - name: root_span.instrumentation_scope.name, |
165 |
| - version: root_span.instrumentation_scope.version |
166 |
| - } |
167 |
| - } |
168 |
| - ) |
169 |
| - ) |
170 | 157 |
|
171 | 158 | subject.on_start(root_span, empty_context)
|
172 | 159 |
|
|
189 | 176 | expect(transaction.baggage).to eq(nil)
|
190 | 177 | end
|
191 | 178 |
|
| 179 | + it 'includes otel context in custom sampling context' do |
| 180 | + sampling_context = nil |
| 181 | + Sentry.configuration.traces_sampler = lambda do |context| |
| 182 | + sampling_context = context |
| 183 | + 0.5 |
| 184 | + end |
| 185 | + |
| 186 | + subject.on_start(root_span, empty_context) |
| 187 | + |
| 188 | + expect(sampling_context).to include(:otel) |
| 189 | + otel_context = sampling_context[:otel] |
| 190 | + |
| 191 | + expect(otel_context).to include( |
| 192 | + kind: root_span.kind, |
| 193 | + instrumentation_scope: { |
| 194 | + name: root_span.instrumentation_scope.name, |
| 195 | + version: root_span.instrumentation_scope.version |
| 196 | + } |
| 197 | + ) |
| 198 | + |
| 199 | + expect(otel_context).to include(attributes: root_span.attributes) |
| 200 | + |
| 201 | + resource_attributes = root_span.resource.attribute_enumerator.to_h |
| 202 | + expect(otel_context).to include(resource: resource_attributes) |
| 203 | + end |
| 204 | + |
192 | 205 | context 'with started transaction' do
|
193 | 206 | let(:transaction) do
|
194 | 207 | subject.on_start(root_span, empty_context)
|
|
0 commit comments