ppecho

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: 5 Imported by: 0

README

ppecho

This package instruments the labstack/echo package.

Installation

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

Usage

PkgGoDev

This package instruments inbound requests handled by an echo.Router. Register the Middleware as the middleware of the router to trace all handlers:

e := echo.New()
e.Use(ppecho.Middleware())

Use WrapHandler to select the handlers you want to track:

e.GET("/hello", ppecho.WrapHandler(hello))

For each request, a pinpoint.Tracer is stored in the request 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/labstack/echo"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/echo"
)

func hello(c echo.Context) error {
    return c.String(200, "Hello World!!")
}

func main() {
    ... //setup agent
	
    e := echo.New()
    e.Use(ppecho.Middleware())

    e.GET("/hello", hello)
    e.Start(":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 ppecho instruments the labstack/echo package (https://github.com/labstack/echo).

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

e := echo.New()
e.Use(ppecho.Middleware())

Use WrapHandler to select the handlers you want to track:

e.GET("/hello", ppecho.WrapHandler(hello))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() echo.MiddlewareFunc

Middleware returns an echo middleware that creates a pinpoint.Tracer that instruments the echo handler function.

func WrapHandler

func WrapHandler(handler echo.HandlerFunc) echo.HandlerFunc

WrapHandler wraps the given echo handler and adds the pinpoint.Tracer to the request's 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