fasthttpprometheus

package module
v0.0.0-...-5aafe5c Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 8 Imported by: 0

README

fasthttp-prometheus

Prometheus metrics exporter for go fasthttp framework

Installation

$ go get github.com/flf2ko/fasthttp-prometheus

Usage

package main

import (
    "fmt"
    "github.com/buaazp/fasthttprouter"
    "github.com/valyala/fasthttp"
    "log"
    fastp "go-fasthttp-prometheus"
)

func Index(ctx *fasthttp.RequestCtx) {
    fmt.Fprint(ctx, "Welcome!\n")
}

func main() {
    router := fasthttprouter.New()
    APIregist(router)

    p := fastp.NewPrometheus("fasthttp")
    fastpHandler := p.WrapHandler(router)

    log.Fatal(fasthttp.ListenAndServe(":8080", fastpHandler))
}

func APIregist(r *fasthttprouter.Router) {
    r.GET("/", Index)
}

Inspired by

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Registry

func Registry(r *prometheus.Registry) func(*Prometheus)

Registry is an option allowing to set a *prometheus.Registry with New

func Subsystem

func Subsystem(sub string) func(*Prometheus)

Subsystem is an option which allows to set the subsystem when initializing with New

Types

type FasthttpHandlerFunc

type FasthttpHandlerFunc func(*fasthttp.RequestCtx)

type Prometheus

type Prometheus struct {
	MetricsPath string
	// contains filtered or unexported fields
}

func NewPrometheus

func NewPrometheus(options ...func(*Prometheus)) *Prometheus

func (*Prometheus) WrapHandler

Jump to

Keyboard shortcuts

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