trace

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 26 Imported by: 36

Documentation

Overview

github.com/whatap/go-api/trace

github.com/whatap/go-api/trace

Index

Constants

View Source
const (
	PACKET_DB_MAX_SIZE           = 4 * 1024  // max size of sql
	PACKET_SQL_MAX_SIZE          = 32 * 1024 // max size of sql
	PACKET_HTTPC_MAX_SIZE        = 32 * 1024 // max size of sql
	PACKET_MESSAGE_MAX_SIZE      = 32 * 1024 // max size of message
	PACKET_METHOD_STACK_MAX_SIZE = 32 * 1024 // max size of message

	COMPILE_FILE_MAX_SIZE = 2 * 1024 // max size of filename

	HTTP_HOST_MAX_SIZE   = 2 * 1024 // max size of host
	HTTP_URI_MAX_SIZE    = 2 * 1024 // max size of uri
	HTTP_METHOD_MAX_SIZE = 256      // max size of method
	HTTP_IP_MAX_SIZE     = 256      // max size of ip(request_addr)
	HTTP_UA_MAX_SIZE     = 2 * 1024 // max size of user agent
	HTTP_REF_MAX_SIZE    = 2 * 1024 // max size of referer
	HTTP_USERID_MAX_SIZE = 2 * 1024 // max size of userid

	HTTP_PARAM_MAX_COUNT      = 20
	HTTP_PARAM_KEY_MAX_SIZE   = 255 // = 을 빼고 255 byte
	HTTP_PARAM_VALUE_MAX_SIZE = 256

	HTTP_HEADER_MAX_COUNT      = 20
	HTTP_HEADER_KEY_MAX_SIZE   = 255 // = 을 빼고 255 byte
	HTTP_HEADER_VALUE_MAX_SIZE = 256

	SQL_PARAM_MAX_COUNT      = 20
	SQL_PARAM_VALUE_MAX_SIZE = 256

	STEP_ERROR_MESSAGE_MAX_SIZE = 4 * 1024
)
View Source
const (
	STAT_METHOD = 0
	STAT_SQL    = 1
	STAT_HTTPC  = 2
	STAT_DBC    = 3
	STAT_SOCKET = 4
)
View Source
const (
	UDP_READ_MAX                    = 64 * 1024
	UDP_PACKET_BUFFER               = 64 * 1024
	UDP_PACKET_BUFFER_CHUNKED_LIMIT = 48 * 1024
	UDP_PACKET_CHANNEL_MAX          = 2048
	UDP_PACKET_FLUSH_TIMEOUT        = 10 * 1000

	UDP_PACKET_HEADER_SIZE = 9
	// typ pos 0
	UDP_PACKET_HEADER_TYPE_POS = 0
	// ver pos 1
	UDP_PACKET_HEADER_VER_POS = 1
	// len pos 5
	UDP_PACKET_HEADER_LEN_POS = 5

	UDP_PACKET_SQL_MAX_SIZE = 32768
)

Variables

View Source
var (
	WHATAP_COOKIE_NAME = "WHATAP"
)

Functions

func AddGIDTraceCtx added in v0.2.0

func AddGIDTraceCtx(GID int64, traceCtx *TraceCtx)

func CloseTraceContext

func CloseTraceContext(ctx *TraceCtx)

func End

func End(ctx context.Context, err error) error

func Error

func Error(ctx context.Context, err error) error

func Func

func Func(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

wrapping handler function, example : http.HandleFunc(func(http.ResponseWriter, *http.Request))

func GetAgentTraceContext added in v0.2.0

func GetAgentTraceContext(tCtx *TraceCtx) *agenttrace.TraceContext

func GetClientId

func GetClientId(r *http.Request, remoteIP string) string

func GetGID added in v0.1.12

func GetGID() int64

func GetMTrace

func GetMTrace(ctx context.Context) http.Header

func GetRemoteIP added in v0.3.0

func GetRemoteIP(remoteAddr string, header map[string][]string) string

func GetTxid

func GetTxid(ctx context.Context) int64

func GetWhatapCookie

func GetWhatapCookie(r *http.Request) (cookie *http.Cookie, exists bool)

func HandlerFunc

func HandlerFunc(handler func(http.ResponseWriter, *http.Request)) http.HandlerFunc

wrapping type of http.HanderFunc, example : http.Handle(pattern, http.HandlerFunc)

func Init

func Init(m map[string]string)

func ParseHeader added in v0.2.0

func ParseHeader(m map[string][]string) string

func ParseParameter added in v0.2.0

func ParseParameter(m map[string][]string) string

func RemoveGIDTraceCtx added in v0.2.0

func RemoveGIDTraceCtx(GID int64)

func SetHeader

func SetHeader(ctx context.Context, m map[string][]string)

func SetParameter

func SetParameter(ctx context.Context, m map[string][]string)

func SetWhatapCookie added in v0.1.14

func SetWhatapCookie(w http.ResponseWriter, cookie *http.Cookie)

func Shutdown

func Shutdown()

func Start

func Start(ctx context.Context, name string) (context.Context, error)

func StartWithContext

func StartWithContext(ctx context.Context, name string) (context.Context, error)

func StartWithRequest

func StartWithRequest(r *http.Request) (context.Context, error)

func Step

func Step(ctx context.Context, title, message string, elapsed, value int) error

func UpdateMtrace

func UpdateMtrace(traceCtx *TraceCtx, header http.Header)

func UpdateMtraceWithContext

func UpdateMtraceWithContext(ctx context.Context, header http.Header)

Types

type TraceCtx

type TraceCtx struct {
	Txid int64
	GID  int64

	Name      string
	StartTime int64

	Ctx *agenttrace.TraceContext

	// Pack
	Host             string
	Uri              string
	Ipaddr           string
	UAgent           string
	Ref              string
	WClientId        string
	HttpMethod       string
	IsStaticContents string
	Status           int32

	MTid        int64
	MDepth      int32
	MStepId     int64
	MCallerTxid int64

	MCallee     int64
	MCallerSpec string
	MCallerUrl  string

	MCallerPoidKey string

	MCallerStepId int64
	// traceparent traceid
	MCallerTraceId string

	TraceMtraceCallerValue      string
	TraceMtracePoidValue        string
	TraceMtraceSpecValue        string
	TraceMtraceMcallee          int64
	TraceMtraceTraceparentValue string
}

func GetGIDTraceCtx added in v0.2.0

func GetGIDTraceCtx(GID int64) *TraceCtx

func GetTraceContext

func GetTraceContext(ctx context.Context) (context.Context, *TraceCtx)

func NewTraceContext

func NewTraceContext(ctx context.Context) (context.Context, *TraceCtx)

func NewTraceCtx

func NewTraceCtx() *TraceCtx

func PoolTraceContext

func PoolTraceContext() *TraceCtx

func (*TraceCtx) Clear

func (this *TraceCtx) Clear()

func (*TraceCtx) GetElapsedTime

func (this *TraceCtx) GetElapsedTime() int

type WrapResponseWriter added in v0.1.9

type WrapResponseWriter struct {
	http.ResponseWriter
	Status int
}

func (*WrapResponseWriter) WriteHeader added in v0.1.9

func (l *WrapResponseWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL