ppfiber

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

ppfiber

This package instruments the gofiber/fiber/v2 package.

Installation

$ go get github.com/pinpoint-apm/pinpoint-go-agent/plugin/fiber
import "github.com/pinpoint-apm/pinpoint-go-agent/plugin/fiber"

Usage

PkgGoDev

This package instruments inbound requests handled by a fiber instance. Register the Middleware as the middleware of the router to trace all handlers:

app := fiber.New()
app.Use(ppfiber.Middleware())

Use WrapHandler to select the handlers you want to track:

app.Get("/hello", ppfiber.WrapHandler(hello))

For each request, a pinpoint.Tracer is stored in the user context. By using the pinpoint.FromContext function, this tracer can be obtained in your handler. Alternatively, the context of the request may be propagated where the context that contains the pinpoint.Tracer is required.

package main

import (
    "github.com/gofiber/fiber/v2"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/fiber"
)

func hello(c *fiber.Ctx) error {
    tracer := pinpoint.FromContext(c.UserContext())
    defer tracer.NewSpanEvent("f1").EndSpanEvent()

    return c.SendString("Hello, World !!")
}

func main() {
    ... //setup agent
	
    app := fiber.New()
    app.Use(ppfiber.Middleware())
    log.Fatal(app.Listen(":9000"))
}

Full Example Source

This package supports URL Statistics feature. It aggregates response times, successes and failures for each router pattern.

Config Options

Documentation

Overview

Package ppfiber instruments the gofiber/fiber/v2 package (https://github.com/gofiber/fiber).

This package instruments inbound requests handled by a fiber instance. Register the Middleware as the middleware of the router to trace all handlers:

app := fiber.New()
app.Use(ppfiber.Middleware())

Use WrapHandler to select the handlers you want to track:

app.Get("/hello", ppfiber.WrapHandler(hello))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() func(c *fiber.Ctx) error

Middleware returns middleware that will trace incoming requests.

func WrapHandler

func WrapHandler(handler fiber.Handler) fiber.Handler

WrapHandler wraps the given fiber handler and adds the pinpoint.Tracer to the user context. By using the pinpoint.FromContext function, this tracer can be obtained.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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