Directories ¶
Path | Synopsis |
---|---|
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() // ...
|
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() // ... |
Example: var group = rpcgroup.New(5000, "app1:5000", "app2:5000") func init() { id := "0001" group.Call(InitializeFunction, id) } var InitializeFunction = rpcgroup.Register(func(id string) { StartLogger(id) })
|
Example: var group = rpcgroup.New(5000, "app1:5000", "app2:5000") func init() { id := "0001" group.Call(InitializeFunction, id) } var InitializeFunction = rpcgroup.Register(func(id string) { StartLogger(id) }) |
Click to show internal directories.
Click to hide internal directories.