Skip to content

Commit

Permalink
fix: export supporting metrics types (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain authored Aug 10, 2023
1 parent 23bf0ee commit 09296bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export enum MessageSource {
type LabelsGeneric = Record<string, string | undefined>
type CollectFn<Labels extends LabelsGeneric> = (metric: Gauge<Labels>) => void

interface Gauge<Labels extends LabelsGeneric = never> {
export interface Gauge<Labels extends LabelsGeneric = never> {
// Sorry for this mess, `prom-client` API choices are not great
// If the function signature was `inc(value: number, labels?: Labels)`, this would be simpler
inc(value?: number): void
Expand All @@ -36,7 +36,7 @@ interface Gauge<Labels extends LabelsGeneric = never> {
addCollect(collectFn: CollectFn<Labels>): void
}

interface Histogram<Labels extends LabelsGeneric = never> {
export interface Histogram<Labels extends LabelsGeneric = never> {
startTimer(): () => void

observe(value: number): void
Expand All @@ -46,26 +46,26 @@ interface Histogram<Labels extends LabelsGeneric = never> {
reset(): void
}

interface AvgMinMax<Labels extends LabelsGeneric = never> {
export interface AvgMinMax<Labels extends LabelsGeneric = never> {
set(values: number[]): void
set(labels: Labels, values: number[]): void
set(arg1?: Labels | number[], arg2?: number[]): void
}

type GaugeConfig<Labels extends LabelsGeneric> = {
export type GaugeConfig<Labels extends LabelsGeneric> = {
name: string
help: string
labelNames?: keyof Labels extends string ? (keyof Labels)[] : undefined
}

type HistogramConfig<Labels extends LabelsGeneric> = {
export type HistogramConfig<Labels extends LabelsGeneric> = {
name: string
help: string
labelNames?: (keyof Labels)[]
buckets?: number[]
}

type AvgMinMaxConfig<Labels extends LabelsGeneric> = GaugeConfig<Labels>
export type AvgMinMaxConfig<Labels extends LabelsGeneric> = GaugeConfig<Labels>

export interface MetricsRegister {
gauge<T extends LabelsGeneric>(config: GaugeConfig<T>): Gauge<T>
Expand Down

0 comments on commit 09296bd

Please sign in to comment.