Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Metric<InternalRepresentation, PayloadRepresentation>

The Metric class describes the shared behaviour amongst concrete metrics.

A concrete metric will always have two possible representations:

  • InternalRepresentation
    • Is the format in which this metric will be stored in memory.
    • This format may contain extra metadata, in order to allow deserializing of this data for testing purposes.
  • PayloadRepresentation
    • Is the format in which this metric will be represented in the ping payload.
    • This format must be the exact same as described in the Glean schema.

Type parameters

Hierarchy

Index

Constructors

  • new Metric<InternalRepresentation, PayloadRepresentation>(v: unknown): Metric<InternalRepresentation, PayloadRepresentation>

Properties

_inner: InternalRepresentation

Methods

  • get(): InternalRepresentation
  • Gets this metrics value in its internal representation.

    Returns InternalRepresentation

    The metric value.

  • payload(): PayloadRepresentation
  • set(v: InternalRepresentation): void
  • Validates that a given value is in the correct format for this metrics internal representation.

    Note

    This function should only check for validations that would prevent a metric from being recorded.

    Parameters

    • v: unknown

      The value to verify.

    Returns MetricValidationResult

    Whether or not validation was successfull.

  • validateOrThrow(v: unknown): InternalRepresentation
  • Validates a given value using the validation function and throws in case it is not valid.

    Parameters

    • v: unknown

      The value to verify.

    Returns InternalRepresentation

    v if it is valid.

Generated using TypeDoc