Documentation
¶
Overview ¶
Package prometheus 提供 metricsx 的 Prometheus 后端: 通过 WithPrometheus 注入 metricsx.New,懒创建 CounterVec / HistogramVec / GaugeVec,统一命名与标签。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶ added in v1.6.3
HTTPHandler 返回导出 Prometheus 文本格式的 http.Handler。 后端不是 Prometheus 时返回 500 错误处理器,避免业务侧直接依赖 prometheus/client_golang。
func Registry ¶
func Registry(m *metricsx.Metrics) (prometheus.Registerer, bool)
Registry 返回后端注册表;后端不是 Prometheus 时返回 false。
func WithPrometheus ¶
WithPrometheus 返回注入 Prometheus 后端的 metricsx 选项。
Types ¶
type Option ¶
type Option func(*sinkConfig)
Option 修改 Prometheus 后端配置。
func WithBuckets ¶
WithBuckets 设置 ObserveDuration 的直方图分桶,空串表示使用默认。
func WithNamespace ¶
WithNamespace 设置指标命名空间前缀(如 "myapp"),空串表示无前缀。
func WithRegistry ¶
func WithRegistry(r prometheus.Registerer) Option
WithRegistry 注入注册表,默认 prometheus.DefaultRegisterer。
Click to show internal directories.
Click to hide internal directories.