Options
All
  • Public
  • Public/Protected
  • All
Menu

Histogram Metric

Histograms track sizes and frequency of ecents. One more feature for histograms, is the timer metric which can record duration of events.

import { Histogram } from '@mists/nestjs-metrics';

const histogram = new Histogram('metric_histogram');

// force prometheus settings
const histogram = new Histogram('metric_histogram', {
  prometheus: {
    help: 'This is a histogram metric'
  }
})

// force statsd settings; if no settings are provided here,
// default settings will be used
const histogram = new Histogram('metric_histogram', {
  statsd: {
    host: 'localhost',
    socketTimeout: 2000,
  }
})

Hierarchy

Index

Constructors

constructor

  • Parameters

    • name: string

      Name used for the metric

    • Optional options: HistogramOptions

      Options for the metric
      Depending on the metric technology used. Even though the MetricOptions support almost all options for each supported technology, be careful how you use and setup your options since they may generated strange behaviors that were not intended with this API.

    Returns Histogram

Properties

Protected name

name: string

Name used for the metric

Protected options

options: MetricOptions

Options for the metric
Depending on the metric technology used. Even though the MetricOptions support almost all options for each supported technology, be careful how you use and setup your options since they may generated strange behaviors that were not intended with this API.

Protected prometheusMetric

prometheusMetric: any

Protected statsdClient

statsdClient: any

Accessors

Protected statsdName

  • get statsdName(): string

Methods

observe

  • observe(value: number, tags?: Tags): void
  • Observe method.

    import { Histogram } from '@mists/nestjs-metrics';
    
    const histogram = new Histogram('metric_histogram');
    
    // will observe value 10 (custom value)
    histogram.observe(10);
    
    // will observe value 1, attaching also a `server_id` label
    histogram.observe(1, {server_id: 'instance_1'})

    Parameters

    • value: number

      Value to decrement with; default 1

    • Optional tags: Tags

      Tags to attach to the increment; optional

    Returns void

reset

  • reset(): void
  • Reset method.

    import { Histogram } from '@mists/nestjs-metrics';
    
    const histogram = new Histogram('metric_histogram');
    
    // will reset all histogram values
    histogram.reset();
    

    Returns void

startTimer

Legend

  • Property
  • Method
  • Constructor
  • Method
  • Inherited method
  • Protected property
  • Static method

Generated using TypeDoc