* You should never call the constructor manually, always use `Sentry.startSpan()` * or other span methods. * @internal * @hideconstructor * @hidden
(spanContext: SentrySpanArguments = {})
| 82 | * @hidden |
| 83 | */ |
| 84 | public constructor(spanContext: SentrySpanArguments = {}) { |
| 85 | this._traceId = spanContext.traceId || generateTraceId(); |
| 86 | this._spanId = spanContext.spanId || generateSpanId(); |
| 87 | this._startTime = spanContext.startTimestamp || timestampInSeconds(); |
| 88 | this._links = spanContext.links; |
| 89 | |
| 90 | this._attributes = {}; |
| 91 | this.setAttributes({ |
| 92 | [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual', |
| 93 | [SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op, |
| 94 | ...spanContext.attributes, |
| 95 | }); |
| 96 | |
| 97 | this._name = spanContext.name; |
| 98 | |
| 99 | if (spanContext.parentSpanId) { |
| 100 | this._parentSpanId = spanContext.parentSpanId; |
| 101 | } |
| 102 | // We want to include booleans as well here |
| 103 | if ('sampled' in spanContext) { |
| 104 | this._sampled = spanContext.sampled; |
| 105 | } |
| 106 | if (spanContext.endTimestamp) { |
| 107 | this._endTime = spanContext.endTimestamp; |
| 108 | } |
| 109 | |
| 110 | this._events = []; |
| 111 | |
| 112 | this._isStandaloneSpan = spanContext.isStandalone; |
| 113 | |
| 114 | // If the span is already ended, ensure we finalize the span immediately |
| 115 | if (this._endTime) { |
| 116 | this._onSpanEnded(); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /** @inheritDoc */ |
| 121 | public addLink(link: SpanLink): this { |
nothing calls this directly
no test coverage detected