Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 838 Bytes

metric.md

File metadata and controls

43 lines (31 loc) · 838 Bytes

Metric Module

Collect metrics based on Prometheus.

Scraping is available at /metrics endpoint.


Usage

To create you own metrics, use provided methods getCounter(), getGauge(), getHistogram() or getSummary(), from the MetricService.

import { Histogram, MetricService } from '@bechara/crux';

@Injectable()
export class FooService {

  public constructor(
    private readonly metricService: MetricService,
  ) {
    setup();
  }

  public setup(): void {
    this.metricService.getHistogram('foo_size', {
      help: 'Size of foo.',
      labelNames: [ 'foo', 'bar' ],
      buckets: [ 1, 3, 5, 8, 13 ],
    });
  }

  public readFoo(): Foo {
    // ...
    const histogram = this.metricService.getHistogram('foo_size');
    // ...
  }
}

Back to title