Simple metrics collector class for creating and managing metrics.

Constructors

  • Parameters

    • serviceName: string
    • serviceVersion: string = "1.0.0"
    • resourceAttributes: Record<string, unknown> = {}

    Returns SimpleMetricsCollector

Methods

  • Add a counter metric (monotonic sum).

    Parameters

    • name: string
    • description: string
    • unit: string
    • value: number
    • attributes: Record<string, unknown> = {}

    Returns void

  • Add a gauge metric (current value).

    Parameters

    • name: string
    • description: string
    • unit: string
    • value: number
    • attributes: Record<string, unknown> = {}

    Returns void

  • Add a histogram metric.

    Parameters

    • name: string
    • description: string
    • unit: string
    • count: number
    • sum: number
    • buckets: { bound: number; count: number }[]
    • attributes: Record<string, unknown> = {}

    Returns void

  • Get all metrics and clear the buffer.

    Returns MetricsData

  • Get current metrics without clearing the buffer.

    Returns MetricsData