# README
How to use tracing using jaeger tracing
example in your main.go
:
package main
import (
// import go-lib from mrapry go-lib
"github.com/mrapry/go-lib/tracer"
)
func main() {
serviceName := strings.TrimSuffix("{servicename}-"+os.Getenv("SERVER_ENV"), "{-production or -dev or -stg}")
tracer.InitOpenTracing(os.Getenv("JAEGER_HOST"), serviceName)
}
example in your main_http.go
:
package main
import (
// import go-lib from mrapry go-lib
"github.com/mrapry/go-lib/tracer"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main_http() {
// using echo
e := echo.New()
e.Use(echo.WrapMiddleware(tracer.Middleware))
e.Use(middleware.BodyDump(func(c echo.Context, req []byte, res []byte) {
span := opentracing.SpanFromContext(c.Request().Context())
statusCode := c.Response().Status
ext.HTTPStatusCode.Set(span, uint16(statusCode))
if statusCode >= http.StatusBadRequest {
ext.Error.Set(span, true)
}
span.SetTag("response.body", string(res))
}))
}
# Functions
EchoRestTracerMiddleware for wrap from http inbound (request from client).
GetTraceID func.
GetTraceURL log trace url.
InitOpenTracing with agent and service name.
Log trace.
SetError func.
StartTrace starting trace child span from parent span.
WithTraceFunc functional with context and tags in function params.
# Constants
db method for tracer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
db tag error.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
Tracer for trace.