{"version":3,"file":"Span.cjs","names":["SpanStatusCode","maybeAddAttribute","AddAttributeDecision","isTimeInput","cleanSimpleAttributes","cleanAttributes","hrTimeDuration","hrTime","millisToHrTime","isTimeInputHrTime","addHrTimes","ATTR_EXCEPTION_MESSAGE","ATTR_EXCEPTION_TYPE","ATTR_EXCEPTION_STACKTRACE","ExceptionEventName","inspectCustom","settledResourceAttributes","formatInspect"],"sources":["../src/Span.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n  Context,\n  Exception,\n  HrTime,\n  Link,\n  Span as APISpan,\n  SpanOptions as APISpanOptions,\n  Attributes,\n  SpanContext,\n  SpanKind,\n  SpanStatus,\n  TimeInput,\n  AnyValue,\n} from '@opentelemetry/api';\nimport { diag, SpanStatusCode } from '@opentelemetry/api';\nimport type { InstrumentationScope } from '@opentelemetry/core';\nimport {\n  addHrTimes,\n  millisToHrTime,\n  hrTime,\n  hrTimeDuration,\n  isTimeInput,\n  isTimeInputHrTime,\n  AddAttributeDecision,\n  maybeAddAttribute,\n  cleanAttributes,\n  cleanSimpleAttributes,\n} from '@opentelemetry/core';\nimport type { Resource } from '@opentelemetry/resources';\nimport {\n  ATTR_EXCEPTION_MESSAGE,\n  ATTR_EXCEPTION_STACKTRACE,\n  ATTR_EXCEPTION_TYPE,\n} from '@opentelemetry/semantic-conventions';\nimport type { ReadableSpan } from './export/ReadableSpan';\nimport { ExceptionEventName } from './enums';\nimport type { SpanProcessor } from './SpanProcessor';\nimport type { TimedEvent } from './TimedEvent';\nimport type { SpanLimits } from './types';\nimport type { InspectFn, InspectStylizeOptions } from './inspect';\nimport {\n  formatInspect,\n  inspectCustom,\n  settledResourceAttributes,\n} from './inspect';\n\n/**\n * This type provides the properties of @link{ReadableSpan} at the same time\n * of the Span API\n */\nexport type Span = APISpan & ReadableSpan;\n\n// `root` is omitted because it is consumed by Tracer.startSpan() to strip\n// parent context but it has no meaning when constructing a Span directly.\ntype SpanOptions = Omit<APISpanOptions, 'root'> & {\n  resource: Resource;\n  scope: InstrumentationScope;\n  context: Context;\n  spanContext: SpanContext;\n  name: string;\n  // Required here to override optional `kind` from the API's SpanOptions\n  // SpanImpl assigns it unconditionally and ReadableSpan expects it to be set.\n  kind: SpanKind;\n  parentSpanContext?: SpanContext;\n  spanLimits: Required<SpanLimits>;\n  spanProcessor: SpanProcessor;\n  droppedAttributesCount?: number;\n  recordEndMetrics?: () => void;\n};\n\n/**\n * This class represents a span.\n */\nexport class SpanImpl implements Span {\n  // Below properties are included to implement ReadableSpan for export\n  // purposes but are not intended to be written-to directly.\n  private readonly _spanContext: SpanContext;\n  readonly kind: SpanKind;\n  readonly parentSpanContext?: SpanContext;\n  readonly attributes: Attributes;\n  readonly links: Link[] = [];\n  readonly events: TimedEvent[] = [];\n  readonly startTime: HrTime;\n  readonly resource: Resource;\n  readonly instrumentationScope: InstrumentationScope;\n\n  private _droppedAttributesCount = 0;\n  private _droppedEventsCount: number = 0;\n  private _droppedLinksCount: number = 0;\n  private _attributesCount: number = 0;\n\n  name: string;\n  status: SpanStatus = {\n    code: SpanStatusCode.UNSET,\n  };\n  endTime: HrTime = [0, 0];\n  private _ended = false;\n  private _duration: HrTime = [-1, -1];\n  private readonly _spanProcessor: SpanProcessor;\n  private readonly _spanLimits: Required<SpanLimits>;\n  private readonly _recordEndMetrics?: () => void;\n\n  private readonly _performanceStartTime: number;\n  private readonly _performanceOffset: number;\n  private readonly _startTimeProvided: boolean;\n\n  /**\n   * Constructs a new SpanImpl instance.\n   *\n   * `opts.attributes` must already have been sanitized by caller.\n   * `attributes` in `opts.links` must already have been sanitized by caller.\n   * These are typically required anyway to pass sanitized details to a\n   * *sampler* before span creation.\n   */\n  constructor(opts: SpanOptions) {\n    const now = Date.now();\n\n    this._spanContext = opts.spanContext;\n    this._performanceStartTime = performance.now();\n    this._performanceOffset =\n      now - (this._performanceStartTime + performance.timeOrigin);\n    this._startTimeProvided = opts.startTime != null;\n    this._spanLimits = opts.spanLimits;\n    this._spanProcessor = opts.spanProcessor;\n\n    this.name = opts.name;\n    this.parentSpanContext = opts.parentSpanContext;\n    this.kind = opts.kind;\n    this.startTime = this._getTime(opts.startTime ?? now);\n    this.resource = opts.resource;\n    this.instrumentationScope = opts.scope;\n    this._recordEndMetrics = opts.recordEndMetrics;\n\n    // Attributes in links have already be sanitized by the caller.\n    if (opts.links) {\n      const { linkCountLimit } = this._spanLimits;\n      if (opts.links.length > linkCountLimit) {\n        // later ones win\n        this.links = opts.links.slice(\n          opts.links.length - linkCountLimit,\n          opts.links.length\n        );\n        this._droppedLinksCount = opts.links.length - linkCountLimit;\n      } else {\n        this.links = opts.links;\n        this._droppedLinksCount = 0;\n      }\n    }\n\n    // `opts.attributes` have already been sanitized by caller.\n    this.attributes = opts.attributes ?? {};\n    this._attributesCount = Object.keys(this.attributes).length;\n    this._droppedAttributesCount = opts.droppedAttributesCount ?? 0;\n\n    this._spanProcessor.onStart(this, opts.context);\n  }\n\n  spanContext(): SpanContext {\n    return this._spanContext;\n  }\n\n  public setAttribute(key: string, value: AnyValue) {\n    if (this._isSpanEnded()) return this;\n\n    const decision = maybeAddAttribute({\n      key,\n      value,\n      attributes: this.attributes,\n      limits: this._spanLimits,\n      currentAttributesCount: this._attributesCount,\n    });\n\n    if (decision === AddAttributeDecision.DROP_LIMIT_REACHED) {\n      this._droppedAttributesCount++;\n      if (this._droppedAttributesCount === 1) {\n        // Only warn once per LogRecord to avoid log spam\n        diag.warn('Dropping extra attributes.');\n      }\n    } else if (decision === AddAttributeDecision.ADD_NEW) {\n      this._attributesCount++;\n    }\n\n    return this;\n  }\n\n  setAttributes(attributes: Attributes): this {\n    for (const key in attributes) {\n      if (Object.prototype.hasOwnProperty.call(attributes, key)) {\n        this.setAttribute(key, attributes[key]);\n      }\n    }\n    return this;\n  }\n\n  /**\n   *\n   * @param name Span event name\n   * @param [attributesOrStartTime] Attributes or start time\n   *     if type is {@type TimeInput} and 3rd param is undefined.\n   *     Only \"simple\" value types are supported for span event attributes\n   *     (string, number, boolean, homogeneous array of these primitive types).\n   *     See OTEP 4485 and `cleanSimpleAttributes()` in `@opentelemetry/core`.\n   * @param [timeStamp] Specified time stamp for the event\n   */\n  addEvent(\n    name: string,\n    attributesOrStartTime?: Attributes | TimeInput,\n    timeStamp?: TimeInput\n  ): this {\n    if (this._isSpanEnded()) return this;\n\n    const { eventCountLimit } = this._spanLimits;\n\n    if (eventCountLimit === 0) {\n      diag.warn('No events allowed.');\n      this._droppedEventsCount++;\n      return this;\n    }\n\n    if (\n      eventCountLimit !== undefined &&\n      this.events.length >= eventCountLimit\n    ) {\n      if (this._droppedEventsCount === 0) {\n        diag.debug('Dropping extra events.');\n      }\n      this.events.shift();\n      this._droppedEventsCount++;\n    }\n\n    if (isTimeInput(attributesOrStartTime)) {\n      if (!isTimeInput(timeStamp)) {\n        timeStamp = attributesOrStartTime;\n      }\n      attributesOrStartTime = undefined;\n    }\n\n    this.events.push({\n      name,\n      time: this._getTime(timeStamp),\n      ...cleanSimpleAttributes(attributesOrStartTime, {\n        attributeCountLimit: this._spanLimits.attributePerEventCountLimit,\n        attributeValueLengthLimit: this._spanLimits.attributeValueLengthLimit,\n      }),\n    });\n    return this;\n  }\n\n  addLink(link: Link): this {\n    if (this._isSpanEnded()) return this;\n\n    const { linkCountLimit } = this._spanLimits;\n\n    if (linkCountLimit === 0) {\n      this._droppedLinksCount++;\n      return this;\n    }\n\n    if (linkCountLimit !== undefined && this.links.length >= linkCountLimit) {\n      if (this._droppedLinksCount === 0) {\n        diag.debug('Dropping extra links.');\n      }\n      this.links.shift();\n      this._droppedLinksCount++;\n    }\n\n    this.links.push({\n      context: link.context,\n      ...cleanAttributes(link.attributes, {\n        attributeCountLimit: this._spanLimits.attributePerLinkCountLimit,\n        attributeValueLengthLimit: this._spanLimits.attributeValueLengthLimit,\n      }),\n    });\n    return this;\n  }\n\n  addLinks(links: Link[]): this {\n    for (const link of links) {\n      this.addLink(link);\n    }\n    return this;\n  }\n\n  setStatus(status: SpanStatus): this {\n    if (this._isSpanEnded()) return this;\n    if (status.code === SpanStatusCode.UNSET) return this;\n    if (this.status.code === SpanStatusCode.OK) return this;\n\n    const newStatus: SpanStatus = { code: status.code };\n\n    // When using try-catch, the caught \"error\" is of type `any`. When then assigning `any` to `status.message`,\n    // TypeScript will not error. While this can happen during use of any API, it is more common on Span#setStatus()\n    // as it's likely used in a catch-block. Therefore, we validate if `status.message` is actually a string, null, or\n    // undefined to avoid an incorrect type causing issues downstream.\n    if (status.code === SpanStatusCode.ERROR) {\n      if (typeof status.message === 'string') {\n        newStatus.message = status.message;\n      } else if (status.message != null) {\n        diag.warn(\n          `Dropping invalid status.message of type '${typeof status.message}', expected 'string'`\n        );\n      }\n    }\n\n    this.status = newStatus;\n    return this;\n  }\n\n  updateName(name: string): this {\n    if (this._isSpanEnded()) return this;\n    this.name = name;\n    return this;\n  }\n\n  end(endTime?: TimeInput): void {\n    if (this._isSpanEnded()) {\n      diag.error(\n        `${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`\n      );\n      return;\n    }\n    this.endTime = this._getTime(endTime);\n    this._duration = hrTimeDuration(this.startTime, this.endTime);\n\n    if (this._duration[0] < 0) {\n      diag.warn(\n        'Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.',\n        this.startTime,\n        this.endTime\n      );\n      this.endTime = this.startTime.slice() as HrTime;\n      this._duration = [0, 0];\n    }\n\n    if (this._droppedEventsCount > 0) {\n      diag.warn(\n        `Dropped ${this._droppedEventsCount} events because eventCountLimit reached`\n      );\n    }\n    if (this._droppedLinksCount > 0) {\n      diag.warn(\n        `Dropped ${this._droppedLinksCount} links because linkCountLimit reached`\n      );\n    }\n    if (this._spanProcessor.onEnding) {\n      this._spanProcessor.onEnding(this);\n    }\n\n    this._recordEndMetrics?.();\n    this._ended = true;\n    this._spanProcessor.onEnd(this);\n  }\n\n  private _getTime(inp?: TimeInput): HrTime {\n    if (typeof inp === 'number' && inp <= performance.now()) {\n      // must be a performance timestamp\n      // apply correction and convert to hrtime\n      return hrTime(inp + this._performanceOffset);\n    }\n\n    if (typeof inp === 'number') {\n      return millisToHrTime(inp);\n    }\n\n    if (inp instanceof Date) {\n      return millisToHrTime(inp.getTime());\n    }\n\n    if (isTimeInputHrTime(inp)) {\n      return inp;\n    }\n\n    if (this._startTimeProvided) {\n      // if user provided a time for the start manually\n      // we can't use duration to calculate event/end times\n      return millisToHrTime(Date.now());\n    }\n\n    const msDuration = performance.now() - this._performanceStartTime;\n    return addHrTimes(this.startTime, millisToHrTime(msDuration));\n  }\n\n  isRecording(): boolean {\n    return this._ended === false;\n  }\n\n  recordException(exception: Exception, time?: TimeInput): void {\n    const attributes: Attributes = {};\n    if (typeof exception === 'string') {\n      attributes[ATTR_EXCEPTION_MESSAGE] = exception;\n    } else if (exception) {\n      if (exception.code) {\n        attributes[ATTR_EXCEPTION_TYPE] = exception.code.toString();\n      } else if (exception.name) {\n        attributes[ATTR_EXCEPTION_TYPE] = exception.name;\n      }\n      if (exception.message) {\n        attributes[ATTR_EXCEPTION_MESSAGE] = exception.message;\n      }\n      if (exception.stack) {\n        attributes[ATTR_EXCEPTION_STACKTRACE] = exception.stack;\n      }\n    }\n\n    // these are minimum requirements from spec\n    if (attributes[ATTR_EXCEPTION_TYPE] || attributes[ATTR_EXCEPTION_MESSAGE]) {\n      this.addEvent(ExceptionEventName, attributes, time);\n    } else {\n      diag.warn(`Failed to record an exception ${exception}`);\n    }\n  }\n\n  get duration(): HrTime {\n    return this._duration;\n  }\n\n  get ended(): boolean {\n    return this._ended;\n  }\n\n  get droppedAttributesCount(): number {\n    return this._droppedAttributesCount;\n  }\n\n  get droppedEventsCount(): number {\n    return this._droppedEventsCount;\n  }\n\n  get droppedLinksCount(): number {\n    return this._droppedLinksCount;\n  }\n\n  private _isSpanEnded(): boolean {\n    if (this._ended) {\n      const error = new Error(\n        `Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`\n      );\n\n      diag.warn(\n        `Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,\n        error\n      );\n    }\n    return this._ended;\n  }\n\n  [inspectCustom](\n    depth: number,\n    options: InspectStylizeOptions | undefined,\n    inspect: InspectFn | undefined\n  ): unknown {\n    const payload = {\n      name: this.name,\n      kind: this.kind,\n      spanContext: this._spanContext,\n      parentSpanContext: this.parentSpanContext,\n      status: this.status,\n      startTime: this.startTime,\n      endTime: this.endTime,\n      duration: this._duration,\n      ended: this._ended,\n      attributes: this.attributes,\n      events: this.events,\n      links: this.links,\n      droppedAttributesCount: this._droppedAttributesCount,\n      droppedEventsCount: this._droppedEventsCount,\n      droppedLinksCount: this._droppedLinksCount,\n      instrumentationScope: this.instrumentationScope,\n      resource: { attributes: settledResourceAttributes(this.resource) },\n    };\n    return formatInspect('SpanImpl', payload, depth, options, inspect);\n  }\n}\n"],"mappings":";;;;;;;;;AA8EA,IAAa,WAAb,MAAsC;CAGpC;CACA;CACA;CACA;CACA,QAAyB,CAAC;CAC1B,SAAgC,CAAC;CACjC;CACA;CACA;CAEA,0BAAkC;CAClC,sBAAsC;CACtC,qBAAqC;CACrC,mBAAmC;CAEnC;CACA,SAAqB,EACnB,MAAMA,mBAAAA,eAAe,MACvB;CACA,UAAkB,CAAC,GAAG,CAAC;CACvB,SAAiB;CACjB,YAA4B,CAAC,IAAI,EAAE;CACnC;CACA;CACA;CAEA;CACA;CACA;;;;;;;;;CAUA,YAAY,MAAmB;EAC7B,MAAM,MAAM,KAAK,IAAI;EAErB,KAAK,eAAe,KAAK;EACzB,KAAK,wBAAwB,YAAY,IAAI;EAC7C,KAAK,qBACH,OAAO,KAAK,wBAAwB,YAAY;EAClD,KAAK,qBAAqB,KAAK,aAAa;EAC5C,KAAK,cAAc,KAAK;EACxB,KAAK,iBAAiB,KAAK;EAE3B,KAAK,OAAO,KAAK;EACjB,KAAK,oBAAoB,KAAK;EAC9B,K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