|
1 | 1 | /* eslint-disable max-lines */
|
2 |
| -import { getCurrentHub } from '@sentry/hub'; |
3 |
| -import { Baggage, Hub, Primitive, Span as SpanInterface, SpanContext, Transaction } from '@sentry/types'; |
4 |
| -import { |
5 |
| - createBaggage, |
6 |
| - dropUndefinedKeys, |
7 |
| - isBaggageMutable, |
8 |
| - isSentryBaggageEmpty, |
9 |
| - setBaggageImmutable, |
10 |
| - setBaggageValue, |
11 |
| - timestampWithMs, |
12 |
| - uuid4, |
13 |
| -} from '@sentry/utils'; |
| 2 | +import { Primitive, Span as SpanInterface, SpanContext, Transaction } from '@sentry/types'; |
| 3 | +import { dropUndefinedKeys, timestampWithMs, uuid4 } from '@sentry/utils'; |
14 | 4 |
|
15 | 5 | /**
|
16 | 6 | * Keeps track of finished spans for a given transaction
|
@@ -308,29 +298,6 @@ export class Span implements SpanInterface {
|
308 | 298 | });
|
309 | 299 | }
|
310 | 300 |
|
311 |
| - /** |
312 |
| - * @inheritdoc |
313 |
| - */ |
314 |
| - public getBaggage(): Baggage { |
315 |
| - const existingBaggage = this.transaction && this.transaction.metadata.baggage; |
316 |
| - |
317 |
| - // Only add Sentry baggage items to baggage, if baggage does not exist yet or it is still |
318 |
| - // empty and mutable |
319 |
| - // TODO: we might want to ditch the isSentryBaggageEmpty condition because it prevents |
320 |
| - // custom sentry-values in DSC (added by users in the future) |
321 |
| - const finalBaggage = |
322 |
| - !existingBaggage || (isBaggageMutable(existingBaggage) && isSentryBaggageEmpty(existingBaggage)) |
323 |
| - ? this._populateBaggageWithSentryValues(existingBaggage) |
324 |
| - : existingBaggage; |
325 |
| - |
326 |
| - // In case, we poulated the DSC, we have update the stored one on the transaction. |
327 |
| - if (existingBaggage !== finalBaggage && this.transaction) { |
328 |
| - this.transaction.metadata.baggage = finalBaggage; |
329 |
| - } |
330 |
| - |
331 |
| - return finalBaggage; |
332 |
| - } |
333 |
| - |
334 | 301 | /**
|
335 | 302 | * @inheritDoc
|
336 | 303 | */
|
@@ -360,65 +327,6 @@ export class Span implements SpanInterface {
|
360 | 327 | trace_id: this.traceId,
|
361 | 328 | });
|
362 | 329 | }
|
363 |
| - |
364 |
| - /** |
365 |
| - * Collects and adds data to the passed baggage object. |
366 |
| - * |
367 |
| - * Note: This function does not explicitly check if the passed baggage object is allowed |
368 |
| - * to be modified. Implicitly, `setBaggageValue` will not make modification to the object |
369 |
| - * if it was already set immutable. |
370 |
| - * |
371 |
| - * After adding the data, the baggage object is set immutable to prevent further modifications. |
372 |
| - * |
373 |
| - * @param baggage |
374 |
| - * |
375 |
| - * @returns modified and immutable baggage object |
376 |
| - */ |
377 |
| - private _populateBaggageWithSentryValues(baggage: Baggage = createBaggage({})): Baggage { |
378 |
| - // Because of a cicular dependency, we cannot import the Transaction class here, hence the type casts |
379 |
| - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any |
380 |
| - const hub: Hub = ((this.transaction as any) && (this.transaction as any)._hub) || getCurrentHub(); |
381 |
| - const client = hub && hub.getClient(); |
382 |
| - |
383 |
| - const { environment, release } = (client && client.getOptions()) || {}; |
384 |
| - const { publicKey } = (client && client.getDsn()) || {}; |
385 |
| - |
386 |
| - const metadata = this.transaction && this.transaction.metadata; |
387 |
| - const sampleRate = metadata && metadata.transactionSampling && metadata.transactionSampling.rate; |
388 |
| - |
389 |
| - const traceId = this.traceId; |
390 |
| - |
391 |
| - const transactionName = this.transaction && this.transaction.name; |
392 |
| - |
393 |
| - let userId, userSegment; |
394 |
| - hub.withScope(scope => { |
395 |
| - const user = scope.getUser(); |
396 |
| - userId = user && user.id; |
397 |
| - userSegment = user && user.segment; |
398 |
| - }); |
399 |
| - |
400 |
| - environment && setBaggageValue(baggage, 'environment', environment); |
401 |
| - release && setBaggageValue(baggage, 'release', release); |
402 |
| - transactionName && setBaggageValue(baggage, 'transaction', transactionName); |
403 |
| - userId && setBaggageValue(baggage, 'userid', userId); |
404 |
| - userSegment && setBaggageValue(baggage, 'usersegment', userSegment); |
405 |
| - sampleRate && |
406 |
| - setBaggageValue( |
407 |
| - baggage, |
408 |
| - 'samplerate', |
409 |
| - // This will make sure that expnent notation (e.g. 1.45e-14) is converted to simple decimal representation |
410 |
| - // Another edge case would be something like Number.NEGATIVE_INFINITY in which case we could still |
411 |
| - // add something like .replace(/-?∞/, '0'). For the sake of saving bytes, I'll not add this until |
412 |
| - // it becomes a problem |
413 |
| - sampleRate.toLocaleString('fullwide', { useGrouping: false, maximumFractionDigits: 16 }), |
414 |
| - ); |
415 |
| - publicKey && setBaggageValue(baggage, 'publickey', publicKey); |
416 |
| - traceId && setBaggageValue(baggage, 'traceid', traceId); |
417 |
| - |
418 |
| - setBaggageImmutable(baggage); |
419 |
| - |
420 |
| - return baggage; |
421 |
| - } |
422 | 330 | }
|
423 | 331 |
|
424 | 332 | export type SpanStatusType =
|
|
0 commit comments