Documentation ¶
Overview ¶
Package cat works as a client for Central Application Tracking(CAT).
Import
import cat "/your/path/to/cat"
Config
cat.DOMAIN = "your appid" cat.HOSTNAME = "your hostname" //optional cat.IP = "your hostip" //optional cat.TEMPFILE = ".cat" //optional, "your/path/to/.cat" cat.CAT_HOST = cat.UAT //or "http://cat.uat.qa.nt.ctripcorp.com"
Use Transaction
mycat := cat.Instance() func() { t := mycat.NewTransaction("URL", "Page") defer func() { p := recover() mycat.LogPanic(p) t.SetStatus(p) t.Complete() }() // do your bussiness here // perhaps panic t.AddData("k0", "v0") t.AddData("k1", "v1") }()
Use Event
mycat := cat.Instance() func() { e := mycat.NewEvent("Review", "New") e.AddData("k0", "v0") e.AddData("k1", "v1") e.SetStatus("0") e.Complete() }()
Use Heartbeat
mycat := cat.Instance() func() { h := mycat.NewHeartbeat("Heartbeat", "192.168.141.131") h.Set("System", "CPU", "0.3") h.Set("System", "DISK", "0.9") h.SetStatus("0") h.Complete() }()
Log Error As Event
mycat := cat.Instance() func() { err, ret := someMethod() mycat.LogError(err) }()
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( PROD string = "http://cat.ctripcorp.com" FAT string = "http://cat.fws.qa.nt.ctripcorp.com" UAT string = "http://cat.uat.qa.nt.ctripcorp.com" CAT_HOST string = FAT CAT_SERVERS []string DOMAIN string = "900407" HOSTNAME string = "" IP string = "" TEMPFILE string = ".cat" )
Configs about cat is required to be correct. The client is able to complement some of the configs, but is incapable of validation. Fortunately invalid configs causes failure of cat's init, thus users can be immediately aware of config fault.
View Source
var ( CONN_FACTORY = func() (conn net.Conn, err error) { servers := CAT_SERVERS size := len(servers) for i := 0; i < size; i++ { conn, err = net.Dial("tcp", servers[i]) if err == nil { return conn, err } } return nil, errors.New("Unable to access cat servers including backups.") } )
View Source
var LF = "\n"
View Source
var TAB = "\t"
Functions ¶
func Cat_init_if ¶
func Cat_init_if()
Cat_init_if initialize cat.go, which must be down before any other operations, for which Instance called it automatically.
Types ¶
type Cat ¶
type Cat interface { //Tree provides methods to create different kinds of messages Tree //Create a new simple Event without tags. LogEvent(t string, n string) //Create a new Event whose type is error and status is ERROR, //nil is ignored LogError(e error) //Create a new Event whose type is panic and status is ERROR, //nil is ignored LogPanic(e Panic) }
A tool instance for CAT. Use it to create Transaction, Event, Heartbeat, Trace... Every Cat instance has 1 Tree instance.
type Heartbeat ¶
type MessageId ¶
func NewMessageId ¶
func NewMessageId() MessageId
type MessageIdFactory ¶
var MESSAGE_ID_FACTORY MessageIdFactory = NewMessageIdFactory()
func NewMessageIdFactory ¶
func NewMessageIdFactory() MessageIdFactory
type Meta ¶
type Transaction ¶
type Transaction interface { Message AddChild(Message) Transaction Complete() }
func NewTransaction ¶
func NewTransaction(t string, n string, f Function) Transaction
Source Files ¶
Click to show internal directories.
Click to hide internal directories.