|
1 | 1 | /* eslint-disable max-lines */ |
2 | | -import { Span as SpanInterface, SpanContext } from '@sentry/types'; |
| 2 | +import { Span as SpanInterface, SpanContext, Transaction } from '@sentry/types'; |
3 | 3 | import { dropUndefinedKeys, timestampWithMs, uuid4 } from '@sentry/utils'; |
4 | 4 |
|
5 | 5 | import { SpanStatus } from './spanstatus'; |
@@ -99,6 +99,11 @@ export class Span implements SpanInterface, SpanContext { |
99 | 99 | */ |
100 | 100 | public spanRecorder?: SpanRecorder; |
101 | 101 |
|
| 102 | + /** |
| 103 | + * @inheritDoc |
| 104 | + */ |
| 105 | + public transaction?: Transaction; |
| 106 | + |
102 | 107 | /** |
103 | 108 | * You should never call the constructor manually, always use `hub.startSpan()`. |
104 | 109 | * @internal |
@@ -161,19 +166,21 @@ export class Span implements SpanInterface, SpanContext { |
161 | 166 | public startChild( |
162 | 167 | spanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'spanId' | 'sampled' | 'traceId' | 'parentSpanId'>>, |
163 | 168 | ): Span { |
164 | | - const span = new Span({ |
| 169 | + const childSpan = new Span({ |
165 | 170 | ...spanContext, |
166 | 171 | parentSpanId: this.spanId, |
167 | 172 | sampled: this.sampled, |
168 | 173 | traceId: this.traceId, |
169 | 174 | }); |
170 | 175 |
|
171 | | - span.spanRecorder = this.spanRecorder; |
172 | | - if (span.spanRecorder) { |
173 | | - span.spanRecorder.add(span); |
| 176 | + childSpan.spanRecorder = this.spanRecorder; |
| 177 | + if (childSpan.spanRecorder) { |
| 178 | + childSpan.spanRecorder.add(childSpan); |
174 | 179 | } |
175 | 180 |
|
176 | | - return span; |
| 181 | + childSpan.transaction = this.transaction; |
| 182 | + |
| 183 | + return childSpan; |
177 | 184 | } |
178 | 185 |
|
179 | 186 | /** |
|
0 commit comments