Documentation
¶
Overview ¶
INSTRUCTION:
Put the following code in initialize()
logid := GetNextLogID() StartLogger(logid)
It is possible to add user defined regions for trace by adding:
defer trace.StartRegion(context.Background(), regionName).End()
For example, in order to add it to every handler of http, one can write a wrapper as follows:
handleFunc := func(p goji.Pattern, h func(http.ResponseWriter, *http.Request)) {
regionName := GetFunctionName(h)
mux.HandleFunc(p, func(a http.ResponseWriter, b *http.Request) {
defer trace.StartRegion(context.Background(), regionName).End()
h(a, b)
})
}
If you are using echo, the following code works:
func TraceMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
defer trace.StartRegion(c.Request().Context(), c.Request().Method + " " + c.Path()).End()
return next(c)
}
}
func main() {
e := echo.New()
// ...
e.Use(TraceMiddleware)
}
Index ¶
- Variables
- func AlpMiddleware(next echo.HandlerFunc) echo.HandlerFunc
- func ExecuteCommand(bashscript string) (string, error)
- func GetFunctionName(i interface{}) string
- func GetNextLogID() string
- func MustExecuteCommand(bashscript string) string
- func StartLogger(id string, BenchmarkTime int)
- type AlpTrace
- type AlpTraceRegion
Constants ¶
This section is empty.
Variables ¶
View Source
var LogFilePath = "/tmp/isucon/"
View Source
var LoggerBashScript = "/usr/bin/logger.sh"
View Source
var UseTrace = false
Functions ¶
func AlpMiddleware ¶
func AlpMiddleware(next echo.HandlerFunc) echo.HandlerFunc
func ExecuteCommand ¶
func GetFunctionName ¶
func GetFunctionName(i interface{}) string
func GetNextLogID ¶
func GetNextLogID() string
func MustExecuteCommand ¶
func StartLogger ¶
Types ¶
type AlpTrace ¶
type AlpTrace struct {
// contains filtered or unexported fields
}
func (*AlpTrace) Start ¶
func (c *AlpTrace) Start() *AlpTraceRegion
type AlpTraceRegion ¶
type AlpTraceRegion struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.