Go to console

Index

Methods

getAttribute

  • getAttribute(attr: string): string | undefined
  • Retrieves the value that the custom attribute is set to.

    Parameters

    • attr: string

      Name of the custom attribute.

    Returns string | undefined

getAttributes

  • getAttributes(): object
  • Returns a map of all custom attributes of a trace instance.

    Returns object

    • [key: string]: string

getMetric

  • getMetric(metricName: string): number
  • Returns the value of the custom metric by that name. If a custom metric with that name does not exist returns zero.

    Parameters

    • metricName: string

      Name of the custom metric.

    Returns number

incrementMetric

  • incrementMetric(metricName: string, num?: number): void
  • Adds to the value of a custom metric. If a custom metric with the provided name does not exist, it creates one with that name and the value equal to the given number.

    Parameters

    • metricName: string

      The name of the custom metric.

    • Optional num: number

      The number to be added to the value of the custom metric. If not provided, it uses a default value of one.

    Returns void

putAttribute

  • putAttribute(attr: string, value: string): void
  • Set a custom attribute of a trace to a certain value.

    Parameters

    • attr: string

      Name of the custom attribute.

    • value: string

      Value of the custom attribute.

    Returns void

putMetric

  • putMetric(metricName: string, num: number): void
  • Sets the value of the specified custom metric to the given number regardless of whether a metric with that name already exists on the trace instance or not.

    Parameters

    • metricName: string

      Name of the custom metric.

    • num: number

      Value to of the custom metric.

    Returns void

record

  • record(startTime: number, duration: number, options?: object): void
  • Records a trace from given parameters. This provides a direct way to use trace without a need to start/stop. This is useful for use cases in which the trace cannot directly be used (e.g. if the duration was captured before the Performance SDK was loaded).

    Parameters

    • startTime: number

      Trace start time since epoch in millisec.

    • duration: number

      The duraction of the trace in millisec.

    • Optional options: object

      An object which can optionally hold maps of custom metrics and custom attributes.

      • Optional attributes?: object
        • [key: string]: string
      • Optional metrics?: object
        • [key: string]: number

    Returns void

removeAttribute

  • removeAttribute(attr: string): void
  • Removes the specified custom attribute from a trace instance.

    Parameters

    • attr: string

      Name of the custom attribute.

    Returns void

start

  • start(): void
  • Starts the timing for the trace instance.

    Returns void

stop

  • stop(): void
  • Stops the timing of the trace instance and logs the data of the instance.

    Returns void