prom-client#Histogram TypeScript Examples

The following examples show how to use prom-client#Histogram. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts    From common-ts with MIT License 6 votes vote down vote up
export async function timed<T>(
  metric: Histogram<string> | undefined,
  labels: LabelValues<string> | undefined,
  promise: T | Promise<T>,
): Promise<T> {
  const timer = metric?.startTimer(labels)
  try {
    return await promise
  } finally {
    if (timer) {
      timer(labels)
    }
  }
}
Example #2
Source File: prometheus.ts    From monkeytype with GNU General Public License v3.0 6 votes vote down vote up
resultWpm = new Histogram({
  name: "result_wpm",
  help: "Result wpm",
  labelNames: ["mode", "mode2"],
  buckets: [
    10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170,
    180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290,
  ],
})
Example #3
Source File: metrics.service.ts    From wise-old-man with MIT License 6 votes vote down vote up
private setupReactionHistogram() {
    this.reactionHistogram = new prometheus.Histogram({
      name: 'reaction_duration_seconds',
      help: 'Duration of reactions in microseconds',
      labelNames: ['reactionName', 'status'],
      buckets: [0.1, 0.3, 0.5, 0.7, 1, 3, 5, 7, 10, 30]
    });

    this.registry.registerMetric(this.reactionHistogram);
  }
Example #4
Source File: metrics.service.ts    From wise-old-man with MIT License 6 votes vote down vote up
private setupHttpHistogram() {
    this.httpHistogram = new prometheus.Histogram({
      name: 'http_request_duration_seconds',
      help: 'Duration of HTTP requests in microseconds',
      labelNames: ['method', 'route', 'status', 'userAgent'],
      buckets: [0.1, 0.3, 0.5, 0.7, 1, 3, 5, 7, 10, 30]
    });

    this.registry.registerMetric(this.httpHistogram);
  }
Example #5
Source File: metrics.service.ts    From wise-old-man with MIT License 6 votes vote down vote up
private setupJobHistogram() {
    this.jobHistogram = new prometheus.Histogram({
      name: 'job_duration_seconds',
      help: 'Duration of jobs in microseconds',
      labelNames: ['jobName', 'status', 'source'],
      buckets: [0.1, 0.5, 1, 5, 10, 30, 60]
    });

    this.registry.registerMetric(this.jobHistogram);
  }
Example #6
Source File: metrics.ts    From backstage with Apache License 2.0 5 votes vote down vote up
export function createHistogramMetric<T extends string>(
  config: HistogramConfiguration<T>,
): Histogram<T> {
  const existing = register.getSingleMetric(config.name) as Histogram<T>;
  return existing || new Histogram<T>(config);
}
Example #7
Source File: db.ts    From livepeer-com with MIT License 5 votes vote down vote up
metricHistogram: Histogram<keyof QueryHistogramLabels> = new Histogram({
  name: "livepeer_api_pgsql_query_duration_seconds",
  help: "duration histogram of pgsql queries",
  buckets: [0.003, 0.03, 0.1, 0.3, 1.5, 10],
  labelNames: ["query", "result"] as const,
})
Example #8
Source File: prometheus.ts    From monkeytype with GNU General Public License v3.0 5 votes vote down vote up
resultAcc = new Histogram({
  name: "result_acc",
  help: "Result accuracy",
  labelNames: ["mode", "mode2"],
  buckets: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
})
Example #9
Source File: prometheus.ts    From monkeytype with GNU General Public License v3.0 5 votes vote down vote up
resultDuration = new Histogram({
  name: "result_duration",
  help: "Result duration",
  buckets: [
    5, 10, 15, 30, 45, 60, 90, 120, 250, 500, 750, 1000, 1250, 1500, 1750, 2000,
    2500, 3000,
  ],
})
Example #10
Source File: metrics.service.ts    From wise-old-man with MIT License 5 votes vote down vote up
private jobHistogram: Histogram<JobParams>;
Example #11
Source File: metrics.service.ts    From wise-old-man with MIT License 5 votes vote down vote up
private httpHistogram: Histogram<HttpParams>;
Example #12
Source File: metrics.service.ts    From wise-old-man with MIT License 5 votes vote down vote up
private reactionHistogram: Histogram<ReactionParams>;