# README
Instana instrumentation for Beego framework
This module contains middleware to instrument HTTP services written with https://github.com/beego/beego
.
Installation
To add the module to your go.mod
file run the following command in your project directory:
$ go get github.com/instana/go-sensor/instrumentation/instabeego
Usage
Web server instrumentation
// create an Instana collector
c := instana.InitCollector(&instana.Options{
Service: "beego-server",
EnableAutoProfile: true,
})
// instrument the web server
instabeego.InstrumentWebServer(c)
// define API
beego.Get("/foo", func(ctx *beecontext.Context) {/* ... */})
// Run beego application
beego.Run()
// ...
HTTP client instrumentation
// create an Instana collector
c := instana.InitCollector(&instana.Options{
Service: "my-http-client",
EnableAutoProfile: true,
})
// get the parent span and inject into the request context
ctx := instana.ContextWithSpan(context.Background(), /* parent span */)
// create a new http request using beego
req := httplib.NewBeegoRequestWithCtx(ctx, "https://www.instana.com", http.MethodGet)
// instrument the client request
instabeego.InstrumentRequest(c, req)
// execute the client request and get the response
_, err := req.Response()
// ...
# Functions
InstrumentRequest wrap the original BeegoHTTPRequest transport with instana.RoundTripper().
InstrumentWebServer wraps beego's handlers execution.
# Constants
Version is the instrumentation module semantic version.