Code coverage report for core/src/apm/constants.ts

Statements: 100% (14 / 14)      Branches: 100% (0 / 0)      Functions: 100% (2 / 2)      Lines: 100% (13 / 13)      Ignored: none     

All files » core/src/apm/ » constants.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 431 1 1 1     1 4         1         1 1 1 1 1                               1          
import {CounterFactory} from './counter';
import {GaugeFactory} from './gauge';
import {HistogramFactory} from './histogram';
import {TimerWrapperFactory} from './timed';
 
 
export class ApmFeature {
  constructor(readonly envKey: string, readonly type: { name: string }) {
  }
}
 
 
export class ApmFeatureRef {
 
}
 
 
export class ApmEnv {
  readonly timer = new ApmFeature('apm.timer', TimerWrapperFactory);
  readonly counter = new ApmFeature('apm.counter', CounterFactory);
  readonly gauge = new ApmFeature('apm.gauge', GaugeFactory);
  readonly histogram = new ApmFeature('apm.histogram', HistogramFactory);
}
 
 
// export type ApmFactoryName<T> = T extends {name:string}
export type ApmFactory<T> = T extends TimerWrapperFactory
                                      | CounterFactory<any>
                                      | GaugeFactory<any>
                                      | HistogramFactory<unknown> ? { name: string } : never;
 
export type ApmFactoryInstance<T, I> = T extends ApmFactory<any>
                                       ? I extends T ? I : never
                                       : any;
 
// type TesT<T, I> = [ApmFactory<T>, ApmFactoryInstance<T, I>];
// const t: TesT<CounterFactory, ConsoleCounterFactory> = [CounterFactory, new ConsoleCounterFactory({})]
export const APM_ENV = new ApmEnv();
 
 
export type ApmFeatures = keyof ApmEnv;