Path: blob/main/pkg/integrations/handler_integration.go
5282 views
package integrations12import (3"context"4"net/http"56"github.com/grafana/agent/pkg/integrations/config"7)89// NewHandlerIntegration creates a new named integration that will call handler10// when metrics are needed.11func NewHandlerIntegration(name string, handler http.Handler) Integration {12return &handlerIntegration{name: name, handler: handler}13}1415type handlerIntegration struct {16name string17handler http.Handler18}1920func (hi *handlerIntegration) MetricsHandler() (http.Handler, error) {21return hi.handler, nil22}2324func (hi *handlerIntegration) ScrapeConfigs() []config.ScrapeConfig {25return []config.ScrapeConfig{{26JobName: hi.name,27MetricsPath: "/metrics",28}}29}3031func (hi *handlerIntegration) Run(ctx context.Context) error {32<-ctx.Done()33return nil34}353637