|
1 | 1 | /* eslint-disable max-lines */
|
2 | 2 | import { Primitive, Span as SpanInterface, SpanContext, Transaction } from '@sentry/types';
|
3 |
| -import { dropUndefinedKeys, timestampWithMs, uuid4 } from '@sentry/utils'; |
| 3 | +import { dropUndefinedKeys, logger, timestampWithMs, uuid4 } from '@sentry/utils'; |
4 | 4 |
|
5 | 5 | /**
|
6 | 6 | * Keeps track of finished spans for a given transaction
|
@@ -169,6 +169,18 @@ export class Span implements SpanInterface {
|
169 | 169 |
|
170 | 170 | childSpan.transaction = this.transaction;
|
171 | 171 |
|
| 172 | + if (__DEBUG_BUILD__ && childSpan.transaction) { |
| 173 | + const opStr = (spanContext && spanContext.op) || '< unknown op >'; |
| 174 | + const nameStr = childSpan.transaction.name || '< unknown name >'; |
| 175 | + const idStr = childSpan.transaction.spanId; |
| 176 | + |
| 177 | + // TODO: It would be safer to shove this in metadata (would need to move `metadata` from the `Transaction` class |
| 178 | + // to the `Span` class) |
| 179 | + childSpan.data.__log_message__ = `[Tracing] Starting ${opStr} span on transaction ${nameStr} (${idStr}).`; |
| 180 | + |
| 181 | + logger.log(childSpan.data.__log_message__); |
| 182 | + } |
| 183 | + |
172 | 184 | return childSpan;
|
173 | 185 | }
|
174 | 186 |
|
@@ -220,6 +232,17 @@ export class Span implements SpanInterface {
|
220 | 232 | * @inheritDoc
|
221 | 233 | */
|
222 | 234 | public finish(endTimestamp?: number): void {
|
| 235 | + if ( |
| 236 | + __DEBUG_BUILD__ && |
| 237 | + this.transaction && |
| 238 | + // We only want to log this for spans, not for transactions |
| 239 | + this.transaction.spanId !== this.spanId && |
| 240 | + this.data.__log_message__ |
| 241 | + ) { |
| 242 | + logger.log((this.data.__log_message__ as string).replace('Starting', 'Finishing')); |
| 243 | + delete this.data.__log_message__; |
| 244 | + } |
| 245 | + |
223 | 246 | this.endTimestamp = typeof endTimestamp === 'number' ? endTimestamp : timestampWithMs();
|
224 | 247 | }
|
225 | 248 |
|
|
0 commit comments