mwbeego

package module
v0.0.6 Latest Latest
Warning

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

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

README


go get github.com/middleware-labs/golang-apm-beego-beego

Distributed Tracing

import (
	"github.com/beego/beego/v2/server/web"
	mwbeego "github.com/middleware-labs/golang-apm-beego-beego"
	track "github.com/middleware-labs/golang-apm/tracker"
)
func main(){
	config, _ := track.Track(
		track.WithConfigTag("service", "your service name"),
		track.WithConfigTag("projectName", "your project name"),
	)
	mware := mwbeego.MiddleWare(config.ServiceName)
	web.RunWithMiddleWares(":7777", mware)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MiddleWare added in v0.0.2

func MiddleWare(service string, options ...Option) beego.MiddleWare

MiddleWare creates a MiddleWare that provides OpenTelemetry tracing and metrics to a Beego web app. Parameter service should describe the name of the (virtual) server handling the request. The OTelBeegoMiddleWare can be configured using the provided Options.

func Render

func Render(c *beego.Controller) error

Render traces beego.Controller.Render. Use this function if you want to add a child span for the rendering of a template file. Disable autorender before use, and call this function explicitly.

func RenderBytes

func RenderBytes(c *beego.Controller) ([]byte, error)

RenderBytes traces beego.Controller.RenderBytes. Use this function if you want to add a child span for the rendering of a template file to its byte representation. Disable autorender before use, and call this function explicitly.

func RenderString

func RenderString(c *beego.Controller) (string, error)

RenderString traces beego.Controller.RenderString. Use this function if you want to add a child span for the rendering of a template file to its string representation. Disable autorender before use, and call this function explicitly.

func Template

func Template(name string) attribute.KeyValue

Template returns the template name as a KeyValue pair.

Types

type Filter

type Filter func(*http.Request) bool

Filter returns true if the request should be traced.

type Handler

type Handler struct {
	http.Handler
}

Handler implements the http.Handler interface and provides trace and metrics to beego web apps.

func (*Handler) ServeHTTP

func (o *Handler) ServeHTTP(rr http.ResponseWriter, req *http.Request)

ServerHTTP calls the configured handler to serve HTTP for req to rr.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option applies a configuration to the given config.

func WithFilter

func WithFilter(f Filter) Option

WithFilter adds the given filter for use in the middleware. Defaults to no filters.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies a meter provider to use for creating a meter. If none is specified, the global provider is used.

func WithPropagators

func WithPropagators(propagators propagation.TextMapPropagator) Option

WithPropagators sets the propagators used in the middleware. Defaults to global.Propagators().

func WithSpanNameFormatter

func WithSpanNameFormatter(f SpanNameFormatter) Option

WithSpanNameFormatter sets the formatter to be used to format span names. Defaults to the path template.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.

type SpanNameFormatter

type SpanNameFormatter func(operation string, req *http.Request) string

SpanNameFormatter creates a custom span name from the operation and request object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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