Code coverage report for node/src/apm/statsd/counter.ts

Statements: 37.5% (3 / 8)      Branches: 0% (0 / 8)      Functions: 0% (0 / 4)      Lines: 37.5% (3 / 8)      Ignored: none     

All files » node/src/apm/statsd/ » counter.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 511 1                                                                 1                                
import {Counter, CounterFactory, Tags} from '@btilford/ts-base-core';
import {StatsDMetric, StatsDOptions} from './metric';
 
 
class StatsDCounter extends StatsDMetric implements Counter<number> {
 
 
  decrement(val: number, tags: Tags = {}): void {
    this.statsd.decrement(
      this.name,
      val || 1,
      this.options.sampleRate,
      {
        ...this.tags,
        ...tags,
      },
    );
  }
 
 
  increment(val: number, tags: Tags = {}): void {
    this.statsd.increment(
      this.name,
      val || 1,
      this.options.sampleRate,
      {
        ...this.tags,
        ...tags,
      },
    );
  }
}
 
 
export class StatsDCounterFactory extends CounterFactory<number> {
  protected readonly options: StatsDOptions;
 
 
  constructor(options: StatsDOptions = {}) {
    super();
    this.options = { ...options };
  }
 
 
  counter(name: string, tags: Tags = {}): Counter<number> {
    return new StatsDCounter(name, this.options, tags);
  }
 
 
}