catutil

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 4 Imported by: 4

README

catutil

catutil

支持 gorm、mongodb、http 的 cat 监控

golang cat client: github.com/cat-go/cat

PS 使用之前需要先初始化 cat

type CatConf struct {
	Flag       bool   `json:"flag"`
	AppId      string `json:"app_id"`
	Port       int    `json:"port"`
	HttpPort   int    `json:"http_port"`
	ServerAddr string `json:"server_addr"`
	IsDebug    bool   `json:"is_debug"`
}

func initCat(c *CatConf) {
	if c.Flag {
		if c.Cat.IsDebug {
			cat.DebugOn()
		}
		cat.Init(&cat.Options{
			AppId:      c.AppId,
			Port:       c.Port,
			HttpPort:   c.HttpPort,
			ServerAddr: c.ServerAddr,
		})
	}
}

Documentation

Index

Constants

View Source
const (
	CatCtx               = "cat_ctx"
	CatCtxRootTran       = "cat_root_tran"
	CatCtxRedisTran      = "cat_redis_tran"
	CatCtxMysqlTran      = "cat_mysql_tran"
	CatCtxMongoDbTran    = "cat_mongo_db_tran"
	CatCtxHttpRemoteTran = "cat_http_remote_tran"

	TypeHttpRemote    = "HttpRemoteCall"
	TypeMongoDbPrefix = "MongoDb."
	TypeUrlStatus     = "URL.status"

	RemoteCallMethod    = "RemoteCall.Method"
	RemoteCallErr       = "RemoteCall.Err"
	RemoteCallStatus    = "RemoteCall.Status"
	RemoteCallScheme    = "RemoteCall.Scheme"
	TraceIdHeaderName   = "x-trace-id"
	ContextKeyRequestId = "requestId"
	ContextKeyTraceId   = "traceId"
	ContextKeyStartTime = "startTime"
)

Variables

This section is empty.

Functions

func GetRequestId

func GetRequestId(c context.Context) string

func GetRootTran

func GetRootTran(ctx context.Context) message.Transactor

func GetTraceId

func GetTraceId(ctx context.Context) string

func SetRequestId

func SetRequestId(c context.Context, requestId string)

func SetTraceId

func SetTraceId(c *gin.Context, tran message.Transactor)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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