metricsfx

package
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

README

ajan/metricsfx

Overview

The metricsfx package provides metrics collection and monitoring utilities using Prometheus. It integrates with other components to provide metrics for HTTP services, gRPC services, and custom metrics.

Features

  • Prometheus metrics integration
  • HTTP metrics collection
  • gRPC metrics collection
  • Custom metrics support
  • Integration with dependency injection
  • Automatic metric registration

API

MetricsProvider

The main interface for metrics functionality:

// Create a new metrics registry
registry := prometheus.NewRegistry()

// Create metrics provider
metricsProvider := metricsfx.NewMetricsProvider(registry)

// Register custom metrics
counter := prometheus.NewCounter(prometheus.CounterOpts{
  Name: "my_counter",
  Help: "Example counter",
})
metricsProvider.GetRegistry().MustRegister(counter)
HTTP Integration
// Add metrics middleware to your HTTP router
router.Use(metricsfx.NewMetricsMiddleware(metricsProvider))
gRPC Integration
// Add metrics interceptor to your gRPC server
grpcServer := grpc.NewServer(
  grpc.UnaryInterceptor(metricsfx.NewMetricsInterceptor(metricsProvider)),
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricsProvider

type MetricsProvider struct {
	// contains filtered or unexported fields
}

func NewMetricsProvider

func NewMetricsProvider() *MetricsProvider

func (*MetricsProvider) GetRegistry

func (mp *MetricsProvider) GetRegistry() *prometheus.Registry

func (*MetricsProvider) RegisterNativeCollectors

func (mp *MetricsProvider) RegisterNativeCollectors() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL