🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

github.com/fetch-rewards/fiberprometheus/v2

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/fetch-rewards/fiberprometheus/v2

v2.6.6
Source
Go
Version published
Created
Source

fiberprometheus

Prometheus middleware for gofiber.

Release Discord Test Security Linter

Following metrics are available by default:

http_requests_total
http_request_duration_seconds
http_requests_in_progress_total

Install v2

go get -u github.com/gofiber/fiber/v2
go get -u github.com/ansrivas/fiberprometheus/v2

Example using v2

package main

import (
	"github.com/ansrivas/fiberprometheus/v2"
	"github.com/gofiber/fiber/v2"
)

func main() {
  app := fiber.New()

  // This here will appear as a label, one can also use
  // fiberprometheus.NewWith(servicename, namespace, subsystem )
  // or
  // NOTE: Following is not available in v1
  // labels := map[string]string{"custom_label1":"custom_value1", "custom_label2":"custom_value2"}
  // fiberprometheus.NewWithLabels(labels, namespace, subsystem )
  prometheus := fiberprometheus.New("my-service-name")
  prometheus.RegisterAt(app, "/metrics")
  app.Use(prometheus.Middleware)

  app.Get("/", func(c *fiber.Ctx) error {
    return c.SendString("Hello World")
  })

  app.Post("/some", func(c *fiber.Ctx) error {
    return c.SendString("Welcome!")
  })

  app.Listen(":3000")
}

Example using V1

package main

import (
  "github.com/gofiber/fiber"
  "github.com/ansrivas/fiberprometheus"
)

func main() {
  app := fiber.New()

  // This here will appear as a label, one can also use
  // fiberprometheus.NewWith(servicename, namespace, subsystem )
  prometheus := fiberprometheus.New("my-service-name")
  prometheus.RegisterAt(app, "/metrics")
  app.Use(prometheus.Middleware)

  app.Get("/", func(c *fiber.Ctx) {
    c.Send("Hello World")
  })

  app.Post("/some", func(c *fiber.Ctx) {
    c.Send("Welcome!")
  })

  app.Listen(3000)
}

Result

Grafana Board

FAQs

Package last updated on 07 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts