Skip to content
Snippets Groups Projects
Select Git revision
  • e24bf474ef08ea55b0df1d23688dfea51216e4fe
  • main default protected
  • renovate/main-zod-3.x
  • renovate/main-ghcr.io-renovatebot-base-image-10.x
  • renovate/main-ghcr.io-containerbase-devcontainer-13.x
  • next
  • revert-31645-feat/rename-gradle-wrapper-validation-action
  • renovate/main-redis-5.x
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • fix/36615-branch-reuse-bug
  • refactor/pin-new-value
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • 41.28.2
  • 41.28.1
  • 41.28.0
  • 41.27.1
  • 41.27.0
  • 41.26.2
  • 41.26.1
  • 41.26.0
  • 41.25.1
  • 41.25.0
  • 41.24.0
  • 41.23.5
  • 41.23.4
  • 41.23.3
  • 41.23.2
  • 41.23.1
  • 41.23.0
  • 41.22.0
  • 41.21.4
  • 41.21.3
41 results

index.ts

Blame
  • prometheus-metrics.js 3.31 KiB
    'use strict'
    
    const decamelize = require('decamelize')
    const prometheus = require('prom-client')
    
    module.exports = class PrometheusMetrics {
      constructor({ register } = {}) {
        this.register = register || new prometheus.Registry()
        this.counters = {
          numRequests: new prometheus.Counter({
            name: 'service_requests_total',
            help: 'Total service requests',
            labelNames: ['category', 'family', 'service'],
            registers: [this.register],
          }),
          responseTime: new prometheus.Histogram({
            name: 'service_response_millis',
            help: 'Service response time in milliseconds',
            // 250 ms increments up to 2 seconds, then 500 ms increments up to 8
            // seconds, then 1 second increments up to 15 seconds.
            buckets: [
              250,
              500,
              750,
              1000,
              1250,
              1500,
              1750,
              2000,
              2250,
              2500,
              2750,
              3000,
              3250,
              3500,
              3750,
              4000,
              4500,
              5000,
              5500,
              6000,
              6500,
              7000,
              7500,
              8000,
              9000,
              10000,
              11000,
              12000,
              13000,
              14000,
              15000,
            ],
            registers: [this.register],
          }),
          rateLimitExceeded: new prometheus.Counter({
            name: 'rate_limit_exceeded_total',
            help: 'Count of rate limit exceeded by type',
            labelNames: ['rate_limit_type'],
            registers: [this.register],
          }),
          serviceResponseSize: new prometheus.Histogram({
            name: 'service_response_bytes',
            help: 'Service response size in bytes',
            labelNames: ['category', 'family', 'service'],
            // buckets: 64KiB, 128KiB, 256KiB, 512KiB, 1MiB, 2MiB, 4MiB, 8MiB
            buckets: prometheus.exponentialBuckets(64 * 1024, 2, 8),
            registers: [this.register],
          }),
        }