From 37b2076268f0fc21daac7e2f07eaf2d90a6f8555 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 11 Aug 2020 22:46:55 +0000 Subject: [PATCH] chore: update readme --- .../github.com/astaxie/beego/README.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/instrumentation/github.com/astaxie/beego/README.md b/instrumentation/github.com/astaxie/beego/README.md index a477fda61b7..195f655c189 100644 --- a/instrumentation/github.com/astaxie/beego/README.md +++ b/instrumentation/github.com/astaxie/beego/README.md @@ -35,3 +35,48 @@ You can customize instrumentation by passing any of the following options to `Ne | `WithPropagators(propagation.Propagators)` | The propagators to be used. If not specified, `global.Propagators()` will be used. | | `WithFilter(Filter)` | Adds an additional filter function to the configuration. Defaults to no filters. | | `WithSpanNameFormatter(SpanNameFormatter)` | The formatter used to format span names. If not specified, the route will be used instead. | + +You can also trace the `Render`, `RenderString`, and `RenderBytes` functions. You should disable the `AutoRender` setting either programmatically or in the config file, so you can explicitly call the traced implementations: + +```go +package main + +import ( + "github.com/astaxie/beego" + + otelBeego "go.opentelemetry.io/contrib/instrumentation/github.com/astaxie/beego" +) + +type ExampleController struct { + beego.Controller +} + +func (c *ExampleController) Get() { + c.TplName = "index.ptl" + + // explicit call to traced Render function + otelBeego.Render(&c.Controller) +} + +func main() { + // Init the tracer and metric export pipelines + + // Disable autorender + beego.BConfig.WebConfig.AutoRender = false + + // Create your routes + beego.Router("/", &ExampleController{}) + + // Create the MiddleWare + mware := otelBeego.NewOTelBeegoMiddleWare("example-server") + + // Run the server with the MiddleWare + beego.RunWithMiddleWares("localhost:8080", mware) +} +``` + +| Function | Description | +| -------- | ----------- | +| `Render(*beego.Controller) error` | Provides tracing to `beego.Render`. | +| `RenderString(*beego.Controller) (string, error)` | Provides tracing to `beego.RenderString`. | +| `RenderBytes(*beego.Controller) ([]byte, error)` | Provides tracing to `beego.RenderBytes`. |