Documentation ¶
Overview ¶
Package otelbeego instruments the github.com/astaxie/beego package.
Deprecated: This module is no longer supported. github.com/astaxie/beego is no longer maintained. Use github.com/beego/beego/v2 together with its instrumentation packages instead.
Index ¶
- func NewOTelBeegoMiddleWare(service string, options ...Option) beego.MiddleWare
- func Render(c *beego.Controller) error
- func RenderBytes(c *beego.Controller) ([]byte, error)
- func RenderString(c *beego.Controller) (string, error)
- func SemVersion() stringdeprecated
- func Template(name string) attribute.KeyValue
- func Version() string
- type Filter
- type Handler
- type Option
- type SpanNameFormatter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOTelBeegoMiddleWare ¶
func NewOTelBeegoMiddleWare(service string, options ...Option) beego.MiddleWare
NewOTelBeegoMiddleWare 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.
Example ¶
package main import ( "github.com/astaxie/beego" ) type ExampleController struct { beego.Controller } func (c *ExampleController) Get() { // name of the template in the views directory c.TplName = "index.tpl" // explicit call to Render if err := Render(&c.Controller); err != nil { c.Abort("500") } } func main() { // Init the trace and meter provider // Disable autorender beego.BConfig.WebConfig.AutoRender = false // Create routes beego.Router("/", &ExampleController{}) // Create the middleware mware := NewOTelBeegoMiddleWare("exampe-server") // Start the server using the OTel middleware beego.RunWithMiddleWares(":7777", mware) }
Output:
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 SemVersion
deprecated
added in
v0.24.0
Types ¶
type Handler ¶
Handler implements the http.Handler interface and provides trace and metrics to beego web apps.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies a configuration to the given config.
func WithFilter ¶
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.