Options
All
  • Public
  • Public/Protected
  • All
Menu

A timespan metric.

Timespans are used to make a measurement of how much time is spent in a particular task.

Hierarchy

Index

Constructors

constructor

Properties

Readonly category

category: string

Readonly disabled

disabled: boolean

Optional dynamicLabel

dynamicLabel: string

Readonly lifetime

lifetime: Lifetime

Readonly name

name: string

Readonly sendInPings

sendInPings: string[]

Optional startTime

startTime: number

Private timeUnit

timeUnit: default

Readonly type

type: string

Methods

baseIdentifier

  • baseIdentifier(): string
  • The metric's base identifier, including the category and name, but not the label.

    Returns string

    The generated identifier. If category is empty, it's ommitted. Otherwise, it's the combination of the metric's category and name.

cancel

  • cancel(): void

identifier

  • identifier(metricsDatabase: default): Promise<string>
  • The metric's unique identifier, including the category, name and label.

    Parameters

    • metricsDatabase: default

      The metrics database.

    Returns Promise<string>

    The generated identifier. If category is empty, it's ommitted. Otherwise, it's the combination of the metric's category, name and label.

setRawNanos

  • setRawNanos(elapsed: number): void
  • Explicitly sets the timespan value.

    This API should only be used if your library or application requires recording times in a way that can not make use of {@link TimespanMetricType#start}/{@link TimespanMetricType#stop}.

    Care should be taken using this if the ping lifetime might contain more than one timespan measurement. To be safe, this function should generally be followed by sending a custom ping containing the timespan.

    Parameters

    • elapsed: number

      The elapsed time to record, in nanoseconds.

    Returns void

shouldRecord

  • shouldRecord(uploadEnabled: boolean): boolean
  • Verify whether or not this metric instance should be recorded.

    Parameters

    • uploadEnabled: boolean

      Whether or not global upload is enabled or disabled.

    Returns boolean

    Whether or not this metric instance should be recorded.

start

  • start(): void
  • Starts tracking time for the provided metric.

    This records an error if it's already tracking time (i.e. start was already called with no corresponding stop(). In which case the original start time will be preserved.

    Returns void

stop

  • stop(): void
  • Stops tracking time for the provided metric. Sets the metric to the elapsed time.

    This will record an error if no start() was called.

    Returns void

testGetNumRecordedErrors

  • testGetNumRecordedErrors(errorType: string, ping?: string): Promise<number>
  • Returns the number of errors recorded for the given metric.

    Parameters

    • errorType: string

      The type of the error recorded.

    • ping: string = ...

      represents the name of the ping to retrieve the metric for. Defaults to the first value in sendInPings.

    Returns Promise<number>

    the number of errors recorded for the metric.

testGetValue

  • testGetValue(ping?: string): Promise<undefined | number>
  • Test-only API.**

    Gets the currently stored value as a number.

    This doesn't clear the stored value.

    TODO: Only allow this function to be called on test mode (depends on Bug 1682771).

    Parameters

    • ping: string = ...

      the ping from which we want to retrieve this metrics value from. Defaults to the first value in sendInPings.

    Returns Promise<undefined | number>

    The value found in storage or undefined if nothing was found.

Static _private_setRawUndispatched

  • _private_setRawUndispatched(instance: default, elapsed: number): Promise<void>
  • An internal implemention of setRaw that does not dispatch the recording task.

    Important

    This is absolutely not meant to be used outside of Glean itself. It may cause multiple issues because it cannot guarantee that the recording of the metric will happen in order with other Glean API calls.

    Parameters

    • instance: default

      The metric instance to record to.

    • elapsed: number

      The elapsed time to record, in milliseconds.

    Returns Promise<void>

Legend

  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Enumeration
  • Interface
  • Private property
  • Static method

Generated using TypeDoc