| Tim Windelschmidt | 6d33a43 | 2025-02-04 14:34:25 +0100 | [diff] [blame] | 1 | // Copyright The Monogon Project Authors. |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| Jan Schär | 4a18022 | 2024-07-29 16:32:54 +0200 | [diff] [blame] | 4 | package dns |
| 5 | |
| 6 | import ( |
| 7 | "github.com/prometheus/client_golang/prometheus" |
| 8 | "github.com/prometheus/client_golang/prometheus/promauto" |
| 9 | ) |
| 10 | |
| 11 | // MetricsRegistry is the metrics registry in which all DNS metrics are |
| 12 | // registered. |
| 13 | var MetricsRegistry = prometheus.NewRegistry() |
| 14 | var MetricsFactory = promauto.With(MetricsRegistry) |
| 15 | |
| 16 | var ( |
| 17 | // rcode can be an uppercase rcode name, a numeric rcode if the rcode is not |
| 18 | // known, or one of: |
| 19 | // * redirected: The query was redirected by CNAME, so the final rcode |
| 20 | // is not yet known. |
| 21 | // * not_ready: The handler is not yet ready, SERVFAIL is replied. |
| 22 | handlerDuration = MetricsFactory.NewHistogramVec(prometheus.HistogramOpts{ |
| 23 | Namespace: "dnsserver", |
| 24 | Subsystem: "server", |
| 25 | Name: "handler_duration_seconds", |
| 26 | Buckets: prometheus.ExponentialBuckets(0.00025, 2, 16), // from 0.25ms to 8 seconds |
| 27 | Help: "Histogram of the time each handler took.", |
| 28 | }, []string{"handler", "rcode"}) |
| 29 | ) |