Categorygithub.com/megaease/metrics-go
modulepackage
1.0.1
Repository: https://github.com/megaease/metrics-go.git
Documentation: pkg.go.dev

# README

Metrics-Go

metrics-go is a powerful and flexible library for collecting, managing, and exposing application metrics in Go. Designed for general-purpose use, it supports Prometheus as the primary backend for monitoring and provides tools to seamlessly integrate with web frameworks like Echo and Gin.

Features

  • Prometheus Integration: Expose metrics easily via a /metrics like endpoint.
  • Granular HTTP Metrics: Track HTTP request durations, sizes, and statuses.
  • Framework-Specific Middleware: Built-in support for Gin and Echo.
  • Custom Metrics: Extend functionality to add business-specific metrics.
  • Real-Time Monitoring: Collect exponentially-weighted rate, percentile latency metrics (e.g., m1, m5, p99, p95).

Install

go get github.com/megaease/metrics-go

Quick Start

The MetricsHub serves as the central component to manage and update metrics:

import (
	"github.com/labstack/echo/v4"
	"github.com/megaease/metrics-go/metricshub"
	"github.com/megaease/metrics-go/middleware"
)

config := &metricshub.MetricsHubConfig{
    ServiceName: "vm-operator-echo",
    HostName:    "sprite-run-serverless-01",
}
// 1. Initialize MetricsHub
mHub := metricshub.NewMetricsHub(config)

// 2. Expose Metrics via HTTP
app := echo.New()
app.Use(middleware.NewEchoMetricsCollector(mHub))
app.GET("/metrics", echo.WrapHandler(mHub.HTTPHandler()))
app.Start(fmt.Sprintf(":%d", 8080))

The full examples can be found in the examples directory.

Advanced Usage

TODO

Community

Contributing

The project welcomes contributions and suggestions that abide by the CNCF Code of Conduct.

License

Easegress is under the Apache 2.0 license. See the LICENSE file for details.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author