ppbeego

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

ppbeego

This package instruments the beego/v2 package.

Installation

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

Usage

PkgGoDev

server

This package instruments inbound requests handled by a beego instance. Register the ServerFilterChain as the filter chain of the router to trace all handlers:

web.InsertFilterChain("/*", ppbeego.ServerFilterChain())

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/beego/beego/v2/server/web"
    "github.com/pinpoint-apm/pinpoint-go-agent"
    "github.com/pinpoint-apm/pinpoint-go-agent/plugin/beego"
)

func (m *MainController) Hello() {
    tracer := pinpoint.FromContext(m.Ctx.Request.Context())
    defer tracer.NewSpanEvent("f1").EndSpanEvent()

    m.Ctx.WriteString("hello, world!!")
}

func main() {
    //setup agent
 
	ctrl := &MainController{}
	web.Router("/hello", ctrl, "get:Hello")
	web.InsertFilterChain("/*", ppbeego.ServerFilterChain())
	web.Run("localhost:9000")
}

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

Config Options
client

This package instruments outbound requests and add distributed tracing headers. Add the ClientFilterChain as the filter chain of the request.

req := httplib.Get("http://localhost:9090/")
req.AddFilters(ppbeego.ClientFilterChain(tracer))
import (
	"github.com/beego/beego/v2/client/httplib"
	"github.com/pinpoint-apm/pinpoint-go-agent"
	"github.com/pinpoint-apm/pinpoint-go-agent/plugin/beego"
)

func (m *MainController) Get() {
    tracer := pinpoint.FromContext(m.Ctx.Request.Context())

    req := httplib.Get("http://localhost:9090/")
    req.AddFilters(ppbeego.ClientFilterChain(tracer))
    str, _ := req.String()
    m.Ctx.WriteString(str)
}

Full Example Source

Config Options

Documentation

Overview

Package ppbeego instruments the beego/v2 package (https://github.com/beego/beego).

This package instruments inbound requests handled by a beego instance. Register the ServerFilterChain as the filter chain of the router to trace all handlers:

web.InsertFilterChain("/*", ppbeego.ServerFilterChain())

This package instruments outbound requests and add distributed tracing headers. Add the ClientFilterChain as the filter chain of the request:

req := httplib.Get("http://localhost:9090/")
req.AddFilters(ppbeego.ClientFilterChain(tracer))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientFilterChain added in v1.3.0

func ClientFilterChain(tracer pinpoint.Tracer) func(httplib.Filter) httplib.Filter

ClientFilterChain returns filter function that will trace the outgoing requests.

func DoRequest

func DoRequest(tracer pinpoint.Tracer, req *httplib.BeegoHTTPRequest) (resp *http.Response, err error)

DoRequest is deprecated. Use ClientFilterChain.

func Middleware

func Middleware() func(http.Handler) http.Handler

Middleware is deprecated. Use ServerFilterChain.

func ServerFilterChain added in v1.3.0

func ServerFilterChain() func(web.FilterFunc) web.FilterFunc

ServerFilterChain returns filter function that will trace the incoming requests.

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